2

Does anyone know how to resize current browser window using Ruby? I have searched the internet and haven't found any solid solutions. I have the following below, but it is always ignored.

def resizeApplication
  @@driver.execute_script("window.resizeTo(500,500);")
end
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Jonathan Warykowski
  • 378
  • 1
  • 4
  • 14
  • if you are refering watir-webdriver then you might look at [this link][1] [1]: http://stackoverflow.com/questions/6126311/setting-browser-window-size-in-watir-webdriver – user825154 Mar 19 '12 at 23:06
  • How can I resize current window in Selenium WebDriver with Java? – Ripon Al Wasim May 20 '13 at 09:25

2 Answers2

11
@@driver.manage.window.resize_to(500, 500)

See Window class.

p0deje
  • 3,903
  • 1
  • 26
  • 37
2

Can be achieved alternatively using Chrome options,

  caps = Selenium::WebDriver::Remote::Capabilities.chrome(
      "chromeOptions" => { args: ["--window-size=414,736"]})
  @driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125