On this page: http://wiki.openqa.org/display/WTR/Basic+Authentication,
there is a main.rb with this code.
<code>
require 'unittests/setup'
require 'watir'
require 'watir/WindowHelper'
class TC_Logon_Test < Test::Unit::TestCase
def setup
@url = 'yoursite.com'
@login_title = "Connect to #{@url}"
@username = 'uname'
@password = 'pass'
end
def test_logon
a = Thread.new {
system("ruby handle_logon.rb \"#{@login_title}\"
\"#{@username}\" \"#{@password}\"")
}
b = Thread.new {
system('ruby handle_security_alert.rb')
}
$ie.goto(@url)
a.join
b.join
# continue code here...
end
end
</code>
It uses the system kernel method to run two Ruby files:
handle_logon.rb && handle_security_alert.rb.
I am not sure where these files exist or what they contain?
Aidy
Was early in the morning here:
helper = WindowHelper.new
helper.logon(login_title, username, password)
There doesn't seem to be a timeout on the WindowHelper logon method
and looking at the autoit functions there is no default.
Aidy
2008/8/12 Tim Koopmans <tim....@gmail.com>:
And I have never got this to work in a Ruby thread
autoit.WinWait title, ""
Has anyone else?
Aidy
2008/8/12 aidy lewis <aidy....@googlemail.com>:
<code>
autoit = WIN32OLE.new("AutoItX3.Control")
Thread.new(autoit) do
sleep 1
autoit.WinWait("Authentication Required", "")
autoit.Send(username)
autoit.Send("{TAB}")
autoit.Send(password)
autoit.Send("{ENTER}")
end
self.goto(url)
<code>
I think autoit.WinWait executes faster than browser.goto => a hang. We
need a sleep even if it is only for 0.1 secs
I don't think we need to explicitly create another thread for
self.goto as it is already in one.
Aidy
2008/8/12 aidy lewis <aidy....@googlemail.com>:
Sorry, we don't need to create a thread for browser.goto and .join
because browser.goto(url) will never complete unless the autoit thread
in executed.
Aidy
> Aidy
>