0

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)
Tobs
  • 1
  • 1
  • 1
  • you can see this article for help https://intoli.com/blog/clear-the-chrome-browser-cache/ – Sajjad Zaidi Sep 30 '20 at 08:26
  • 1
    I already tries this method, but it didn't work, I get an error saying that it's unable to locate element: /deep/ #clearBrowsingDataConfirm – Tobs Sep 30 '20 at 08:39
  • I tried your code, it seems to be working. Maybe, your connection might be slow. For this, you can add webdriver.wait to allow your driver to wait for the button to show. See https://selenium-python.readthedocs.io/waits.html – Sajjad Zaidi Oct 02 '20 at 13:37

1 Answers1

-1

beacuse shadowRoot

<settings-clear-browsing-data-dialog>
 #shadow-root (open)
</settings-clear-browsing-data-dialog>
xin.chen
  • 964
  • 2
  • 8
  • 24
  • This doesn't answer the question in a useful way does it (show updated selenium/python code to implement recommendation pls) – JB-007 Oct 24 '21 at 14:59