watir example fails

184 views
Skip to first unread message

c w

unread,
Jan 6, 2017, 11:39:47 AM1/6/17
to watir-...@googlegroups.com
Hi,

I am a bit frustrated as this used to be working few years ago. I try again as I intend to try to use back watir and I have no idea why starting with the second element scripts are failing on the watir example


Just run this:

require 'rubygems'
require 'watir'


driver = Selenium::WebDriver.for :chrome
@browser = Watir::Browser.new driver

@browser.text_field(:name => "entry.1000000").set 'Watir'
sleep 3
@browser.text_field(:name => "entry.1000001").set 'Watir'


I get the following:

c:\watir>ruby watir.rb
This code has slept for the duration of the default timeout waiting for an Eleme
nt to exist. If the test is still passing, consider using Element#exists? instea
d of rescuing UnknownObjectException
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elements/element.rb
:507:in `rescue in wait_for_exists': timed out after 30 seconds, waiting for {:n
ame=>"entry.1000001", :tag_name=>"input"} to be located (Watir::Exception::Unkno
wnObjectException)
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elemen
ts/element.rb:497:in `wait_for_exists'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elemen
ts/element.rb:515:in `wait_for_present'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elemen
ts/element.rb:533:in `wait_for_enabled'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elemen
ts/element.rb:545:in `wait_for_writable'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/elemen
ts/element.rb:656:in `element_call'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.1.0/lib/watir/user_e
ditable.rb:11:in `set'
        from watir.rb:18:in `<main>'




I just installed the latest version of ruby Ruby23-x64

It fails if I remove the sleep as well.

From the example only the first text field works.

Please advise.


Kind regards,
Cristina

Titus Fortner

unread,
Jan 6, 2017, 12:40:25 PM1/6/17
to watir-general
"entry.1000001" is a textarea element not a text_field element.
You used to be able to use text_field for both, now you have to specify the type you want. This code will do exactly what you want:

require 'watir'
browser = Watir::Browser.new
browser.goto 'bit.ly/watir-example'
browser.text_field(name: "entry.1000000").set 'Watir'
browser.textarea(name: "entry.1000001").set 'Watir'


--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
 
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscribe@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages