ruby - Selenium or Watir Webdriver, how to save resized screenshot? -
i try resized 400x400 screenshot of google. try both in selenium , watir no success.
require 'watir-webdriver' b = watir::browser.new b.goto 'google.com' b.window.resize_to(400,400) b.driver.save_screenshot("screenshot.jpg")
i screenshot original browser size.
any idea how can save resized 400x400?
at present, webdriver defines screenshot "full page screenshot". is, entire dom should represented image generated save_screenshot
method. fact chrome driver doesn't generate screenshot of full dom bug in chrome driver. real answer there no way generate screenshot of browser view port using webdriver.
having said that, might possible use other programmatic means accomplish this, depending on os. on windows, example, pretty easy desktop window's window handle (hwnd), capture image of desktop (using windows getdesktop
, printwindow
apis), , cropping using coordinates supplied webdriver window
api.
Comments
Post a Comment