Screen Shot

 1. How can I capture screenshots using Selenium WebDriver?

  1. Use getScreenShotAs() method
  2. It is in the TakesScreenShot Interface
  3. create reference of TakesScreenShot interface. 
  4. Get the screen shot using getScreenShotAs().
  5.  By default it will store screen shots in temp folder. 
  6. Create destination to store the file using File class. 
  7. Copy the file from src to destination using copyFile() of FileUtils class
File scrFile =((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(scrFile, new File(“D:\\testScreenShot.jpg”));

2. Can you explain how to capture and save a screenshot using Selenium WebDriver?

We can use the TakeScreenshot function to capture the screenshot and the getScreenshotAs() command to save the screenshot.

No comments:

Post a Comment

Cucumber

What is Cucumber? Definition : Cucumber is an open-source tool that supports BDD . Purpose : Bridges the communication gap between business ...