[Wtr-general] hacked goto() almost working, any ideas? Re: anyone ever hacked Watir to do Basic Authentication?
Chris McMahon
christopher.mcmahon at gmail.com
Wed May 3 18:24:26 EDT 2006
Finally, seems like my problem is just for frames. In fact, it seems
exactly like this problem:
http://www.talkaboutsoftware.com/group/microsoft.public.inetsdk.programming.webbrowser_ctl/messages/17461.html
I've also tried navigating directly to the frame in question first,
then to the main page, but it doesn't help, the browser still won't
use auth credentials to request the frame.
On 5/3/06, Chris McMahon <christopher.mcmahon at gmail.com> wrote:
> Check this out, I've hacked watir's goto() method:
>
> def goto(url)
> #@ie.navigate(url)
> @ie.navigate(url,nil,nil,nil,"Authorization: Basic
> AbdXyz46bG1ubw==\n")
> wait()
> sleep 0.2
> return @down_load_time
> end
>
> and it works!!
>
> The only problem is that it works only for the very first transaction.
> I'm now getting auth popups for inline images and things.
>
> Under normal circumstances, the browser, having passed basic
> authentication credentials once to this site would know to always pass
> those credentials to that site for every subsequent GET/POST/whatever.
> Anyone have any ideas about how to make that happen through hacking
> on Watir directly?
>
> -Chris
>
>
> On 5/3/06, Chris McMahon <christopher.mcmahon at gmail.com> wrote:
> > So using net/http, I can do:
> >
> > my_id = 'user'
> > my_pwd = 'password'
> > auth = "Basic " + Base64.encode64( "#{my_id}:#{my_pwd}" )
> >
> > url = '/'
> > site = 'server'
> > port = 80
> >
> > req = Net::HTTP.new( site, port )
> > req.get( url, 'Authorization' => auth ) do |r|
> > puts r
> > end
> >
> > Has anyone ever considered having Watir do
> >
> > my_id = 'user'
> > my_pwd = 'password'
> > auth = "Basic " + Base64.encode64( "#{my_id}:#{my_pwd}" )
> >
> > ie = IE.new
> > ie.goto("http://server").auth
> >
> > It seems like it ought to be possible, and it'd save 99% of the
> > WinClicker ugliness.
> >
> > -Chris
> >
>
More information about the Wtr-general
mailing list