How to refresh the page using Selenium web driver in Python
Overview
Selenium is an open-source web-based automation tool. In this Answer, we'll learn to refresh the page using Selenium in Python. We'll use the refresh() method to refresh the page.
Syntax
driver_instance.refresh()
Example
from selenium import webdriverimport time#specify where your chrome driver present in your pcPATH=r"C:\Users\educative\Documents\chromedriver\chromedriver.exe"#get instance of web driverdriver = webdriver.Chrome(PATH)#provide website url heredriver.get("https://www.educative.io/")#sleep for 5 secondstime.sleep(5)#refresh the pagedriver.refresh()
Explanation
- Line 1: We import
webdriverfromseleniumpackage. - Line 2: We import
time. - Line 5: We provide the path where we placed the driver of the web browser. For chrome, it is
chromedriver.exein windows environment. - Line 8: We get the instance of the
webdriver. - Line 11: We provide the URL to
driver.get()method to open it. - Line 14: We make the program sleep for
5seconds. - Line 17: We refresh the current page using the
driver.refresh()method.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved