Since this is one of the top hits on google ill provide the ruby solution if you cant use the http://username:password@url.
you can use system input but doing it on windows and on mac are different. Here is the solution on a mac:
You would have to detect if the test is running on windows or mac first and then do the corresponding.
t1=Thread.new{
@browser.get 'url';
}
t2=Thread.new{
sleep (10)
#replace these lines with the windows corresponding if on windows.
%x(osascript -e 'tell application "System Events" to keystroke "username"')
%x(osascript -e 'tell application "System Events" to keystroke tab')
%x(osascript -e 'tell application "System Events" to keystroke "password"')
%x(osascript -e 'tell application "System Events" to keystroke return')
}
t1.join()
t2.join()
Here is the windows solution:
t1=Thread.new{
@browser.get 'url'
}
t2=Thread.new{
sleep (5)
wsh = WIN32OLE.new('Wscript.Shell')
wsh.AppActivate('browser') #fx. firefox
wsh.SendKeys('username{TAB}password{ENTER}')
}
t1.join()
t2.join()