2

I am coding with Python 3 and Selenium. I want automatically clear the cache in chrome, the timeframe does not matter.

This is my current solution:

driver.get('chrome://settings/clearBrowserData')
time.sleep(3)
driver.find_element_by_xpath('//settings-ui').send_keys(Keys.ENTER)
time.sleep(10)

This solution however does not click the "Delete Data" Button and I dont know why...

Chromedriver version is 85.0.4183.87 and Selenium 3.141.

zvi
  • 3,677
  • 2
  • 30
  • 48
Marten
  • 645
  • 7
  • 21

1 Answers1

0

You can use Actions + Keyboard keys to reach this button (Tab and Enter). You need to press Tab 7 times and then, Enter. So, use: TabX(7); Enter();. Works fine for me (C#).

    public void TabX(int valor)
    {
        for (int i = 0; i < valor; i++)
        {
            Actions act = new Actions(driver);
            act.SendKeys(Keys.Tab).Build().Perform();
        }
    }

    public void Enter()
    {
        Actions act = new Actions(driver);
        act.SendKeys(Keys.Enter).Build().Perform();
    }