Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to By Pass NTLM authentication pop up while performing automation testing using Selenium web driver for Chrome browser?

I used the following python code to bypass the NTLM popup.

chromedriver = webdriver.Chrome(executable_path=chromedriver_path, chrome_options=options)
chromedriver.get("https://username:[email protected]")

The popup couldn't bypass and still exists and test breaks.

like image 675
coder123 Avatar asked May 22 '19 07:05

coder123


People also ask

How do you pass credentials to an authentication popup in Selenium?

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.

Can Selenium handle pop-ups?

Yes, it is possible to handle Windows based pop-ups in Selenium webdriver. Sometimes on clicking a link or a button, another window gets opened. It can be a pop up with information or an advertisement. The methods getWindowHandles and getWindowHandle are used to handle child windows.


2 Answers

You might be facing issue for domain login as browser converts domain separator \ to / and credentials become invalid. Use encoded separator %5C and it will work.

Browser will convert https://domain\username:password@URL to https://domain/username:password@URL.

User encoded separator for request.
https://domain\username:password@URL => https://domain%5Cusername:password@URL

like image 151
kushwahav Avatar answered Sep 21 '22 23:09

kushwahav


As @BhuvaneshMani has mentioned in the comment's on this answer...

You need to observe how the NTLM is getting authenticated. (use the devTools in chrome under Network)

After you find the authentication call use that URL!

As @BhuvaneshMani's example:

For e.g., app url may be app.url however after hitting the url, it redirects to auth.server.url. So if you append username and password into app.url it wont work. It should be appended to auth.server.url.

So your code should look something like this:

driver = webdriver.Chrome(executable_path=chromedriver_path, chrome_options=options)
driver.get("https://username:[email protected]")

Or (I found that most authentication calls are to the same URL just to the server port: port:8080/auth/login)

driver.get("https://username:[email protected]:8080/auth/login")

Hope this helps you!

like image 39
Moshe Slavin Avatar answered Sep 20 '22 23:09

Moshe Slavin