[Wtr-general] Seemingly bogus error in simple script

Charley Baker charley.baker at gmail.com
Wed Mar 7 14:05:06 EST 2007


I can only assume there are some timing issues. I'd recommend using a more
recent version of Watir which you can pull from the home page on openqa:
http://www.openqa.org/watir or build your own from the repository which is
on the FAQ page under Installing a Gem from the latest development source.

  If you use the latest version of Watir, you should be able to wait for
controls on the page to exist.

require 'watir'
include Watir

ie = IE.start('http://blah)
wait_until{ie.text_field(:name, 'j_username').exists?}
ie.text_field(:name, "j_username").set("blah")
ie.text_field(:name, "j_password").set("blah")
ie.button(:value, "Submit").click

Without any insight into your actual problem, code snippets or the like,
this is my best guess.

-Charley


On 3/7/07, Steven List <forum-watir-users at openqa.org> wrote:
>
> I'm brand new at this.
>
> I've created a very simple script to test a login page...
>
> require 'watir'
>
> ie = Watir::IE.start("http://mysite")
>
> ie.text_field(:name, "j_username").set("blah")
> ie.text_field(:name, "j_password").set("blah")
> ie.button(:value, "Submit").click
>
> If I execute these commands manually in irb, I have no problem.
>
> If I execute the script that contains them from the command line, I get
> this error:
>
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1928:in
> `assert_exists': Unable to locate object, using name and j_username
> (Watir::Exception::UnknownObjectException)
>         from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:3382:in
> `set'
>         from Z:/Customers/Beneplace/Beneplace Redesign/WATIR tests/admin-
> login.rb:5
>
> Even though I get the error, the actions occur - the text is entered into
> the text boxes, the button is clicked, and I see the next page.
>
> If I put additional commands AFTER the click, they do not get executed.
>
> This is being used with a JSP page, if that makes any difference, and IE7.
>
> Thanks for any help.
>
> Steven
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.openqa.org/thread.jspa?threadID=6823&messageID=19642#19642
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070307/1d6879eb/attachment.html 


More information about the Wtr-general mailing list