2012-12-25 62 views
-1

我收到故障異常而採取的設備截圖如何在執行測試用例時保存android web驅動截圖?

我的代碼如下:

//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(); 
    } 

任何機構可以幫我這個問題?

回答

0

我試圖執行你的代碼,但沒有得到異常,雖然我沒有得到截圖。我有修改你的代碼有點看看這個工作適合你

driver.get("http://wikipedia.com"); 

File screenshot = new File("screenshot1.png"); 
File tmpScreenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); 
org.apache.commons.io.FileUtils.copyFile(tmpScreenshot, screenshot); 
System.out.println("the screenshot printed at:- " + screenshot.getAbsolutePath()); 
+0

謝謝它的工作 – user1928527

相關問題