I am automating an application which contains browser level authentication.
When I open the application, the browser performs basic authentication, i.e. it prompts for a username and password. How can I handle this scenario using Selenium?
|
I am automating an application which contains browser level authentication. When I open the application, the browser performs basic authentication, i.e. it prompts for a username and password. How can I handle this scenario using Selenium? |
|||||||
|
|
Adding to Dmitry's and Lyndon's answer, you can also using Apple scripts if you are using a Mac machine. It is very efficient to handle such situations. Just need to run the scripts using java runtime class if you are using java. |
|||
|
|
|
Use |
|||||
|
|
It would be better if you provide some more info on what language/platform are you using, but, anyway… Selenium is not really good on handling such windows, so If you are using Java, then please look at Robot class If you are using Ruby, C#, Java, then look at WatiR, WatiN, WatiJ. All this libraries can attach to the existing browser by it’s title and handle the pop-up dialogs. I am not saying about replacing Selenium with WatiN, but you can use this library of this specific purpose. Also for .NET you can use Windows UI automation And, of course, you can use AutoIt or AutoHotkey. The most simplest way is to compile the dialog handling code in to .exe file and run it with specific parameters when it is necessary. |
|||
|
|
Basic authentication isn't handled very well in Selenium, and to be honest, I'm not certain that it should be either (although it would be nice). The solution that I've been using is to create a script in autoIT or something similar that is able to access the authentication box. Essentially, create the script that looks for the authentication box, enter credentials, click OK or press Enter and then either end or kill this sub script. It's dirty, not ideal, but it's the best solution that I've found so far that can work with multiple browsers. |
|||
|
|
|
Here one method of handling, Create browser profile and check remind password. By calling the profile before the execution, It won't ask you the authentication next time onwards. Let me know if it doesn't work. |
|||
|
|