How to locate an INPUT element embedeed in a table

64 views
Skip to first unread message

Natasha

unread,
Oct 7, 2008, 12:27:32 PM10/7/08
to Watir General
Hello All,

I am trying to automate Fotolog's login page. Please could you help
me.

Following is the snippet of HTML code:
-------------------------------------------------------------------------------

<table>
<tr>
<td class="label">Username:</td>
<td><input type="text" name="u_name" maxlength="16" value=""></td>
</tr>
<tr>
<td class="label">Password:</td>
<td><input type="password" name="p_word"></td>
</tr>
<tr>
<td></td>
<td class="submitIt"><button type="submit"
class="btSubmit0">Login</button></td>
</tr>
<tr>
<td colspan="2"><a href="http://account.fotolog.com/
forgot_password">Forgot your password?</a></td>
</tr>
</table>
---------------------------------------------------------------------------------------------

I need to automate the typing in user name and password, followed by
clicking on login button.

I have tried following sets of codes, but it didn't work.

1. Accessing text type fields using aftertext attribute

$ie.text_field(:aftertext,/Username:/).set("user1")
$ie.text_field(:aftertext,/Password:/).set("pwd1")
$ie.button(:text,"Login").click

2. Accessing text fields using name attribute

$ie.text_field(:name,"u_name").set("user1")
$ie.text_field(:name,"p_word").set("pwd1")
$ie.button(:text,"Login").click

Am getting following error:
============================================================
WIN32OLERuntimeError: focus
OLE error code:800A083E in htmlfile
Can't move focus to the control because it is invisible, not
enabled, or o
f a type that does not accept the focus.
HRESULT error code:0x80020009
Exception occurred.
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/
input_elements.rb:334:in
`method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/
input_elements.rb:334:in
`set'
C:/natasha/RubyScripts/FinalAutomatedTests/minicard_fotolog.rb:
54:in `test_a
_orderPlacement'
============================================================


Thanks and regards,
Natasha

Tiffany Fodor

unread,
Oct 7, 2008, 1:02:07 PM10/7/08
to Watir General
Hi Natasha!

I've run into the same problem with password confirmation fields when
adding a user in an application. If the field will not accept focus
from Watir, you may need to see if you can get your developer to
change the properties on it. I tried everything I could think of and
even solicited help from several experts on the list with whom I could
share my private URL. In my case, there was no way around the
protection on the field.

Off the top of my head, the things I tried were:

- using each property available to identify the field
- using the field index to identify it
- using send keys to tab to the field from a known location and type
in it

If none of these work for you, I suggest you work with your developer
to get it changed.

Sorry I couldn't be more help.....

-Tiffany

Tiffany Fodor

unread,
Oct 7, 2008, 1:07:01 PM10/7/08
to Watir General
Sorry, I should have included this in my original response....

I don't think your problem is related to your object being embedded in
a table, I think there's a protection on it that doesn't allow
automated tools to access it. You can verify this by just performing
a .exists? on your object to make sure that Watir can see that it's
there.

Also, if you're not using it already, command-line IRB is a great way
to troubleshoot working with objects.

-Tiffany

Natasha Ranney

unread,
Oct 7, 2008, 1:12:36 PM10/7/08
to watir-...@googlegroups.com
Thanks Tiffany. I will try that out. Just that this is not our code. This belongs to Fotolog. But anyways, will surely try out the options suggested and revert with my observations.

Regards,
Natasha

Tiffany Fodor <tcf...@comcast.net> wrote:

Sorry, I should have included this in my original response....

I don't think your problem is related to your object being embedded in
a table, I think there's a protection on it that doesn't allow
automated tools to access it. You can verify this by just performing
a .exists? on your object to make sure that Watir can see that it's
there.

Also, if you're not using it already, command-line IRB is a great way
to troubleshoot working with objects.

-Tiffany


On Oct 7, 11:02 am, Tiffany Fodor wrote:
> Hi Natasha!
>
> I've run into the same problem with password confirmation fields when
> adding a user in an application.  If the field will not accept focus
> from Watir, you may need to see if you can get your developer to
> change the properties on it.  I tried everything I could think of and
> even solicited help from several experts on the list with whom I could
> share my private URL.  In my case, there was no way around the
> protection on the field.
>
> Off the top of my head, the things I tried were:
>
> - using each property available to identify the field
> - using the field index to identify it
> - using send keys to tab to the field from a known location and type
> in it
>
> If none of these work for you, I suggest you work with your developer
> to get it changed.
>
> Sorry I couldn't be more help.....
>
> -Tiffany
>
> On Oct 7, 10:27 am, Natasha wrote:
>
> > Hello All,
>
> > I am trying to automate Fotolog's login page. Please could you help
> > me.
>
> > Following is the snippet of HTML code:
> > -------------------------------------------------------------------------------
>
> >                        

> >                                
> >                                
> >                                
> >                                

> >                        
Username:
> >                                

> >                        

> >                        
Password:
> >                                

> >                        

> >                        


> >                                

> >                        

> >                        
Forgot your password?
> >                        

> >                        

Tiffany Fodor

unread,
Oct 7, 2008, 1:26:17 PM10/7/08
to Watir General
Hi again!

I didn't realize your site was public, so I gave it a shot myself.
The username and password on the http://www.fotolog.com homepage work
fine, but I'm having the same problem with the password field on the
http://account.fotolog.com/login page.

If you find a way around this, I'd be really excited to learn how you
did it - this problem drove me nuts!

-Tiffany

On Oct 7, 11:12 am, Natasha Ranney <itsn...@yahoo.co.uk> wrote:
> Thanks Tiffany. I will try that out. Just that this is not our code. This belongs to Fotolog. But anyways, will surely try out the options suggested and revert with my observations.
>
> Regards,
> Natasha
>
> > >                                  [input]
>
> > >                                 Password:
> > >                                  [input]

Ravi

unread,
Oct 7, 2008, 4:13:23 PM10/7/08
to Watir General
I found the following working!

$ie.div(:id,'maincontent').text_field(:name,'u_name').set '1234'

$ie.div(:id,'maincontent').text_field(:name,'p_word').set '1234'


On Oct 7, 12:26 pm, Tiffany Fodor <tcfo...@comcast.net> wrote:
> Hi again!
>
> I didn't realize your site was public, so I gave it a shot myself.
> The username and password on thehttp://www.fotolog.comhomepage work

Tiffany Fodor

unread,
Oct 7, 2008, 5:19:42 PM10/7/08
to Watir General
Yay! Nice work Ravi!

Cynthia Zhang

unread,
Oct 7, 2008, 6:07:46 PM10/7/08
to watir-...@googlegroups.com
This shall work as well:

ie.form(:id,'login_form').text_field(:name, 'u_name').set'user'
ie.form(:id,'login_form').text_field(:name, 'p_word').set'password'
ie.form(:id,'login_form').button(:class,'btSubmit').click
#####################################################################################
This correspondence is for the named person's use only. It may contain confidential or legally privileged information, or both. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this correspondence in error, please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of Veda Advantage. If you need assistance, please contact Veda Advantage on either :- Australia 133124 or New Zealand +64 9 367 6200

Natasha Ranney

unread,
Oct 8, 2008, 5:01:17 AM10/8/08
to watir-...@googlegroups.com
Thanks Ravi & Cynthia. It worked :)

Regards,
Natasha

Cynthia Zhang <Cynthi...@VedaAdvantage.com> wrote:

This shall work as well:

ie.form(:id,'login_form').text_field(:name, 'u_name').set'user'
ie.form(:id,'login_form').text_field(:name, 'p_word').set'password'
ie.form(:id,'login_form').button(:class,'btSubmit').click


-----Original Message-----
From: watir-...@googlegroups.com [mailto:watir-...@googlegroups.com] On Behalf Of Tiffany Fodor
Sent: Wednesday, 8 October 2008 8:20 a.m.
To: Watir General
Subject: [wtr-general] Re: How to locate an INPUT element embedeed in a table


Yay! Nice work Ravi!


On Oct 7, 2:13 pm, Ravi wrote:
> I found the following working!
>
> $ie.div(:id,'maincontent').text_field(:name,'u_name').set '1234'
>
> $ie.div(:id,'maincontent').text_field(:name,'p_word').set '1234'
>
> On Oct 7, 12:26 pm, Tiffany Fodor wrote:
>
> > Hi again!
>
> > I didn't realize your site was public, so I gave it a shot myself.
> > The username and password on thehttp://www.fotolog.comhomepagework
> > fine, but I'm having the same problem with the password field on thehttp://account.fotolog.com/loginpage.
>
> > If you find a way around this, I'd be really excited to learn how
> > you did it - this problem drove me nuts!
>
> > -Tiffany
>
> > On Oct 7, 11:12 am, Natasha Ranney wrote:
>
> > > Thanks Tiffany. I will try that out. Just that this is not our code. This belongs to Fotolog. But anyways, will surely try out the options suggested and revert with my observations.
>
> > > Regards,
> > > Natasha
>
Reply all
Reply to author
Forward
0 new messages