简体   繁体   中英

ScreenShot of entire webpage using selenium-webdriver/ rc rails

I am trying to take screenshot of an given link using 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. 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). See this thread:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM