Automation Question:

Explain me how can we capture screenshots in Selenium?

Tweet Share WhatsApp

Answer:

We can take the screenshots in selenium by using getScreenshotAs method of TakesScreenshot interface:

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:screenshot1.jpg"));

Read All 108 Automation Questions
Previous QuestionNext Question
Please explain what is the difference between findElement () and findElements ()?Tell me how would you test your own element locator?