Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Resize browser windows with Selenium WebDriver in Ruby
driver = WebDriver.for(:remote, :url => Helper.grid, :desired_capabilities => caps)
width = 1024
height = 768
# Resize window. In Firefox and Chrome, must create a new window to do this.
case driver.capabilities[:browser_name]
when 'firefox', 'chrome'
handles = driver.window_handles
driver.switch_to.window((driver.window_handles - handles).pop)
driver.execute_script("window.resizeTo(#{width}, #{height}); window.moveTo(0,1);")
driver.execute_script("window.resizeTo(#{width}, #{height}); window.moveTo(0,1);")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.