You can use this command. Also, refresh is a built-in command.
driver = webdriver.Chrome()
driver.get("http://www.google.com")
driver.refresh()
Put the binary in the same folder as the python script you're writing and add the path of the browser driver
If you want to refresh every 5 seconds or more, just surround the refresh line with a while loop and add a delay. For example:
import time
while(True):
driver.refresh()
time.sleep(refresh_time_in_seconds)
If you wish to just refresh the page and you can see that the page hasn't changed, keep track of the page that you're on. driver.current_url is the URL of the current page. So putting it all together it would be:
import time
refresh_time_in_seconds = 15
driver = webdriver.Chrome()
driver.get("http://www.google.com")
url = driver.current_url
while(True):
if url == driver.current_url:
driver.refresh()
url = driver.current_url
time.sleep(refresh_time_in_seconds)
Another way to do this is by using this command
driver.get("some website url"); driver.navigate().refresh();
We can use actions class and mimic the key press F5
Actions act = new Actions(driver); act.SendKeys(Keys.F5).perform();
Hope this helps