2

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
Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
themirror
  • 9,963
  • 7
  • 46
  • 79

2 Answers2

4

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.

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
themirror
  • 9,963
  • 7
  • 46
  • 79
  • 2
    I have noticed that myself. Just to make it clear for others, to populate password in safariwatir: `browser.password(:id, "id").set "password"` – Željko Filipin Jul 15 '11 at 08:37
1

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.

wattostudios
  • 8,666
  • 13
  • 43
  • 57
wanly
  • 11
  • 1