Save an image with Selenium WebDriver

Using Java it really easy to save an image (for any purpose).

In this code snnipet you'll do…

  1. Find the image element in a certain way (I'm using cssSelector)
  2. Get the src attribute
  3. Create a java URL
  4. Create a BufferedImage using ImageIO java class
  5. Use ImageIO to save the image with a preferred image extension and a location