Thanks to all for your help.  I've tried the three solutions suggested
in the previous two replies.  The last one found the text field value
FOO, the first two did not.  I put the following code in my script:

ie = Watir::IE.attach(:title, "FooBar Report")
if assert(ie.text_field(:id,'ctl140_ctl00_ctl09_txtValue').value ==
'FOO')
  puts "    FOO Found"
else
  puts "    FOO Not Found"
end
if assert(ie.text_field(:name,'ctl140$ctl00$ctl09$txtValue').value ==
'FOO')
  puts "    FOO Found"
else
  puts "    FOO Not Found"
end
if ie.text_field(:value,'FOO').exists?
  puts "    FOO Found"
else
  puts "    FOO Not Found"

This returns the following:

    FOO Not Found
    FOO Not Found
    FOO Found

Given the HTML from my latest post, it seems like all of these should
find FOO.  Maybe I'm using 'assert' incorrectly?  Newbie growing
pains!

endOn Jan 26, 11:08 am, Michael Hwee <[email protected]> wrote:
> Or, ie.text_field(:value, 'FOO').exists?
>
> Monkeybun, please make sure you asked the right question after your 
> investigation.
> So, we can help you solved your problems properly.
>
> Michael
>
>
>
> ----- Original Message ----
> From: dara <[email protected]>
> To: Watir General <[email protected]>
> Sent: Friday, January 23, 2009 3:13:11 PM
> Subject: [wtr-general] Re: ie.contains_text problem
>
> Using your example HTML, you can verify the contents of the text field
> with either of the following:
>
>     assert(ie.text_field(:id, 'ctl140_ctl00_ctl09_txtValue').value ==
> 'FOO')
> or
>     assert(ie.text_field(:name, 'ctl140$ctl00$ctl09$txtValue').value
> == 'FOO')
>
> You identify the text field by either the id or the name, and output
> the value attribute.
>
> Cheers,
>
> -Dara
>
> On Jan 23, 12:59 pm, Monkeybuns <[email protected]> wrote:
> > dara, you are correct.  'FOO' is an entry in a text field, not part of
> > the text of the page.  It does not appear in ie.text.
>
> > When I view the source with FOO in the text field, the following HTML
> > is the part of the source containing FOO:
>
> > </div></td><td class="InterParamPadding"></td><td
> > class="ParamLabelCell"><span>Adjuster</span></td><td
> > class="ParamEntryCell" style="padding-right:0px;"><div>
> > <input name="ctl140$ctl00$ctl09$txtValue" type="text" value="FOO"
> > size="30" id="ctl140_ctl00_ctl09_txtValue" /> <span style="white-
> > space:nowrap;"><input id="ctl140_ctl00_ctl09_cbNull" type="checkbox"
> > name="ctl140$ctl00$ctl09$cbNull" onclick="document.getElementById
> > ('ctl140_ctl00').ParametersController.UpdateParam1
> > ('ctl140_ctl00_ctl09_cbNull', 'ctl140_ctl00_ctl09_txtValue');" /><label 
> > for="ctl140_ctl00_ctl09_cbNull">NULL</label></span>
>
> > </div></td>
>
> > On Jan 23, 12:25 pm, dara <[email protected]> wrote:
>
> > > It sounds as though 'FOO' is in your HTML but not in the text of the
> > > page.
>
> > > 'FOO' appearing in ie.show_all_objects does not mean it will appear in
> > > ie.text.
>
> > > If 'FOO' does not appear in ie.text (try "puts ie.text"), then
> > > ie.contains_text('FOO') and ie.text.include?('FOO') are always going
> > > to return false.
>
> > > Including a HTML example in your post would help figure this out.
>
> > > On Jan 23, 10:53 am, Michael Hwee <[email protected]> wrote:
>
> > > > Or, just get ride of 'assert' and 'contains_text'.
>
> > > > Just use
>
> > > > if ie.text.include?("FOO")
> > > >   puts "FOO found"
> > > > else
> > > >   puts "FOO not found"
> > > > end
>
> > > > Michael
>
> > > > ----- Original Message ----
> > > > From: Bret Pettichord <[email protected]>
> > > > To: [email protected]
> > > > Sent: Friday, January 23, 2009 7:05:46 AM
> > > > Subject: [wtr-general] Re: ie.contains_text problem
>
> > > > I'm not sure if contains_text returns false or nil when fails to find a
> > > > match. Try this instead:
>
> > > > if assert(ie.contains_text("FOO"))
>
> > > > Monkeybuns wrote:
> > > > > The following code returns "FOO not found" even though
> > > > > "FOO" is present in the output of ie.show_all_objects:
>
> > > > >    ie = Watir::IE.attach(:title,"FooBar Report")
> > > > >    ie.show_all_objects
> > > > >    if assert(ie.contains_text("FOO") != nil)
> > > > >      puts "FOO found"
> > > > >    else
> > > > >      puts "FOO not found"
> > > > >    end
>
> > > > > Seems to me like this should work, though I'm very new
> > > > > to Watir.  I get the following result:
>
> > > > > C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:48:in `assert_block':
> > > > > <false> is not true. (Test::Unit::AssertionFailedError)
> > > > >     from C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:500:in
> > > > > `_wrap_assertion'
> > > > >     from C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:46:in
> > > > > `assert_block'
> > > > >     from C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:63:in `assert'
> > > > >     from C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:495:in
> > > > > `_wrap_assertion'
> > > > >     from C:/ruby/lib/ruby/1.8/test/unit/assertions.rb:61:in `assert'
>
> > > > > Any wisdom?- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to