I don't think your call to #collect is doing what you expect.  For each text
field, puts is printing the details and returning nil.  textF is then an
array of nils with the same length as the number of text_fields.  

The documentation of the #collect command is available at: 
        http://www.ruby-doc.org/core/classes/Array.html#M002187

It looks to me like you want all of the text fields.  I think what you are
looking for is something like:

ie.text_fields.each {|tf|
        if tf.value != 'null'
                puts tf.name
        end
}

                                        /\/\ark

> -----Original Message-----
> From: watir-general@googlegroups.com [mailto:watir-
> gene...@googlegroups.com] On Behalf Of manar alalfi
> Sent: Tuesday, September 01, 2009 12:23 PM
> To: Watir General
> Subject: [wtr-general] Check value of anonymous text field
> 
> 
> Hello,
> 
> I want to print the name attribute of a text field in a page
> 
> #collect Text fields elaments
> textF =  ie.text_fields.collect {|tf | puts tf}
> 
> # iterate to check for none_null_ name text field
> for tf in textF do
>   if ie.text_field(:name, tf.name).value != 'null'
>            puts  tf.name.to_s
>   end
> 
> but the code gives an error:
> 3: undefined method `name' for nil:NilClass (NoMethodError)
> 
> any help?
> 
> Thanks
> 
> 
> > 
> 
> 
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4387 (20090901) __________
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.eset.com
> 
> 
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4388 (20090902) __________
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.eset.com
> 
 

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4388 (20090902) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to