简体   繁体   English

如何使用ruby在自动化中打开一个浏览器

[英]How to open one browser in automation using ruby

I just want to know how to open one browser when i am going to test a loop. 我只想知道在测试循环时如何打开一个浏览器。 or how to clear the last inputted values in the login page to change it in the new values. 或如何清除登录页面中最后输入的值以将其更改为新值。

Assuming you're using watir-webdriver, you can instantiate a browser like this: 假设您使用的是watir-webdriver,则可以实例化这样的浏览器:

require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'bit.ly/watir-webdriver-demo'

If you want to clear text entry fields, you can use the clear method: 如果要清除文本输入字段,可以使用clear方法:

require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_1000000').set 'your name'
b.text_field(:id => 'entry_1000000').clear

I pulled this info from http://watirwebdriver.com/ , so you may want to check that out. 我从http://watirwebdriver.com/提取了此信息,因此您可能需要检查一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM