[Wtr-general] simple solution for basic authentication

Danny R. Faught faught at tejasconsulting.com
Mon Jul 31 14:42:37 EDT 2006


> I tried and failed, but I thought my problem was in the way IE handled
the data.  I'd love to be proven wrong:

It works for me, hacking watir.rb with hardcoded credentials like so -

	def goto( url )
		user = "username"
		pass = "password"
		auth = "Authorization: Basic " +
			Base64.encode64(user + ":" + pass) + "\015\012"
		@ie.navigate(url, nil, nil, nil, auth)
		wait()
		sleep 0.2
  		return @down_load_time
	end

I added a "require 'base64'" near the top.

This is working for a site that's a huge mess of nested frames plus a
swarm of small js, image, and css files, etc.  I noticed that you
hardcoded the base64 encoding of the credentials.  Did you try to do it
by doing the encoding on the fly?

To productize it, I'd recommending adding a credentials method like
Win32::IE::Mechanize uses.

-Danny



More information about the Wtr-general mailing list