Your ultimate guide

Browser Navigation Commands



Navigation Commands:
    Navigation Commands are used to navigate window base actions in the browser.
            

1. get("URL"): Get method will navigate to a web page given by the URL.
    Example: driver.get("https://testingcolleges.blogspot.com")

2. back(): It does the same operation as clicking on the back button (←) of any browser.
    Example: driver.back()

3. forward(): It does the same operation as clicking on the forward button (→) of any browser.
    Example: driver.forward()

4. refresh(): To refresh the current web page.
    Example: driver.refresh()


Example Program for Browser Navigation Commands:
  1. import time
  2. from selenium import webdriver

  3. driver = webdriver.Chrome()
  4. driver.get("https://www.google.com/")
  5. driver.get("https://www.facebook.com/")

  6. driver.back()
  7. driver.forward()
  8. time.sleep(2)
  9. driver.refresh()
  10. time.sleep(2)
  11. driver.quite()
OUTPUT:
    


No comments:

Post a Comment