Sankalp
Sankalp

Reputation: 11

How to handle windows authentication popup using selenium with python?

Authentication window snap

Already tried following methods,

1) https://username:[email protected]

My username contains '\' thats why it is giving problem.

2) switch to alert method In this I am getting 'No alert' Exception

Please help in these cases/ Suggest any other method to handle windows authentication with python...

Upvotes: 1

Views: 2034

Answers (1)

Shoaib Akhtar
Shoaib Akhtar

Reputation: 1403

Install win32com.client and then try the below code

from selenium import webdriver
import time
import win32com.client

driver=webdriver.Firefox()
driver.maximize_window()
driver.get('url')
shell = win32com.client.Dispatch("WScript.Shell")   
shell.Sendkeys("username")  
shell.Sendkeys("{TAB}")
shell.Sendkeys("password") 
shell.Sendkeys("{ENTER}")
time.sleep(5)
driver.quit()

Upvotes: 2

Related Questions