如何在执行测试用例时保存android web驱动程序截图?
我在拍摄设备屏幕截图时遇到故障异常 我的代码如下:如何在执行测试用例时保存android web驱动程序截图?,android,selenium,webdriver,android-webview,Android,Selenium,Webdriver,Android Webview,我在拍摄设备屏幕截图时遇到故障异常 我的代码如下: //open the page driver.get("http://wikipedia.com"); //take another screenshot try { File screenshot = new File("screenshot1.png"); File tmpScreenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputTyp
//open the page
driver.get("http://wikipedia.com");
//take another screenshot
try {
File screenshot = new File("screenshot1.png");
File tmpScreenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
}
catch(IOException e){
System.out.println("Failed to take screenshot."+e.getMessage());
}
//quit
driver.quit();
}
有人能帮我解决这个问题吗?我试图执行你的代码,但没有得到异常,尽管我也没有得到屏幕截图。我对你的代码做了一些修改,看看这是否适合你
driver.get(“http://wikipedia.com");
文件截图=新文件(“screenshot1.png”);
文件tmpScreenshot=((TakesScreenshot)driver.getScreenshotAs(OutputType.File);
org.apache.commons.io.FileUtils.copyFile(tmpScreenshot,屏幕截图);
System.out.println(“在:-“+screenshot.getAbsolutePath()打印的屏幕截图”);