Reputation: 47
I have put code on selenium, where browser get refreshed after 20 second. However I want to put some more code on it, that before opening the browser it will clear history, cache and after whole work, it will get close close and again open and clear history, cache and cookies here is my code :
import time from selenium
import webdriver as wd
chromedriver - r"D:\bot\chromedriver.exe"
driver=wd.chrome(executable_path=chromedriver)
driver.get("http:\youtu.be/RsWCo_xGXxY")
refresh_rate = 20
while True:
time.sleep(refresh_rate)
driver.refresh()
Upvotes: 1
Views: 2324
Reputation: 5647
To clear all browser history you can use this code:
from selenium import webdriver
import time
chrome_path = r"D:\bot\chromedriver.exe"
driver = webdriver.Chrome(chrome_path) # creates new webdriver instance
driver.get("http:\youtu.be/RsWCo_xGXxY")
driver.delete_all_cookies() # deletes all coockies
refresh_rate = 20
while True:
time.sleep(refresh_rate)
driver.refresh()
Output:
Upvotes: 1