Python+Selenium+IE遇到windows security弹出框

driver.get(url)的时候遇到了https的Windows security弹出框,
解释问题图片网上查了很多解决方案,试了好用的
https://stackoverflow.com/questions/43666687/how-to-handle-windows-security-pop-up-in-ie-windows-10-using-selenium,即:
I was able to solve the IE Basic Auth Problem in IE 11 (Windows 10) by making registry changes. As described in this blog post, iexplore.exe and explorer.exe keys need to be created in the following locations:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE

They should be DWORD values, set to 0.

This will allow you to do:

http://domain\user:password@example.com
where %5C is .
比较简单,修改注册表之后重启机器就可以了,另外\要用/5c代替。
但是我不明白错误原因,也就不明白为什么要这么改。望多指教。
看也有其他方案,但是感觉太麻烦就没试:
https://stackoverflow.com/questions/27322871/handling-authentication-required-alert-box-with-python-2-7-selenium-webdrive
https://stackoverflow.com/questions/48229446/python-selenium-webpage-with-windows-security
https://www.jianshu.com/p/c1397ccde04b
以下是我测试过的用例

#!/usr/bin/env python3
#login site

import selenium.webdriver
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.common.alert import Alert
#from selenium.webdriver.support.ui import WebDriverWait as wait
#from selenium.webdriver.support import expected_conditions as EC

br=selenium.webdriver.Ie()
url=r'https://sea%5ctuser1:12345678@home.world.com/'#改注册表之后好用了,而且\要用%5c的方式
br.get(url)#open url
br.implicitly_wait(5)
login=br.find_element_by_id('overridelink')
br.implicitly_wait(10)
login.click()

#wait(br,10).until(EC.alert_is_present())
#alert=br.switch_to_alert()
#alert.send_keys('''sea\\tuser1\ue00412345678''')#user和password一直在username框里,使用Keys.TAB和\t和\ue004也不好用
#alert.send_keys('\t')
#alert.send_keys(Keys.TAB)#不起作用
#alert.send_keys(Keys.TAB)#不起作用
#alert.accept()
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值