Is navigate method available in Selenium Webdriver with Python?


The navigate method is not available in Selenium webdriver with Python.

In order to navigate to a page, we can use the get method and pass the URL of the page that we want to launch as a parameter.

In this method the webdriver waits till the webpage is completely loaded prior transferring the control to the next step in the test case. If the page that we are trying to load, has multiple AJAX calls after loading, then the webdriver becomes unaware when the page will ultimately load.

We can use the different wait methods in synchronization to handle such a scenario. Also, once a page is navigated, we can verify its URL, with the help of the current_url method.

Syntax

driver.get("https://www.tutorialspoint.com/index.htm");
s = driver.current_url

Example

from selenium import webdriver
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\chromedriver.exe")
#implicit wait
driver.implicitly_wait(0.5)
#maximize browser
driver.maximize_window()
#navigate a page
driver.get("https://www.tutorialspoint.com/index.htm")
#obtain current URL
print("Page Url:")
print(driver.current_url)
#navigate another page
driver.get("https://www.tutorialspoint.com/about/about_careers.htm")
#obtain current URL
print("Second Page Url:")
print(driver.current_url)
#browser quit
driver.quit()

Output

Updated on: 06-Apr-2021

455 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements