2016-07-26 90 views
0

我想在运行硒脚本时捕获屏幕截图。但是我得到了错误。任何人都可以帮助我解决这个问题。selenium webdriver失败截图

java.lang.ArrayIndexOutOfBoundsException:123 org.openqa.selenium.internal.Base64Encoder.mapCharToInt(Base64Encoder.java:89) 在 org.openqa.selenium.internal.Base64Encoder.decode(Base64Encoder。的java:76) 在 org.openqa.selenium.OutputType $ 2.convertFromBase64Png(OutputType.java:57) 在 org.openqa.selenium.OutputType $ 2.convertFromBase64Png(OutputType.java:1) 在 org.openqa .selenium.OutputType $ 3.convertFromBase64Png(OutputType.java:75) at org.openqa.selenium.Output类型$ 3.convertFromBase64Png(OutputType.java:1) 在 org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:339)

正在使用下面的代码,

File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);  
      nextVal = seq.incrementAndGet(); 
      FileUtils.copyFile(scrFile, new File("./Screenshots/Sanity/" + nextVal + ".png")); 
+0

什么是您的webdriver jar的确切版本? –

+0

selenium-2.53.1.jar –

+0

你的代码没有问题。这可能是由驱动程序实现引起的。如果这不仅仅是一个临时运行时问题,你应该尝试另一个硒版本。 –

回答

0

更新我的硒webdriver jar和Chromedriver [2.23]到最新版本后问题得到修复。现在我们可以在运行时捕获屏幕截图,而不会有任何问题。