code: public String saveScreenshot(String filename, long timeout, boolean includeImage,
                                 List<String> hashes) {
      assertElementNotStale();
  
      Canvas canvas = buildCanvas();
      ScreenCaptureReply reply =
          exec.screenWatcher(canvas, timeout, includeImage, hashes);
  
      if (includeImage && reply.getPng() != null) {
        FileChannel stream;
  
        try {
          stream = new FileOutputStream(filename).getChannel();
          stream.write(ByteBuffer.wrap(reply.getPng()));
          stream.close();
        } catch (IOException e) {
          throw new WebDriverException("Failed to write file: " + e.getMessage(), e);
        }
      }
  
      return reply.getMd5();
    }
docs: Take a screenshot of the area this element covers. If the hash of the image matches any of the
  given hashes then no image is saved, otherwise it saves a copy of the image to the given
  filename.
  
  @param filename     the location to save the screenshot
  @param timeout      the number of milliseconds to wait before taking the screenshot
  @param includeImage whether to get the image data. Disable if you just need the MD5 hash
  @param hashes       known image hashes
  @return the MD5 hash of the screenshot