Watir and text field inside iframe

荒凉一梦 提交于 2019-12-01 23:43:44
@browser.text_field(:id => "IDUserId").set "TEXT"
@browser.text_field(:name => "IDUserId").set "TEXT"
@browser.text_field(:class => "sws_text_input").set "TEXT"

Those will all work for a this text field as long as it is not contained in a frame, at which point you will need to identify it.

You only want to use Xpath as a last result, as it is fragile and complicated. I'm not even sure if CSS works as I've never tried it.

Please check out Željko's WATIR book or www.watir.com for basic locator methods.

Maybe watir has been updated since these answers were posted, but none of these frame methods worked for me. I was able to successfully use the iframe method, and interact with that just like any other object. Once the iframe object was selected, I could call on DOM elements after the iframe call successfully. Was only able to select the iframe object using its 'id' tag even though it had a 'name' attribute as well..

browser.text_field(:id => "handle").exists?
#=> false

browser.iframe(:id => "secureform").text_field(:id => "handle").exists?
#=> true

The working solution is:

browser.frame(:index => 1).text_field(:index => 0).set "admin"

Now I'm trying to understand why :)

Another working solution browser.frame(:id => "iFrameID").text_field(:id => /TextField/).set "data"

HTH

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