Watir: password field unfindable in Safari

1.3k views Asked by At

I'm brand new to Watir. I'm using SafariWatir on a fully updated MBP Snow Leopard.

So far I've successfully used

goto, link, text_field, and button

but when I try to access a text_field with

type="password" name="pass" id="pass"

(as seen in Web Inspector) with

browser.text_field(:id, "pass") or
browser.text_field(:name, "pass")

I get

Watir::Exception::UnknownObjectException: Unable to locate TextField
2

There are 2 answers

1
themirror On BEST ANSWER

There's a very simple answer:

In Watir and FireWatir, a password field is called

text_field

In SafariWatir, a password field is called

password

So, to access a input of type=password, I needed to use

browser.password(:id, "pass")

or

browser.password(:name, "pass")

This solved my problem.

0
wanly On

Notes: I'm using mac 10.8,ruby 1.9.3;

The working sample is: browser.password(:name,'password').set'yourpassword'

There is no space between set and the value.