Team, Let's learn the process to take the Screenshot in Selenium code


public void takeScreenShot()
{
//Screenshots
File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

String fileName = new SimpleDateFormat("dd-MM-yyyy_hhmmss'.png'").format(new Date());

File dest = new File("./ScreenShot/" + fileName);

try {
FileUtils.copyFile(src, dest);
} catch (IOException e) {
e.printStackTrace();
}
  }



After executing this > refresh the project > a New Folder is created in Project named as "ScreenShot" , under this screenshot is created.

Post a Comment

Facebook

QA Artifacts for Advanced Learning