硒網站對如何在http://www.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example
做(使用Firefox作爲瀏覽器)從Java類似於這樣的例子這裏有一個快速TL; DR版本。它沒有點擊進入堆棧溢出,而是應該截取該術語的谷歌搜索結果。無論如何,當你已經知道網站的URL時,通過Google去瀏覽可能是一個冗餘的步驟,我相信你可以修改這個例子,使它能夠滿足你的需求。
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Stack Overflow");
element.submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("Stack Overflow");
}
});
// Screenshot of search results (screen not whole page)
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\screenshot.png"));
截圖代碼爲謝爾蓋·Pozharov的在Take a screenshot with Selenium WebDriver答案 - 看到其他因素,如驅動程序的選擇。
來源
2016-09-30 12:43:05
Daz
請檢查此鏈接http://superuser.com/questions/55999/how-can-i-automatically-take-a-screenshot-of-a-website-at-a-specified-time – madankundu
PhantomJS也有自動化功能(http://phantomjs.org/page-automation.html),因爲您可以評估JavaScript代碼動態頁面不是不合格者。 –
您是否在談論瀏覽器自動化?如果是這樣的話http://www.seleniumhq.org/可能是你正在尋找的。另見http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver。但我認爲你需要編輯你的問題,以明確這將如何運作。 – Daz