1

Authentication window snap

Already tried following methods,

1) https://username:password@sitename.com

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...

Sankalp
  • 11
  • 3
  • You should try to url encode the back slash. Otherwise, your site seems to not want you to automate or Web scrape against it – OneCricketeer Jun 10 '16 at 14:38
  • Does any of these help? http://stackoverflow.com/questions/10395462/handling-browser-authentication-using-selenium?lq=1 ; http://stackoverflow.com/questions/24304752/how-to-handle-authentication-popup-with-selenium-webdriver-using-java ? – Naman Jun 10 '16 at 23:44
  • By using encode value of '\', it's working.... – Sankalp Jun 29 '16 at 07:29
  • You should post this as an answer and accept it so others can see that your problem was solved, especially if you solved it yourself :) – JeffC Jul 11 '16 at 04:26

1 Answers1

2

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()
Community
  • 1
  • 1
Shoaib Akhtar
  • 1,287
  • 3
  • 15
  • 39