On 1/30/06, Terry Peppers <[EMAIL PROTECTED]> wrote:
> I was looking through the old Watir mailing lists for some information on
> how I might be able to bypass the Apache user authentication on our staging
> machine without using AutoIt. I didn't come up with much aside from use -
> AutoIt. One of our developers recommended I should try the following URL:
>
> http://username:[EMAIL PROTECTED]
...

Yeah, the http://user:[EMAIL PROTECTED] thing used to work in IE too, but
support for that was removed at some point after it began to be widely
used as part of a technique to spoof URLs in phishing emails. :)

Anyway, you might want to look at the 'WindowLogonExample.rb' and
'WindowLogonExtra.rb' files in the Watir unit tests.  Those are more
the kind of thing you want, I think.  And one of the things that
helped me understand ways to use autoit was looking over
'\ruby\lib\ruby\site_ruby\1.8\watir\WindowHelper.rb'.

Up to and including Watir 1.4.1, it seems this type of task is usually
accomplished using multiple Ruby threads, in order to get around the
fact that IE blocks when you request a URL that spawns a popup or
prompt.  The code in one of the threads often just runs a second Ruby
script (as shown in WindowLogonExample.rb / WindowLogonExtra.rb).

I think the development version of Watir has some fancy new stuff that
helps in this area, but I haven't looked at it yet.

Anyway, here's a distilled example of the thread technique that might
work as a standalone script for your case:

---------------------------------

require 'watir'
require 'win32ole'

autoit = WIN32OLE.new('AutoItX3.Control')

# URL that kicks off the basic auth prompt:
url = "http://quantico.int.apg.aventail.com/secured/";

# The title of the prompt dialog:
prompt = "Connect to quantico.int.apg.aventail.com"

user = "user1"
pass = "user1"

a = Thread.new {
  ie = Watir::IE.start(url)
}

b = Thread.new {
  autoit.WinWait prompt, ""
  autoit.Send(user)
  autoit.Send("{TAB}")
  autoit.Send(pass)
  autoit.Send("{ENTER}")
}

a.join
b.join

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to