[Wtr-general] Question from a newbie

Cain, Mark Mark_Cain at RL.gov
Wed Oct 18 15:46:18 EDT 2006


You can use index (it is 1 based) to access the correct text_filed.
Obviously the first one would be (:index, 1), the second (:index, 2) and
so on.  You can look at the Watir API Reference (installed with Watir)
to get the options available.  You can also look at the unittests for
some very good examples on just about everything you would need.

--Mark


-----Original Message-----
From: wtr-general-bounces at rubyforge.org
[mailto:wtr-general-bounces at rubyforge.org] On Behalf Of Justin Nowell
Sent: Wednesday, October 18, 2006 12:30 PM
To: wtr-general at rubyforge.org
Subject: [Wtr-general] Question from a newbie

Hey,

I just downloaded Watir to help automate some tests. I've found it
pretty 
intuitive and easy to learn but I'm having trouble getting it to fill
out a 
text field on a form. The problem is that there are two text fields with
the 
same id and same name (all other attributes are equal as well). My
script 
contained the following line of code:

ie.text_field(:name, "username").set("newuser")

When I did this, it would fill in the first text field with the value 
'newuser', but what I need is to have the second one filled in. I
browsed 
through your FAQ, and saw your stated workaround for this, so I switched
the 
line of code to:

ie.text_field(:name => "username",:index => 2).set("newuser")

When I run this script, I get the following run-time error: "Unable to 
locate object, using nameusernameindex2 and 
(Watir::Exception::UnknownObjectException)".

Is there something obvious I'm missing?

If it helps, this is the tag from the HTML source for both text fields:


<input name="username" id="username" type="text" size="20"
maxlength="24" 
value="">

Any help would be greatly appreciated. Thanks.

-Justin




_______________________________________________
Wtr-general mailing list
Wtr-general at rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


More information about the Wtr-general mailing list