Watir — Basic Authentication window Handling

Code:

require ‘rubygems’
require ‘firewatir’
include FireWatir

browser=Firefox.new

#(Use next line instead of –>browser.goto(“http://website.com”) and entered username , password)
browser.goto(“http://username:password@website.com”)

# (If the authentication window occurs any other pages then simply call that LINK URL with username,password like this.)

Advertisements

2 thoughts on “Watir — Basic Authentication window Handling

  1. Chris says:

    When I use the method above I get a “Confirm” dialog box that says “You are about to log in to the site “172.20.1.1” with the username “admin”.” The call to goto does not return until I click “ok”. Do you know how to get past this confirm dialog box? I’m using firewatir on ubuntu linux.
    Thanks,
    Chris

  2. Francisco says:

    Hi, I have coded your tip but I still get this window when trying to access a basic auth website


    the code is

    require 'rubygems'
    require 'firewatir'
    require 'nokogiri'
    include FireWatir
    
    browser = Firefox.new
    browser.goto("http://USER:PASS@nagios2/nagios/cgi-bin/avail.cgi")
    
    browser.select_list(:name, "report_type").set("Servicegroup(s)")
    browser.button(:value,"Continue to Step 2").click
    browser.select_list(:name, "servicegroup").set("WAP Service Group Ping - KPI HA")
    browser.button(:value,"Continue to Step 3").click
    browser.select_list(:name, "timeperiod").set("Last 31 Days")
    browser.button(:value,"Create Availability Report!").click
    
    page_html = Nokogiri::HTML.parse(browser.html)
    puts page_html.xpath("html/body/div[3]/table/tbody/tr[6]/td[2]").inner_text
    
    browser.close
    

    any tip? Thanks in advance 🙂
    Francisco

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s