Selenium + Python · Lesson 39 of 43
Module 39: Cross-Browser Testing
Your task
Implement normalize_browser(browser_str):
Write it in the editor, then press Check answer (Ctrl + Enter).
from selenium import webdriver
def create_driver(browser_name: str = "chrome"):
b = browser_name.lower().strip()
if b == "firefox":
return webdriver.Firefox()
elif b == "edge":
return webdriver.Edge()
else:
return webdriver.Chrome()Your users use different browsers. In this lesson, you will create a flexible browser factory that instantiates Chrome, Firefox, or Edge based on configuration. Let's build a cross-browser factory!
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.
Yes, Microsoft Edge is available for Linux and macOS and is fully supported by Selenium.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___