Testing already Open Browser with Watir-Webdriver [duplicate]

时间秒杀一切 提交于 2019-12-05 05:41:27

问题


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 ?

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?


回答1:


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

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'

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.



来源:https://stackoverflow.com/questions/23616804/testing-already-open-browser-with-watir-webdriver

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