Take a screen shot with iframe using selenium

I am working on "selenium webdriver" with java. I can switch to iframe. I can read the element that is inside the iframe. But I want to take a screenshot of the Element that is inside the iframe. I am using the following code. Its not to take a snapshot inside the iframe element. There is some solution for this.

File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
BufferedImage  fullImg = ImageIO.read(screenshot);
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
int eleHeight = ele.getSize().getHeight();
BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(), eleWidth,eleHeight);
ImageIO.write(eleScreenshot, imageType, screenshot);
+4
source share

Source: https://habr.com/ru/post/1613164/


All Articles