I'm having trouble getting through basic authentication on one of our websites on IE8 using Watir.
When I navigate(goto) the url, the basic authentication dialog is displayed showing 'Connect to ' as the title, with user name, password edit fields and OK, Cancel buttons (the usual!). In Watir, after passing the following code:
b = Watir::Browser.new
b.goto '<our url>'
the dialog is displayed but the goto statement never completes. If I cancel or login manually, then the goto statement returns a number (this is in IRB by the way).
I've done lots of investigation and tried out all sorts of ideas but now seem to be stumped!
When we login to the site manually, we have to pass our credentials like below:
User Name: <domain>\<username>
Password: <password>
I've tried this in the url string i.e.
http://<domain>\<username>:<password>@<url>:<port>
http://lnd\mbartram:[email protected]:xxxx
but this doesn't work in code or if I enter it manually in the address bar. Perhaps I need to escape the \ part to get this to work but how?
Any help is greatly appreciated. M.
Ok, using a bit of a hack but it works consistently for me. I'm using a simple Wscript.Shell SendKeys method. See below:
`start #{theURL]`
loginDialog = WIN32OLE.new('Wscript.Shell')
loginDialog.AppActivate('Connect to #{ip}')
sendKeys = "#{userName}{TAB}"
loginDialog.SendKeys(sendKeys)
sleep(1)
sendKeys = "#{password}{TAB}{ENTER}"
loginDialog.SendKeys(sendKeys)