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?
source
share