SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Help with Watir

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with Watir

    Hey,

    I am new to using Watir/Ruby, so I'm hoping this will be an easy issue.

    the line
    b.link( :click, "javascript:check_form()").fire_event"onclick"

    worked the way I wanted to by clicking on a javascript login, however, any commands afterwards don't do anything and this error is generated

    C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:220:in `click': undefined method `wait' for nil:NilClass (NoMethodError)
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:80:in `call'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:80:in `match?'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:56:in `locate'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:54:in `each'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:54:in `locate'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:53:in `catch'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:53:in `locate'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/locator.rb:45:in `each_element'
    ... 6 levels...
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:288:in `enabled?'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:60:in `assert_enabled'
    from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:258:in `fire_event

    From what I understand, the wait method its referring to is in the background that Watir automatically. I haven't been able to figure any way around this.

    Does anyone have any suggestions or anything need to be clarified? (As I mentioned, this is all new to me, trying to write a simple script for work)

    I'm using Ruby 1.8.6 and Watir 1.6.5

  2. #2
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it working

    changed the line to b.link( :href, /check_form/).click instead

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, with Watir and JavaScript, you usually have to wait for a JavaScript action to perform. That is Watir will move on the the next action without waiting for the response from the JavaScript action. So you have to use wait or some other procedure that detects that the response has occurred before you move on.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •