selenium-webdriver - 硒进行的访问没有出现
问题描述
我正在尝试使用以下设置在 localhost 站点上进行自动化测试:
Python 3.8.10
selenium 3.141.0
Firefox 90.0
Burp Suite 社区版 v2021.6.2
我正在使用地址为 127.0.0.1:8080 的 Burp 代理。
我在这里测试了几个可用的示例。下面的代码是迄今为止效果最好的代码。
from selenium import webdriver
firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
PROXY = "127.0.0.1:8080"
firefox_capabilities['proxy'] = {
"proxyType": "MANUAL",
"httpProxy": PROXY,
"sslProxy": PROXY
}
driver = webdriver.Firefox(capabilities=firefox_capabilities)
driver.get("http://127.0.0.1")
当 driver.get("URL here") 中的 url 不是 localhost 时,此代码可以正常工作。当我输入 url http://127.0.0.1时,selenium 进行的访问不会出现在 Burp Suite 的 HTTP 历史记录中。代替访问的 url,出现“http://detectportal.firefox.com”。
这是代码中的问题还是我需要做的一些配置?
解决方案
查看 Firefox 代理设置,您可以在那里找到 localhost 连接永远不会定向到代理的声明。
但这可以通过打开about:config
并将选项设置为network.proxy.allow_hijacking_localhost
来更改true
。
推荐阅读
- excel - Excel 公式 - 每 6 天获取每个变量的总和
- powershell - Get-WindowsFeatures:如何过滤显示名称?
- spring-boot - 在 Heroku 上部署 JHipster 应用程序时,“无法将 '' 下的属性绑定到 com.zaxxer.hikari.HikariDataSource”
- jquery - 如何销毁 FooTable 实例
- mysql - 如何在 SQL 查询中使用公式并对该结果进行排序
- reactjs - React 测试库 TypeError:无法在“EventTarget”上执行“removeEventListener”:需要 2 个参数,但只有 1 个存在
- sql - 如何删除超过 6 个月大的行,但使用 SQL 确保表中至少有 100 行?
- docker - 在 Spacy 中下载语言模型会在 docker 中中断
- javascript - Javascript 在 JSON 请求中获取“GET https://www.purpleair.com/json 400 (Bad Request)”
- sql-server - 避免浮点 SQL 的转换过程中的精度损失