Need help using watir-webdriver to auto login and screen scraping

Hello team,

I am trying to login to a server using *watir-webdriver. *The final
objective is to scrape the screen and get certain information from it.
I started first by trying to login.
I am able to get the browser and fill in the USERID & PASSWORD to te
screen. However, I am having a hard time pressing the OK button in
to proceed to the main screen.
I tried all kinds of combinations and nothing worked so far.
The simple ruby code is listed below.

require ‘watir-webdriver’

b = :firefox
b.goto “http://thehost/cognos8/cgi-bin/cognos.cgi

b.text_field(:name => ‘CAMUsername’).set(“test”)
b.text_field(:name => ‘CAMPassword’).set(“test”)
b.button(:value => ‘OK’).click
puts b.url

I am getting the following errors:

`assert_exists’: unable to locate element, using {:name=>“ok”,
:tag_name=>“button”} (Watir::Exception::UnknownObjectException)

  •    from


  •    from checkPendingU1.rb:7:in `<main>'*


One last thing, I am also including what appears to be html code which I
got by running Inspector on firefox.

“Inspeting the element” in the JavaScript/html? code the following
to be the code handling the OK button. But I don’t know what variable
use to click the button.

Thank you

Ruby S.

It can’t find the button because it doesn’t appear to be a button.
That snippet you gave is for a link.
Try something like:

b.a(text: ‘’).click

“ruby-talk” [email protected] wrote on 03/03/2014

From: Ruby S. [email protected]
To: ruby-talk ML [email protected]
Date: 03/03/2014 03:34 PM
Subject: Need help using watir-webdriver to auto login and screen

On Mon, Mar 3, 2014 at 9:33 PM, Ruby S. [email protected]

The simple ruby code is listed below.
puts b.url

Well, it seems that there’s no button (no ), but
instead there is a link (). So you will have to find the link and
click it. I’ve never used watirwebdriver, but I’d guess it’d be
something like:

b = :firefox
b.goto “http://thehost/cognos8/cgi-bin/cognos.cgi
b.text_field(:name => ‘CAMUsername’).set(“test”)
b.text_field(:name => ‘CAMPassword’).set(“test”) => ‘javascript:doSubmit()’).click
puts b.url


That was it! It was a link. I tried: =>
‘javascript:doSubmit()’).click and it work. I am one step closer to what
want to do.

Thank you both, Michael and Jess for your help.

On Mon, Mar 3, 2014 at 3:45 PM, Jess Gabriel y Galn <