I have below Configuration :
Selenium 3.8.0
Java 8
Chrome Browser 60
Chromedriver v 2.31 64bit
I'm running my test in chrome headless mode. The issues is, the browser get unresponsive while it switch to new tab and try to capture the snap.
Following Error recorded :
[727.930][SEVERE]: Timed out receiving message from renderer: 600.000
[727.934][WARNING]: screenshot failed, retrying
The code where it causing the issue :
if(myprofile.postalAddress.size()>0)
{
myprofile.getGetAddressMapIcon().get(0).click();
LogWriter.logger.info("Address Clicked");
CommonMethods.switchWindow(driver);
TakeScreenshot.passedScreenShot("GoogleMap");
driver.close();
CommonMethods.switchToParentWindow(driver);
LogWriter.logger.info("Map Window closed");
}
SwitchWindow
Method :
public static void switchWindow(WebDriver driver) throws IOException
{
parentWindow = driver.getWindowHandle();
for (String winHandle : driver.getWindowHandles())
{
driver.switchTo().window(winHandle);
LogWriter.logger.info("-----");
}
LogWriter.logger.info("Window Title : " + driver.getTitle());
}
TakeScreenshot
Method :
public static void passedScreenShot(String testname) throws IOException
{
File sourceFile = ((TakesScreenshot) DriverSetup.driver).getScreenshotAs(OutputType.FILE);
DateFormat dateFormat = new SimpleDateFormat("dd_MMM_yyyy__hh_mm_ssaa");
destDir = System.getProperty("user.home")+"/AutomationTemp/Reports/Screenshots/PassedTest";
new File(destDir).mkdirs();
String destFile = dateFormat.format(new Date())+"RCON" + "_" + testname +".png";
try
{
Files.copy(sourceFile, new File(destDir + "/" + destFile));
}
catch (IOException e)
{
e.printStackTrace();
}
}
While I'm running the same in GUI mode then all all works fine. Can someone help what is wrong here ?