4

I am working on "selenium webdriver" with java. I can switch to iframe. I can read the Element which is inside iframe. But i want to take the screenshot of Element which is inside iframe. Am using the following code. Its not take screenshot inside iframe element. There is any 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);
Itai Bar-Haim
  • 1,686
  • 16
  • 40
Jai
  • 352
  • 2
  • 18
  • This [link](http://stackoverflow.com/q/10848900/2932244) might help – JRodDynamite Oct 26 '15 at 08:12
  • Thanks for your reply. Am using same code above. Its not capture iframe Element.. – Jai Oct 26 '15 at 09:51
  • 2
    You didn't include the code for assigning `ele`... did you switch to the frame and then assign `ele`? – JeffC Oct 26 '15 at 16:46
  • Thanks JeffC. I forgot to add the code. your question solved my issue. I switch frame to current iframe parent. Now its working fine. – Jai Oct 27 '15 at 04:56

0 Answers0