当你一起工作 Selenium 3.4.0
, geckodriver v0.18.0
, Mozilla Firefox53.0
通过 Python 3.6.1
可以绕过 Basic Authentication
通过嵌入的弹出
username和
password在
url自身如下。
此解决方案将打开
URLhttp://the-internet.herokuapp.com/basic_auth 并使用有效的
username和
password凭据进行身份验证。
from selenium import webdriverfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinarybinary = 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")


