Setting browser window size in Watir-webdriver

空扰寡人 提交于 2019-11-27 01:20:32

问题


How can you specify the size of the browser window opened when you call the following with watir-webdriver?

browser = Watir::Browser.new(:firefox)

回答1:


This works only for Firefox at the moment:

browser.window.resize_to(800, 600)

and you can move the browser, too:

browser.window.move_to(0, 0)



回答2:


I'm using ruby+watir-webdriver and this code works for both FF and IE browsers (I have not checked in others browsers)

screen_width = browser.execute_script("return screen.width;")
screen_height = browser.execute_script("return screen.height;")
browser.driver.manage.window.resize_to(screen_width,screen_height)
browser.driver.manage.window.move_to(0,0)



回答3:


I did something like this

browser = Watir::Browser.new :firefox, :profile => profile
browser.send_keys :f11


来源:https://stackoverflow.com/questions/6126311/setting-browser-window-size-in-watir-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!