WebDriver class in selenium as a methods which is helpful for navigating operations such as forward ,backward and refresh the webpage.
This method is used to forward the webpage.It works similarly like a forward button in a browser. It doesn’t take any argument and it doesn’t return anything.
Syntax: driver.forward()
This method is used to do the backward webpage operation.It works similarly like a back button in a browser. It doesn’t take any argument and it doesn’t return anything.
Syntax: driver.back()
This method is used to refresh the webpage.It works similarly like a refresh button in a browser. It doesn’t take any argument and it doesn’t return anything.
Syntax: driver.refresh()
Example: In the below example we will launch the webpage and execute all the navigation methods.
NavigationMethods.py
from selenium import webdriver import time driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/drivers/chromedriver.exe") driver.get("http://www.dummypoint.com/seleniumtemplate.html") time.sleep(2) driver.get("http://www.dummypoint.com/Form.html") time.sleep(2) driver.back() time.sleep(2) driver.forward() time.sleep(2) driver.refresh() time.sleep(5) driver.quit()