[wtr-general] Checking for contents of a text field

2010-04-07 Thread Rats
I'm trying to check if a field is populated on a page. This command
works fine and returns found it:

if ie.text_field(:value,'some value').exists?
  puts 'found it
else
  puts did not find it
end

However this one doesn't:

if ie.text_field(:id,mytextfield).value == 'some value'
  puts 'found it
else
  puts did not find it
end

If I understand correctly the first example is looking for ALL text
fields on the page to see if any of them have some value. The second
is more specific and is looking at a particular text field.

I know for certain that mytxtfield contains the text I am looking
for ...

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com

To unsubscribe, reply using remove me as the subject.


Re: [wtr-general] Checking for contents of a text field

2010-04-07 Thread Wesley Chen
ie.text_field(:id,mytextfield).value will get the value in the text field.
You can't get the text_field attribute value by it.



Wesley.
For life, the easier, the better.


On Thu, Apr 8, 2010 at 9:27 AM, Rats crapats...@yahoo.com.au wrote:

 I'm trying to check if a field is populated on a page. This command
 works fine and returns found it:

 if ie.text_field(:value,'some value').exists?
  puts 'found it
 else
  puts did not find it
 end

 However this one doesn't:

 if ie.text_field(:id,mytextfield).value == 'some value'
  puts 'found it
 else
  puts did not find it
 end

 If I understand correctly the first example is looking for ALL text
 fields on the page to see if any of them have some value. The second
 is more specific and is looking at a particular text field.

 I know for certain that mytxtfield contains the text I am looking
 for ...

 --
 Before posting, please read http://watir.com/support. In short: search
 before you ask, be nice.

 You received this message because you are subscribed to
 http://groups.google.com/group/watir-general
 To post: watir-general@googlegroups.com

 To unsubscribe, reply using remove me as the subject.


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com


Re: [wtr-general] Checking for contents of a text field

2010-04-07 Thread Wesley Chen
You'd better not use :value to locate on text field.
Because the value in text field can change manual.

Wesley.
For life, the easier, the better.


On Thu, Apr 8, 2010 at 9:47 AM, Wesley Chen cjq@gmail.com wrote:

 ie.text_field(:id,mytextfield).value will get the value in the text
 field.
 You can't get the text_field attribute value by it.



 Wesley.
 For life, the easier, the better.



 On Thu, Apr 8, 2010 at 9:27 AM, Rats crapats...@yahoo.com.au wrote:

 I'm trying to check if a field is populated on a page. This command
 works fine and returns found it:

 if ie.text_field(:value,'some value').exists?
  puts 'found it
 else
  puts did not find it
 end

 However this one doesn't:

 if ie.text_field(:id,mytextfield).value == 'some value'
  puts 'found it
 else
  puts did not find it
 end

 If I understand correctly the first example is looking for ALL text
 fields on the page to see if any of them have some value. The second
 is more specific and is looking at a particular text field.

 I know for certain that mytxtfield contains the text I am looking
 for ...

 --
 Before posting, please read http://watir.com/support. In short: search
 before you ask, be nice.

 You received this message because you are subscribed to
 http://groups.google.com/group/watir-general
 To post: watir-general@googlegroups.com

 To unsubscribe, reply using remove me as the subject.




-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com