


PDFWRITER GETINSTANCE JAVA DRIVER
In the above code, we are using the getScreenShotAs method after casting the driver object to the TakesScreenshot interface type. ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE)

So to take a screenshot of the page, we have to cast our driver object to the TakesScreenshot interface type by adding the below code. We can take a screenshot of a webpage using the getScreenshotAs() method from the TakesScreenshot, but we cannot initialize TakesScreenshot as it is an interface We can convert all the above output types into png images we will discuss those later parts of this tutorial. We can store the captured screenshot in different formats all the formats are present in the OutputType interface.įormats available in the OutputType Interface: WebElement Screenshot Syntax : getScreenshotAs(OutputType target) This process is called Multiple Inheritance in java, i.e., Class(browser) implementing two Interfaces(Webdriver and TakesScreenshot).Ģ. So we have screenshot method implementations in our driver classes. Our browser classes (Like ChromeDriver, FirefoxDriver) extends RemoteWebdriver, and RemoteWedriver implements TakesScreenshot Interface along with Webdriver Interface. There is an interface called TakesScreenshot which provides the getScreenshotAs() method and which selenium uses to take a screenshot. We can take a screenshot of a webpage in selenium using getScreenshotAs() method, Webdriver interface doesn't provide a method to take a screenshot. When an unexpected alert comes in to focus.Actual and Expected values are not matching.We can also take screenshots using Selenium.įailures may occur because of below reasons: When manual tester faces any discrepancy in the verification, i.e., when there is a difference in actual and expected values, manual testers tend to take screenshots as proof for failure. Test cases may fail while executing the test suite in selenium automation.
