Arth
Arth

Reputation: 13110

Finding a textarea by content in Watir-Webdriver

I am having trouble asserting a textarea with certain content exists. Here is an example of what I am hoping to do:

require 'watir-webdriver'

b = Watir::Browser.new :ff

b.goto 'http://www.velnetsupport.co.uk/parrots/FormMail/example_form.html'

b.text_field(:name => 'realname').set 'Tom Jones'
puts b.text_field(:value => /om\ Jon/x).exists? # Expect true get true

b.text_field(:name => 'message').set 'John Jones'
puts b.text_field(:value => /ohn Jon/).exists? # Expect true get false

b.close

Should this work? Is there another way?

Thanks in advance

Upvotes: 1

Views: 3473

Answers (2)

Abe Heward
Abe Heward

Reputation: 515

You might consider doing this, instead:

b.text_field(:name => 'message').set 'John Jones'

# The next line assumes you're using Rspec...
b.text_field(:name => 'message').text.should=='John Jones'

# Alternatively, if you're using TestUnit...
assert_equal(b.text_field(:name => 'message').text, 'John Jones')

# Or, do your own verification:
puts "Exists!" if b.text_field(:name => 'message').text=='John Jones'

Upvotes: 0

alp2012
alp2012

Reputation: 281

One error you made above, replace text field with textarea

puts b.textarea(:value => /ohn Jon/).exists?

Upvotes: 2

Related Questions