简体   繁体   English

如何使用Ruby使用Watir最大化浏览器(IE)

[英]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.

相关问题 如何使用Ruby或WATIR检索IE浏览器实例的进程ID? - How to retrieve process ID for IE browser instance using Ruby or WATIR? 如何使用ruby watir单击浏览器“停止加载此页面”? - how to click on browser “stop loading this page” using ruby watir? 如何使用Ruby在GUI中封装Watir浏览器实例? - How to encapsulate Watir browser instance in a GUI using Ruby? 强制浏览器使用带有Watir和Webdriver的Ruby加载 - Force browser to load using Ruby with Watir and Webdriver Ruby,Watir Classic和IE:除非具有焦点,否则浏览器将停止 - Ruby, Watir Classic and IE: Browser stops unless it has focus 如何获得的文本值 <legend> 在ruby watir中使用xpath标记。(使用IE) - How to get Text value of <legend> tag using xpath in ruby watir.(using IE) 有没有人设法让Ruby 1.9.1上的IE使用Watir正常工作? - Has anyone managed to get Watir using IE on Ruby 1.9.1 working? 如何获取 Browser.text.include? 搜索变量? (使用 Watir 和 Ruby ) - How can I get Browser.text.include? to search for a variable? ( using Watir and Ruby ) 使用watir在Ruby中完成程序后,chrome浏览器会自动关闭 - chrome browser closes automatically after the program finishes in ruby using watir 如何在ruby中使用watir选择内联元素 - How to select an inline element using watir in ruby
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM