How to find a text box in Watir

I am trying to access the site using watir-webdriver, but I cannot find the text box in watir that I can see in Firefox + Firebug.

My code

require 'rubygems'
require 'irb/completion'
require 'watir-webdriver'
browser = Watir::Browser.new(:firefox)
browser.goto('http://emersonecologics.com/')
browser.text_field(:name, "txtEmail").set("myemail@gmail.com")

I get an error message:

Watir::Exception::UnknownObjectException: unable to locate element, using {:type=>"(any text type)", :name=>"txtEmail", :tag_name=>"input or textarea"}

However, I know that there is a text box called txtEmail because Firebug shows me

<input id="txtEmail" class="textbox" type="text" tabindex="1" name="txtEmail">

Of course, this text box is deep inside the tree. Therefore, thinking that I should go to it in the DOM, I tried to access the div called "everything".

If i do

>>browser.divs[1].id
=> "all"
>> browser.divs[1].tag_name
=> "div"

But when I try to get a handle to it as the next, it seems I can’t find it.

>>browser.div(:id, "all")
=> #<Watir::Div:0x101a8fd70 located=false selector={:tag_name=>"div", :id=>"all"}>

Can someone help me select the objects on the page?

+3
source share
2 answers

It looks like I'm framed as well

( , 0, 1), . , .

browser.frame(:id, "ctrlLoginSSL_ifLogin").text_field(:id, "txtEmail").flash

Watir Wiki

P.S.

( ). , , , (https), ( http) Chrome

JavaScript URL- https://www.emersonecologics.com/User/LoginFrame.aspx?redir=/default.aspx URL- http://emersonecologics.com/. , .

+3

, , , . :

browser.frame(: index, 1).text_field (: name, "txtEmail" ). set ( "myemail@gmail.com" )

: http://wiki.openqa.org/display/WTR/Frames

+3

All Articles