I’m trying to use FireWatir (1.6.5) to access a site using Basic
Authentication and I’ve been unable to find a solution that works on
Firefox in Linux. Does FireWatir 1.6.5 support Basic Authentication
on Linux? I’ve been searching the web for 2 days and can’t get a
straight answer anywhere as to how to do this.
The only thread I found that seemed helpful was this one (
http://groups.google.com/group/watir-general/browse_thread/thread/d8ab9a177d282ce4/fc1bf2319fb387d8?lnk=gst&q=basic+authentication#fc1bf2319fb387d8).
Aedorn Varanis says ” Angrez’s fork had the solution so I’m using that
now. Thanks Angrez, works perfectly!”, but he doesn’t mention what he
did to get things working.
Initially I tried to bypass the authentication dialog box by using:
browser.goto(‘http://admin:password@172.20.1.1‘)
However, this generates a “Confirm” dialog which says:
“You are about to log in to the site “172.20.1.1” with the username
“admin”.” [Cancel, OK]
This dialog blocks, and the goto call won’t return until I click “OK”.
Then I tried adding:
browser.startClicker(“ok”)
browser.goto(‘http://admin:password@172.20.1.1‘)
But this ALSO generates the same “Confirm” dialog.
I tested out the startClicker functionality using the unit test /var/
lib/gems/1.8/gems/firewatir-1.6.5/unittests/html/JavascriptClick.html
and it worked fine, which makes me think that using the startClicker
method is NOT the correct way to take care of the Confirm dialog.
Anybody else found a way to get Basic Auth to work, or how to click
the OK on the confirm dialog? I’m at my wits end…
With help from Aedorn Varanis I’ve got things working on Firefox in
Linux.
Aedorn sent me a “logon” method which issues a jssh command that
checks for an “Authentication Required” dialog and if it exists, fills
in the username/password and submits the dialog.
I’ve copied and pasted what he sent me below:
From this, I was able to subclass the FireWatir::Firefox class with a
new Browser class which supports a “credentials=” method just like the
Celerity::Browser does. So, just like using celerity, you can do:
This will automatically fill in the Basic Auth dialog and log you into
the site.
I’ve posted the contents of my browser.rb file below (notice this
works in ruby+firewatir and jruby+celerity in linux):