Selenium + Python · Lesson 15 of 43

0/43 done

Module 15: WebDriver

15. WebDriver Navigation & Browser Control in Python

15 minlesson

Your task

Implement navigate_and_maximize(driver, target_url):

  1. If driver is not None:
    • driver.maximize_window()
    • driver.get(target_url)

Write it in the editor, then press Check answer (Ctrl + Enter).

Core WebDriver Commands in Python

python
from selenium import webdriver

driver = webdriver.Chrome()
driver.maximize_window()

# Navigation:
driver.get("https://targetqa.com")
driver.get("https://targetqa.com/courses")
driver.back()
driver.forward()
driver.refresh()

# Page Properties:
print("Current URL:", driver.current_url)
print("Title:", driver.title)

Key Takeaways & Walkthrough Summary

WebDriver in Python offers an intuitive API for navigating URLs, manipulating browser windows, and inspecting page properties. In this lesson, you will master get(), title, current_url, back(), forward(), and window maximizing. Let's master WebDriver methods!

Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

Is driver.title a method or a property in Python?

In Python, driver.title and driver.current_url are properties (no parentheses needed), unlike driver.getTitle() in Java.

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Python
Skip