使用Watir-Webdriver测试已经打开浏览器 [英] Testing already Open Browser with Watir-Webdriver

查看:268
本文介绍了使用Watir-Webdriver测试已经打开浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想通过@browser = Watir :: Browser.new(:ie)打开一个新的浏览器,但我想使用Watir-Webdriver手动打开浏览器。
我该怎么办?

I do not want to open a new browser by @browser = Watir::Browser.new (:ie) but i want to work with manually opened browser using Watir-Webdriver. How would I do that ?

我认为这可能是这样的
浏览器(:title =>浏览器标题)text_field(:id =>'Field Id') .set'abc'

I thought it may be something like this browser(:title => "Browser Title").text_field( :id => 'Field Id').set 'abc'

看起来我需要创建一个浏览器类的对象来工作。
请指导我?

it seems like I need to create an Object of browser class to work it .. Please guide me?

推荐答案

Selenium-webdriver没有附加到现有浏览器的功能。已请求此功能,但已关闭为不可行(请参阅第18期)。

Selenium-webdriver does not have functionality for attaching to existing browsers. This feature was requested, but closed as not feasible (see Issue 18).

如果您只使用IE,您可以考虑使用Watir-Classic,它具有附加到现有浏览器的功能:

If you are only using IE, you could consider using Watir-Classic, which has functionality for attaching to existing browsers:

browser = Watir::Browser.attach(:title,  "Browser Title")
browser.text_field( :id => 'Field Id').set 'abc'

这个API的主要部分与Watir-和Watir-Classic。有一些小的差异取决于你在做什么。注意,如果你的代码是 require'watir',你可能已经使用Watir-Classic。

The main part of the API is the same between Watir-Webdriver and Watir-Classic. There are some small differences depending on what you are doing. Note that if your code is doing require 'watir', you might already be using Watir-Classic.

这篇关于使用Watir-Webdriver测试已经打开浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆