code: @Override
      public void saveScreenshot(String screenName, WebElement element) throws IOException {
          logger.debug("saveScreenshot with the scenario named [{}] and element [{}]", screenName, element.getTagName());
  
          final byte[] screenshot = ((TakesScreenshot) Context.getDriver()).getScreenshotAs(OutputType.BYTES);
          FileUtils.forceMkdir(new File(System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER));
  
          InputStream in = new ByteArrayInputStream(screenshot);
          BufferedImage fullImg = ImageIO.read(in);
  
          // Get the location of element on the page
          Point point = element.getLocation();
  
          // Get width and height of the element
          int eleWidth = element.getSize().getWidth();
          int eleHeight = element.getSize().getHeight();
  
          // Crop the entire page screenshot to get only element screenshot
          BufferedImage eleScreenshot = fullImg.getSubimage(point.getX(), point.getY(), eleWidth, eleHeight);
          ImageIO.write(eleScreenshot, "jpg", new File(System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER + File.separator + screenName + ".jpg"));
      }
docs: {@inheritDoc}