O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – saving images to bytes

Imagine that you want to do some in-depth analysis of the UI by taking screenshots. This is something that has been done a number of times in different projects. For example, you take a screenshot, then make changes, and then take more screenshots along the way.

  1. Open up Intellij and create a new Java test class.
  2. We will now add a new line for taking a screenshot:
    driver.get(http://book.theautomatedtester.co.uk);
    Bytes screenbytes = ((Screenshot)driver).getScreenshotAs(bytes);
  3. If you set a breakpoint on the previous line, you will be able to see what the string looks like.

What just happened?

Now that we have seen what it takes to take a screenshot of the page from the browser, we have managed to take a screenshot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required