I want to share code to capture the screen shot of all tag in selenium webdriver
get all
<img>
tag in listList<WebElement> image = driver.findElements(By.tagName("img")); int i=1;
Use this:
for(WebElement allImages : image){ //Download image File screen=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); int width=allImages.getSize().getWidth(); int height=allImages.getSize().getHeight(); BufferedImage img=ImageIO.read(screen); BufferedImage dest=img.getSubimage(allImages.getLocation().getX(), allImages.getLocation().getY(), width, height); ImageIO.write(dest, "png", screen); File file=new File("/Users/h-disk/Desktop/folder-name/abc"+i+".png");
Using this code you can capture all <img>
s