Does Webdriver 2.28 automatically take a screenshot on exception/fail/error?
If it does, where can I find the screenshot? Which directory is the default?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it doesn’t do it automatically. Two options you can try:
Use
WebDriverEventListenerthat is attachable to aEventFiringWebDriverwhich you can simply wrap around your usual driver. This will take a screenshot for everyExceptionthrown by the underlyingWebDriver, but not if you fail anassertTrue()check.If you’re using JUnit, use the
@RuleandTestRule. This will take a screenshot if the test fails for whatever reason.The
takeScreenshot()method being this in both cases:…where the
FileUtils.copyFile()method being the one in Apache Commons IO (which is also shipped with Selenium).