Save image in webdriver by java

import java.awt.image.BufferedImage;
import java.io.File;
import java.net.URL;

 

WebElement imageEl = driver.findElement(By.xpath(“//img[@alt=’image’]”));
String imageElURL= imageEl .getAttribute(“src”);

URL imageURL = new URL(imageElURL);
BufferedImage saveImage = ImageIO.read(imageURL);

ImageIO.write(saveImage, “png”, new File(“D:” + File.separator + “image.png”));

Leave a Reply

Your email address will not be published. Required fields are marked *