[Wtr-general] This is really close to fixing another access problem I hope Re: [question] access denied OLE error code:80070005
Chris McMahon
christopher.mcmahon at gmail.com
Tue May 9 12:08:28 EDT 2006
On 5/8/06, Bret Pettichord <bret at pettichord.com> wrote:
> This might fix your problem depending on the actual code that failed. (Show
> us more of your code if you need more help.)
>
> class Watir::IE
> attr_accessor error_checkers
> end
> ie.error_checkers = []
I have been struggling mightily to code HTTP Basic Authentication into
Watir, and failing, but this provides a tantalizing :) hint of an
approach I haven't tried yet.
Basic Authentication, in a nutshell, is when the server returns a 401
Authorization Required error to the browser. The browser throws up a
javascript logon box prompting for username/password. The combination
user/pass is minimally encoded, and then used for subsequent GETs and
POSTs in the same domain.
However, a client that already knows the encoded user/pass should be
able to bypass the logon box by adding the appropriate "Authorization:
Basic" header to the request for the frame, link, inline image, or
whatever. So I hacked watir.rb's goto() method like this:
def goto(url)
#@ie.navigate(url)
@ie.navigate(url,nil,nil,nil,"Authorization: Basic
YFoObAr46bG1ubw==\n")
wait()
sleep 0.2
return @down_load_time
end
This actually works for the main page, which is very cool.
However, now IE produces a logon popup box for the iframe on the
page. If I dismiss that box, I get the logon popup box when I try to
follow the link on the page. IE doesn't put the right Authorization
headers on subsequent requests.
So I tried hacking a proxy to add the headers whenever IE calls out.
I add the headers, but I'm doing something wrong, because the server
doesn't recognize them properly, and I still get the popup boxes:
def handler(req, res)
add_hash = { "authorization" => "Basic YFoObAr6bG1ubw==" }
p "----------------Request Headers----------------"
req.header.merge!(add_hash)
req.header.each { |key,value| puts "#{key} is #{value}" }
etc...
end.
So after that long-winded explanation: does anyone think that
attr_accessor in something like that code
> class Watir::IE
> attr_accessor error_checkers
> end
> ie.error_checkers = []
would be capable of adding Basic Auth headers correctly?
-Chris
More information about the Wtr-general
mailing list