Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9246525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:30:37+00:00 2026-06-18T09:30:37+00:00

Does Webdriver 2.28 automatically take a screenshot on exception/fail/error? If it does, where can

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:30:38+00:00Added an answer on June 18, 2026 at 9:30 am

    No, it doesn’t do it automatically. Two options you can try:

    1. Use WebDriverEventListener that is attachable to a EventFiringWebDriver which you can simply wrap around your usual driver. This will take a screenshot for every Exception thrown by the underlying WebDriver, but not if you fail an assertTrue() check.

      EventFiringWebDriver driver = new EventFiringWebDriver(new InternetExplorerDriver());
      WebDriverEventListener errorListener = new AbstractWebDriverEventListener() {
          @Override
          public void onException(Throwable throwable, WebDriver driver) {
              takeScreenshot("some name");
          }
      };
      driver.register(errorListener);
      
    2. If you’re using JUnit, use the @Rule and TestRule. This will take a screenshot if the test fails for whatever reason.

      @Rule
      public TestRule testWatcher = new TestWatcher() {
          @Override
          public void failed(Throwable t, Description test) {
              takeScreenshot("some name");
          }
      };
      

    The takeScreenshot() method being this in both cases:

    public void takeScreenshot(String screenshotName) {
        if (driver instanceof TakesScreenshot) {
            File tempFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
            try {
                FileUtils.copyFile(tempFile, new File("screenshots/" + screenshotName + ".png"));
            } catch (IOException e) {
                // TODO handle exception
            }
        }
    }
    

    …where the FileUtils.copyFile() method being the one in Apache Commons IO (which is also shipped with Selenium).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java webdriver driven selenium execution which does a loop over a
I'm using Selenium 2.20 . Why does WebDriver InternetExplorerDriver throw this warning when launching
I'm using Selenium WebDriver with Java. I want to use Safari browser. Does Selenium
Does anyone know a good resource that I can use in the browser that
I have looked for answer on other questions but I can't find one. My
def wait_for_element_present(element) wait = Selenium::WebDriver::Wait.new(:timeout => 30); wait.until{driver.find_element(element)}; end Please take a look at
Im trying the code below but it seems it does not work... Can someone
I'm testing a web application using Selenium WebDriver and I was wondering which is
NoSuchElement exception is not coming when webElement not found in a page in webdriver
I'm trying to use selenium webdriver to save a specific image to a directory.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.