Interview Questions

Selenium WebDriver - There is a scenario whenever “Assert.assertEquals()” function fails automatically it has to take screenshot. How can you achieve this ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - There is a scenario whenever “Assert.assertEquals()” function fails automatically it has to take screenshot. How can you achieve this ?

By using EventFiringWebDriver.
Syntax-EventFiringWebDriver eDriver=new EventFiringWebDriver(driver); File srcFile = eDriver.getScreenshotAs(OutputType.FILE); FileUtils.copyFile(srcFile, new File(imgPath));

Syntax-EventFiringWebDriver eDriver=new EventFiringWebDriver(driver);
File srcFile = eDriver.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(imgPath));

(Continued on next question...)

Other Interview Questions