我正在尝试使用以下代码从网页捕获验证码图像
WebElement captchaEl = driver.findElement(By.id("captchaLogin"));
//System.out.println("Captcha: "+ source);
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
BufferedImage fullImg = ImageIO.read(screenshot);
Point point = captchaEl.getLocation();
int eleX = point.getX();
int eleY = point.getY();
int eleWidth = captchaEl.getSize().getWidth();
int eleHeight = captchaEl.getSize().getHeight();
BufferedImage eleScreenshot= fullImg.getSubimage(eleX, eleY, eleWidth, eleHeight);
ImageIO.write(eleScreenshot, "png", screenshot);
FileUtils.copyFile(screenshot, new File(outputFileName));
它最终捕获页面中的其他部分,而不是验证码图像。虽然如果使用phantomjs驱动程序它可以工作,但是如果使用chromedriver或geckodriver(firefoxdriver)则不起作用。这可能是什么问题?