![]() Let’s incorporate this step into a code snippet. This is it! Just two statements and you will be able to take the screenshot. To store the taken screenshot into a file, the below statement is used:įpyFile(screenshotFile, new File("path of the file you want to save the screenshot to")) Here’s the syntax to capture the screenshot:įile screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE) This interface provides a method known as getScreenshotAs which helps to capture the screenshot and store it in the desired location. You can check the detail of the interface here. Selenium provides an out-of-the-box capability called TakeScreenShot interface that can be used for taking screenshots of the viewable area. This is the most used approach of taking screenshots of applications under automation and the easiest one as well. The cloud-based platform supporting screenshots of AUT.Īutomated Selenium Test Scripts for Taking Screenshots of Viewable Area.capturing screenshot of the full webpage. To start, there are four major ways of capturing screenshot images using Selenium Webdriver. Therefore in this post, we would be looking at how you can take automated screenshots of web pages for different purposes using Selenium WebDriver automation scripts. ![]() Now with that said, when we say screenshot we could mean capturing an image of any part of the screen including the image of an element in question or even a screenshot of the whole page. For automation testing with selenium, these screenshots help to distinguish whether the failures are due to application failure or due to script failure. These proofs are, in turn, used for debugging to find out what went wrong and the reason for failure. In automation testing, especially where a typical test run may involve hundreds of commands and test cases, automated screenshots taken at critical assertions are important for developers and testers in making sure that every test case executed as it should. Whenever a tester finds and reports a bug, that bug would not be taken seriously without supporting screenshots or even videos of the issue. This is equally true no matter the type of testing you are doing and that includes selenium automation testing.
0 Comments
Leave a Reply. |