I'm having a really strange issue with watir-webdriver.
Here's a snapshot of the input tag I'm trying to reach (couldn't figure out a way to get the source after the javascripts created the popup, lol)
Anyway here's some of my code that uses xpath to locate these elements (there is two text fields and a select tag)
firstname = b.element(:xpath, "//div[@class='ap_popover']/input[@name='firstName']")
lastname = b.element(:xpath, "//div[@class='ap_popover']/input[@name='lastName']")
authorselector = b.element(:xpath, "//div[@class='ap_popover']/select")
puts firstname
puts lastname
puts authorselector
This code successfully returns the watir element objects. However when I try to cast them:
puts firstname.to_subtype
it freaks out:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:262:in `assert_exists': unable to locate element, using {:xpath=>"//div[@class='ap_popover']/input[@name='lastName']"} (Watir::Exception::UnknownObjectException)
So, what's going on? It can find them via xpath no problem but then when I try to cast them all of a sudden xpath search fails?
It's worth mentioning the html I'm perusing through is created in it's entirety by javascript, hence why I couldn't just copy\paste it here and had to take a screenshot.
Thanks!
b.textfield(:name => 'firstName')
. I've been having someunable to located element
problems recently with watirwebdriver... – Kassym Dorselb.text_fields(:name => 'firstName')
should return both of them and you can select the second one. – Kassym Dorsel