You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Selenium4+Python处理站点前置浏览器登录验证的问题求助

使用Selenium4+Python处理站点前置浏览器登录验证的问题求助

我现在快愁死了!我知道怎么用Selenium实现常规的网页登录,但在测试一个publish-dev站点的时候死活卡壳了——浏览器还没跳转到目标站点,就先弹出了一个登录验证界面,关键是这个界面上的输入框和按钮根本找不到可用的XPath、CSS选择器或者NAME属性,我试了各种定位方式都无效。

我到底忽略了什么知识点?下面是我目前写的代码:

from selenium import webdriver
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.add_argument("--incognito")

driver = webdriver.Chrome(options=options)
driver.get("xyz")

sign_in_username_input = driver.find_element(By.NAME, "Username")
sign_in_password_input = driver.find_element(By.NAME, "Password")

sign_in_username_input.send_keys("ABC")
sign_in_password_input.send_keys("DEF")

sign_in_login_button = driver.find_element(By.NAME, "Sign in")
sign_in_login_button.click()

站点前置登录验证界面

备注:内容来源于stack exchange,提问作者Tontaube

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 09:38:11