Navigate to a New Webpage using Selenium | Navigation Python (with demo video)




from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

#-------->You can use Chrome as your choice.
driver = webdriver.Firefox()
# driver = webdriver.Firefox(executable_path("path_of_Firefox_where_
it_is_stored")) # For windows user
driver.get("https://pythonwitheasyway.blogspot.com/")
button = driver.find_element_by_xpath("/html/body/div[3]/div[6]/div[5]
/div[1]/div[4]/div[2]/div[1]/div[1]/div/div[1]/article/div[3]/a")
time.sleep(4) # Wait for 5 min on that page.
button.click()
time.sleep(2)
driver.back() # Back to previous page
time.sleep(2)
driver.forward() # Again to next page.

Comments