2014-03-05 87 views
-1

我無法使用硒webdriver拍攝整個頁面的屏幕截圖。我正在使用Internet Explorer。 我使用鼠標滾動按鈕嘗試了java的機器人功能,但失敗了。如何使用硒webdrivers在Internet Explorer中拍攝全屏幕截圖

+1

你好,歡迎來到[StackOverflow](http://stackoverflow.com)。請花一些時間閱讀 [幫助頁面](http://stackoverflow.com/help),尤其是名爲[「我可以問什麼問題?」](http://stackoverflow.com/help /主題)和[「我應該避免問什麼類型的問題?」](http://stackoverflow.com/help/dont-ask)。更重要的是,請閱讀[Stack Overflow問題清單](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist)。您可能還想了解[SSCCE](http://www.sscce.org/)是什麼。 – hivert

回答

0

請嘗試以下方法讓我知道它是否適合你

WebDriver driver = new FirefoxDriver(); 
driver.get("http://www.somewebsite.com/"); 
File imgFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); 
FileUtils.copyFile(imgFile , new File("c:\\tmp\\test.png")); 

如果我誤解你闕請讓我知道

0

如果以上答案失敗,你可以給一個嘗試用製作的Augemented webdriver的,它可以與IEDriver上使用的最新版本,請嘗試以下代碼

WebDriver augmentedDriver = new Augmenter().augment(driver); 
File screenFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE); 
FileUtils.copyFile(screenFile.getAbsolutePath(), new File("c:\\tmp\\test.png")); 

您也可以截圖以字節爲單位的形式,通過切換OutputType根據需要

.getScreenshotAs(OutputType.BYTES) 
相關問題