How To Capture Screenshot in Selenium Using Java
Capturing Screenshot in selenium
While testing of application whenever we encounter any bug it is a common behaviour to take screenshots where the deviation from the expected result.In Selenium webdriver screenshot is mainly used for bug analysis. In this tutorial, we are going to learn how to take capture screenshots in selenium and the importance of screenshots in selenium webdriver.
- How to take screenshot in selenium webdriver using java?
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
- Screenshot of full page
- Screenshot of a particular element
- Screenshot of viewable part of page.
- How to take screenshot of a full page in selenium webdriver using java?
Screenshot s=new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
ImageIO.write(s.getImage(),"PNG",new File("C:\\projectScreenshots\\fullPageScreenshot.png"));
Post a Comment
0 Comments