1. How can I capture screenshots using Selenium WebDriver?
- Use getScreenShotAs() method
- It is in the TakesScreenShot Interface
- create reference of TakesScreenShot interface.
- Get the screen shot using getScreenShotAs().
- By default it will store screen shots in temp folder.
- Create destination to store the file using File class.
- 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