One of the most basic things you can do using Selenium is to navigate to a given link, traverse back and then again go back to the same page again.
It also gives you specific methods to refresh or re-load a page, when working.
Let us see the methods which help us in navigating to a specific URL and help perform basic browser functions.
import unittest from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions class toolsqa(unittest.TestCase): def setUp(self): self.driver=webdriver.Firefox() def test_filldetails(self): driver=self.driver driver.maximize_window() driver.get('http://www.toolsqa.com') driver.implicitly_wait(30) tt1=driver.find_element_by_link_text('ABOUT') tt1.click() WebDriverWait(driver,20).until(expected_conditions.title_contains('About ')) driver.back() driver.forward() WebDriverWait(driver,20).until(expected_conditions.title_contains('About ')) driver.back() driver.refresh() def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
The back( )
method gives you the ability to go back to the previous URL. refresh ( )
method is used to refresh a web page again- it’s just like using the F5 key from keyboard.
forward( )
method gives you the ability to go forward to the webpage, from which you came back.
Thanks for this helps
LikeLike