After opening application URL, User is redirected to Sign-In page where there is a Sign-In button.
driver.get("abc.com")
Now when user click on Sign-In button, URL is changed in the same window say it becomes xyz.com and shows authentication popup window for login purpose similar to image shown below.
To enter username and password in authentication window I tried the below code
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("username")
time.sleep(1)
shell.Sendkeys("{TAB}")
time.sleep(1)
shell.Sendkeys("password")
time.sleep(1)
shell.Sendkeys("{ENTER}")
time.sleep(1)
It didn't work. Then I tried to open windows authentication popup directly(by copying URL after click of Sign-In button) with the above code, it worked
driver.get("xyz.com")//instead of abc.com my application URL
I am bit confused. If I open my app URL abc.com, click on Sign-In button, use autoit, it didn't enter credentials. But if I directly send window authentication URL xyz.com instead of app URL abc.com and use autoit, it work.
Can anyone suggest what I am missing here? I also tried to switch window after click on Sign-In button thinking its new URL and then autoit command, but it still it didn't work.
driver.switch_to_window(driver.window_handles[1])
Any idea on this?
Note: I noticed that click on Sign-In button, windows is loading infinitely & cursor is active on username text-field of windows authentication poup. Also once windows authentication window appears, none of selenium command is working and neither autoit command.
To handle the basic authentication popup, we can pass the username and password along with the web page's URL. When the login pop-up is prompted, we enter the username as “admin” and the password as “admin” and then login. Thus, the user would be successfully logged into the website.
On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then World Wide Web Services, then Security. Select Windows Authentication, and then click OK.
The dialog is treated as an alert by selenium. In c#, the code to enter in credentials for a Firefox test looks like:
// Inputs id with permissions into the Windows Authentication box
var alert = driver.SwitchTo().Alert();
alert.SendKeys( @"username" + Keys.Tab +
@"password" + Keys.Tab);
alert.Accept();
The first line is telling the driver to check for open alerts (the dialog box).
The second line sends the username and password to the alert
The third line then sends those credentials and, assuming they are valid, the test will continue.
Assuming you are testing using Firefox, there is no requirement to use extra frameworks to deal with this authentication box.
It looks like you just have to open the URL with basic auth credentials. Can you try this first?
driver.get('http://username:[email protected]')
If you're still getting the popup, try this
driver.get('http://username:[email protected]') #assuming this is the site that handles authentication
driver.get('abc.com')
It should stop the popup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With