Skip to main content

You are here


Capture a section of the screen using Selenium Webdriver

Capturing a section of the screen involves:

1) Performing a screen capture as usual and saving the created image to disk.
2) Getting the saved image and cutting/ cropping out a section of it as required into another image file.


Taking Screen Shot using Selenium WebDriver

The following code takes a screen shot of the website First, the Firefox browser is opened, then the site is loaded. The screen shot is taken and stored in a folder on the C:logicandtricks. Ensure you edit the location for the screen shot file as you see fit on the line:

FileUtils.copyFile(screenshot, new File("c:\\logicandtricks\\screenshot.jpg"));

To run the program you need to have Selenium configured.

Have fun!

Premium Drupal Themes by Adaptivethemes