My tests are in git, and I am running them on the grid using Remote Webdriver. I have to open a static HTML in grid. For this, I have checked in the HTML file in the same git repo where my testis. I have something like below in my test to open the file (which works on my local).
public void openHtmlFile() {
String htmlFile=new TestHelper().getImportFile(TestConstants.OCI_HTML_FILE);
// Below gives exact path of the HTML file. Like when I am running it in my local, it gives exact path of the HTML file where it is kept in git repo in my local.
log.info("Going to URL: " + htmlFile);
Path sampleFile= Paths.get(htmlFile);
driver.get(sampleFile.toUri().toString());
}
When I run my test in my local, the HTML file opens fine, but on the grid it says, "file not found". Here is the screenshot of the page which gets opened in grid. enter image description here
It navigates to URL which is the absolute path of that file in git workspace, so obviously, the node won't find the file as it's a different machine. How can I handle this situation? To add more details, I am running test thru Jenkins, so obviously I am cloning the git repo in Jenkins slave first, and then tests execution follows. But Jenkins slave and grid node are a different machine, hence the file not found the issue.