[英]ScreenShot of entire webpage using selenium-webdriver/ rc rails
I am trying to take screenshot of an given link using selenium-webdriver. 我正在尝试使用selenium-webdriver截取给定链接的屏幕截图。 I am using the below script 我正在使用以下脚本
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'URL'
driver.save_screenshot('screenshot.png')
driver.quit
This is working fine but it only take screenshot of the visible area. 这可以正常工作,但只截取可见区域的屏幕截图。 I have also tried 我也尝试过
driver.capture_entire_page_screenshot('test.png','');
and 和
driver.capture_entire_page_screenshot('test.png');
but I am getting undefined method capture_entire_page_screenshot'
error any suggestions how can I achieve this. 但我收到未定义的方法capture_entire_page_screenshot'
错误,我如何实现此建议。 Update, also tried the below option which is working but only taking the screenshot of visible/ full screenshot. 更新,还尝试了下面的选项,该选项有效,但仅拍摄可见/完整屏幕截图。 With visible area I mean if my page has scroll its not taking the screenshot of the full page. 可见区域是指我的页面是否滚动显示,而不是整个页面的屏幕截图。
require 'rubygems'
require 'selenium'
require 'selenium-webdriver'
require 'selenium/client'
require 'selenium-rc'
@selenium = Selenium::Client::Driver.new("localhost", 4444,"*chrome", "someurl", 1000);
@selenium.start
@selenium.open ""
@selenium.wait_for_page_to_load "3000"
@selenium.send(:sleep, 4) # Wait for Flash and other crap to load
@selenium.capture_entire_page_screenshot('/path/to/save/screenshot.png', '');
@selenium.stop
and also is there a way to use proxy in this? 还有在此使用代理的方法吗?
This is a known issue for the Selenium contributors group and apparently is dependent upon a bug being fixed in Chrome (Chromium). 这是Selenium贡献者小组的一个已知问题,并且显然取决于Chrome(铬)中已修复的错误。 See this thread: 看到这个线程:
https://code.google.com/p/chromedriver/issues/detail?id=294 https://code.google.com/p/chromedriver/issues/detail?id=294
The thread has some hacks to work around the issue until (if?) Google fixes the aforementioned bug 该线程具有一些可解决该问题的技巧,直到(if?)Google修复了上述错误为止
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.