Windows 身份验证代码现在不再有效 [英] Windows authentication code no longer working now

查看:33
本文介绍了Windows 身份验证代码现在不再有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的以下 Windows 身份验证代码运行良好超过一年.但是在过去的几天里,它现在工作的时间更长了.我无法确定确切原因.

My below code for windows authentication was working well for over a year. But for the last few days it is longer working now. I am not able to identify exact reason for that.

from selenium import webdriver
import time
import win32com.client

driver=webdriver.Chrome('D:/Software/BrowsersDriver/ChromeDriver/chromedriver.exe')
driver.maximize_window()
driver.get("authentication windows url")
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(5)
driver.quit()

当我的 chrome 驱动程序停止工作时,我尝试将其更改为最新版本,但仍然无法正常工作.一旦出现 Windows 身份验证,光标在用户名文本字段上无限闪烁,但未输入用户名.我在控制台卡住时收到以下消息

I tried to change my chrome driver to latest when it stops working, but still it is not working. Once the windows authentication appears, cursor keeps blinking on username text-field infinitely, but username is not entered. I am getting below message in console when it is stuck

2018-04-02 07:09:28,230 INFO: Imported existing <module 'comtypes.gen' from 'C:\Python27\lib\site-packages\comtypes\gen\__init__.pyc'>
2018-04-02 07:09:28,230 INFO: Using writeable comtypes cache directory: 'C:\Python27\lib\site-packages\comtypes\gen'

之前运行良好的相同代码.我正在使用 python 2.7.12 和最新版本的 chrome 驱动程序.

The same code used to work well earlier. I am using python 2.7.12 and latest version of chrome driver.

此外,如果有人有不同的解决方案或链接以在 python selenium 的身份验证窗口中提供凭据,那么这也适用于我.

Also if someone has a different solution or a link for it for providing credentials in authentication window in python selenium then that too will work for me.

注意:同样的代码之前运行良好,但现在不起作用

Note: The same code works well earlier, but now it's not working

推荐答案

尝试 AutoIT为 Windows 身份验证创建一个 exe 并在需要时调用它,如果没有其他工作.如果您主要使用 Pyton,请尝试 this

Try AutoIT to create an exe for the windows authentication and call it where ever required, if nothing else is working. If you are mostly working with Pyton then try this

示例代码:-

WinWaitActive("Authentication Required","","120")

If WinExists("Authentication Required") Then
Send("username{TAB}")

Send("password{Enter}")

EndIf

这篇关于Windows 身份验证代码现在不再有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆