How to refresh a webpage using Python Selenium Webdriver?


We can refresh a webpage using Selenium webdriver in Python. This can be done with the help of the refresh method. First of all, we have to launch the application with the get method.

Once a web page is loaded completely, we can then refresh the page with the help of the refresh method. This way the existing page gets refreshed. The refresh method is to be applied on the webdriver object.

Syntax

driver.get("https://www.tutorialspoint.com/tutor_connect/index.php")
driver.refresh()

Example

from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\chromedriver.exe")
driver.implicitly_wait(0.5)
#launch URL
driver.get("https://www.google.com/")
#identify text box
m = driver.find_element_by_class_name("gLFyf")
#send input
m.send_keys("Java")
#refresh page
driver.refresh()

Output

Updated on: 06-Apr-2021

16K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements