Python Selenium - Clearing chrome cache

3.6k views Asked by At

I'm trying to clear the cache from the chrome driver with selenium.

The below code worked fine for a day, and now it has stopped working for some reason. It redirects to the ClearBrowserData url, but it does not press enter to run the Clear Data button. Am I doing something wrong? I would appreciate some help on this.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

chromedriver = 'path'
browser = webdriver.Chrome(executable_path = chromedriver)
browser.get('chrome://settings/clearBrowserData')
browser.find_element_by_xpath('//settings-ui').send_keys(Keys.ENTER)
1

There are 1 answers

1
xin.chen On

beacuse shadowRoot

<settings-clear-browsing-data-dialog>
 #shadow-root (open)
</settings-clear-browsing-data-dialog>