title: JAVA Selenium Webdriver Capturing wrong region in the screenshot
body: <p>I am using selenium Web Driver(Java) to automate our web application.
  I need to capture and compare the each icon of the application in all browsers. </p>
  
  <p>For that first I've opened the application in Firefox and captured icons images with its xpath and then saving them at a particular path.
  Later comparing the saved images when the application opened in another browser. </p>
  
  <p>For this I have used the below code to capture the images, but the element image is not capturing, some unknown region in the screen is saving.</p>
  
  <p>Please help, how to get the correct image of the element. </p>
  
  <pre><code>File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
  BufferedImage  fullImg = ImageIO.read(screenshot);
  Point point = x.getLocation();
  //Get width and height of the element
  int eleWidth = x.getSize().getWidth();
  int eleHeight = x.getSize().getHeight();
  Rectangle rect = new Rectangle(point.getX(),point.getY(),eleWidth, eleHeight);
  //Crop the entire page screenshot to get only element screenshot
  BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(), rect.width, rect.height);
  ImageIO.write(eleScreenshot, "png", screenshot);
  //Copy the element screenshot to disk
  FileUtils.copyFile(screenshot, new File("E:\\ICONS\\Icon1.jpg"));
  </code></pre>