How to capture screenshot during Selenium/Appium test?
Use following method for getting screenshot during
Selenium/Appium test, just create a GetScreenshot.java
class and paste the below code.
public class GetScreenshot {
public static String capture(WebDriver driver, String screenShotName) throws IOException {
TakesScreenshot ts = (TakesScreenshot)driver;
File source = ts.getScreenshotAs(OutputType.FILE);
String dest = System.getProperty("user.dir") + "\\screenshots\\" + screenShotName + ".png";
File destination = new File(dest);
FileUtils.copyFile(source, destination);
return dest;
}
}
Call above method like this:
GetScreenshot.capture(driver, "putScreenshotName");
Comments
Post a Comment