Sometimes the fresh instance of Chrome will need to start with a clean browser history, cookies, and cache while working with selenium in python. I found this method working 100% with updated chrome browser.
The magic function
Function to clear chrome browser cache:
"""Clear the cookies and cache for the ChromeDriver instance."""
# navigate to the settings page
except Exception as ex:
This clear_cache(driver) method will clear the browsing data in the same way that a user would. If you execute it, by using
How to use?
Just create python file or add in existing file as per your requirements:
from selenium import webdriver
browser = webdriver.Chrome()
Thus, you will be able to clear browsing history, cookies and other stuff of chrome browser.