【问题标题】:Disable cache on network tab using python selenium(automation)使用 python selenium 禁用网络选项卡上的缓存(自动化)
【发布时间】:2021-07-01 12:39:55
【问题描述】:

我需要使用 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 并手动禁用缓存

【问题讨论】:

标签: python selenium google-chrome-devtools


【解决方案1】:
driver.execute_cdp_cmd("Network.setCacheDisabled", {"cacheDisabled":True})

使用 chrome dev 协议,看看是否有帮助

https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setCacheDisabled

【讨论】:

    猜你喜欢
    • 2020-10-09
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    • 2020-05-19
    • 1970-01-01
    • 2010-10-24
    • 1970-01-01
    • 2021-09-02
    相关资源
    最近更新 更多