셀레늄 웹 사이트는 여기에 빠른 TL의 http://www.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example
에서 자바에서이 비슷한 (브라우저로 파이어 폭스를 사용)를 수행하는 방법의 예를 가지고, DR 버전. 스택 오버플로로 클릭 연결되는 대신 해당 용어에 대한 Google 결과의 캡쳐 화면을 가져와야합니다. 어쨌든 사이트의 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"));
스크린 샷 코드가 Take a screenshot with Selenium WebDriver에서 Sergii Pozharov의 대답에서입니다 - 등 드라이버의 선택과 같은 다른 고려 사항이를 참조하십시오.
출처
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)과 자바 스크립트 코드를 평가할 수 있기 때문에 동적 페이지는 불법적 인 요소가 아닙니다. –
브라우저 자동화에 대해 이야기하고 있습니까? 그렇다면 http://www.seleniumhq.org/이 귀하가 원하는 것일 수 있습니다. http://stackoverflow.com/questions/3422262/take-a-screenshot-with-selenium-webdriver를 참조하십시오. 그러나 이것이 어떻게 작동하는지 명확하게하기 위해 질문을 편집해야한다고 생각합니다. – Daz