[英]How to maximize browser (IE) with Watir using Ruby
I am new in Watir
as well as Ruby. 我是Watir
和Ruby的新手。 I have written an automated test for google search using Watir
and executed it successfully (my file name is "googlesearch.rb"
). 我已经使用Watir
为Google搜索编写了自动化测试,并成功执行了该测试(我的文件名为"googlesearch.rb"
)。 But the browser ( IE
) was opened as small window. 但是浏览器( IE
)是作为小窗口打开的。 How to maximize the browser using Watir? 如何使用Watir最大化浏览器?
My watir test script is as below: 我的watir测试脚本如下:
require 'watir'
browser = Watir::Browser.new
browser.goto("www.google.com")
browser.text_field(:id, "gbqfq").set("Ripon Al Wasim")
browser.button(:name, "btnG").click
browser.link(:text, "User Ripon Al Wasim - Stack Overflow").click
I executed the test script by using the command: ruby googlesearch.rb
我使用以下命令执行了测试脚本: ruby googlesearch.rb
For watir-webdriver : You just need to use the method #maximize
. 对于watir-webdriver :您只需要使用#maximize
方法。
require 'watir'
require 'watir-webdriver'
browser = Watir::Browser.new
browser.goto("www.google.com")
browser.window.maximize
# ... rest code here goes
Or, if you are using only watir gem to work with IE
browser only on Windows . 或者,如果仅使用watir gem与Windows上的IE
浏览器一起使用 。 Then you could write it as using maximize
. 然后,您可以将其编写为使用maximize
。
require 'watir'
browser = Watir::Browser.new
browser.goto("www.google.com")
browser.maximize
# ... rest code here goes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.