1

I need to disable cache on network tab using selenium python . tried below ways but nothing worked

   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'}
  • Tried to open URL incognito mode but still I have to open devtools and disable cache manually
user3518405
  • 45
  • 2
  • 10
  • Check here https://stackoverflow.com/questions/19026295/run-chrome-browser-in-inconginto-mode-in-selenium/19026738 – vitaliis Apr 05 '21 at 17:02

1 Answers1

3
driver.execute_cdp_cmd("Network.setCacheDisabled", {"cacheDisabled":True})

use chrome dev protocol , see if this helps

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

PDHide
  • 18,113
  • 2
  • 31
  • 46