python - 使用 python selenium 禁用网络选项卡上的缓存(自动化)
问题描述
我需要使用 selenium python 禁用网络选项卡上的缓存。尝试了以下方法,但没有任何效果
options = webdriver.ChromeOptions()
options.add_argument("--incognito")
options.add_argument('--disable-application-cache')
options.add_argument("--disk-cache-size=0")
options.add_argument("--disk-cache-dir=/dev/null")
options.add_argument("--disable-gpu")
d = DesiredCapabilities.CHROME
d['goog:loggingPrefs'] = {'browser': 'ALL'}
- 试图打开 URL 隐身模式,但我仍然必须打开 devtools 并手动禁用缓存
解决方案
driver.execute_cdp_cmd("Network.setCacheDisabled", {"cacheDisabled":True})
使用 chrome dev 协议,看看这是否有帮助
https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setCacheDisabled
推荐阅读
- python - 如 guppy 所述,长期运行项目的奇怪内存消耗
- xcode - 如何在 Apple Watch 上从 xcode 运行我的应用程序?
- html - DataTables:如何将第一列(ID)显示为超链接?
- r - ifelse 替换值,如果它低于以前的值
- javascript - 获取动态页面YOffset
- javascript - 在反应中已路由组件内的组件之间切换
- image-processing - 用 Python 绘制 fftshifted 图像后查找高频中心的坐标
- docker - Nginx:代理到另一个 nginx 实例:网关超时
- xamarin - 设置 Xamarin UI 测试获取错误与 Android SDK 不兼容
- security - 使用 System.IdentityModel.Tokens.Jwt 创建带有 x5c 标头参数的 JWT 令牌