Open/Get URL using Selenium for Python

Open or Get URL

To open a given URL in the browser window using Selenium for Python, call get() method on the driver object and pass the URL as argument to get() method.

driver.get('https://pythonexamples.org/')

Example

  1. Initialise Chrome Web Driver object as driver.
  2. Get the URL https://pythonexamples.org/ using web driver object.

Python Program

from selenium.webdriver.chrome.service import Service
from selenium import webdriver

service = Service(executable_path="/usr/local/bin/chromedriver")
with webdriver.Chrome(service=service) as driver:
    driver.get('https://pythonexamples.org/')

Screenshot

Open URL using Selenium for Python

Summary

In this Python Selenium Tutorial, we learned how to load a specific URL using driver.get() method.

Related Tutorials

Quiz on Selenium

Q1. Which of the following is not a popular web driver used in Selenium Python?

Not answered

Q2. What is the method used to find web elements in Selenium Python?

Not answered

Q3. What is the method used to interact with web elements in Selenium Python?

Not answered

Q4. What is the method used to navigate back to the previous page in Selenium Python?

Not answered

Q5. What is the method used to select a value from a drop-down list in Selenium Python?

Not answered
Code copied to clipboard successfully 👍