How to refresh a webpage using Python Selenium Webdriver?

SeleniumAutomation TestingTesting Tools

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

raja
Published on 06-Apr-2021 10:58:00
Advertisements