Sunday, January 26, 2020

Two Way to take Screen Shot in Selenium Webdriver Java

0 comments



Method 1:


File Source=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try{
FileHandler.copy(Source, new File(".\\shots\\Screenshot.png"));
}
catch(IOException E)
{
E.printStackTrace();
}


Method 2:


TakesScreenshot screenShot=((TakesScreenshot)driver);
File source=screenShot.getScreenshotAs(OutputType.FILE);
try {
FileHandler.copy(scrshot, new File(".\\shots\\Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}

No comments:

Post a Comment