Python Windows身份验证用户名和密码不起作用 [英] Python Windows Authentication username and password is not working
问题描述
我正在尝试在提示符(给出的URL)中输入数据,以下代码给我一个错误.请帮我解决这些问题吗?
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()
我尝试过:
ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()
这也是行不通的.
使用 Selenium 3.4.0
, geckodriver v0.18.0
, Mozilla Firefox 53.0
通过 Python 3.6.1
,可以通过将username
和password
嵌入到url
自身中来绕过 Basic Authentication
弹出窗口,如下所示.>
此解决方案打开URL
http://the-internet.herokuapp.com/basic_auth 并使用有效的username
和password
凭据进行身份验证.
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")
I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()
I have tried with:
ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()
This one is also not working.
When you work with Selenium 3.4.0
, geckodriver v0.18.0
, Mozilla Firefox 53.0
through Python 3.6.1
you can bypass the Basic Authentication
popup through embedding the username
and password
in the url
itself as follows.
This solution opens the URL
http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username
and password
credentials.
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")
这篇关于Python Windows身份验证用户名和密码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!