Challenge - 5 Problems
WebDriver Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium WebDriver setup code?
Consider the following Python code snippet that sets up a Chrome WebDriver and opens a webpage. What will be printed after execution?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service service = Service(executable_path='/path/to/chromedriver') driver = webdriver.Chrome(service=service) driver.get('https://example.com') print(driver.title) driver.quit()
Attempts:
2 left
💡 Hint
The driver.title returns the title of the current page loaded by the browser.
✗ Incorrect
The code opens 'https://example.com' in Chrome and prints the page title, which is 'Example Domain'.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies the page title after WebDriver opens a page?
You want to check that the page title is exactly 'Welcome Page' after opening a URL with Selenium WebDriver in Python. Which assertion is correct?
Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service service = Service(executable_path='/path/to/chromedriver') driver = webdriver.Chrome(service=service) driver.get('https://example.com/welcome') # Which assertion below is correct?
Attempts:
2 left
💡 Hint
The page title is accessed by driver.title, not current_url or page_source.
✗ Incorrect
To verify the page title, use assert driver.title == 'Welcome Page'. Other options check wrong properties.
🔧 Debug
advanced2:30remaining
Why does this GeckoDriver setup code raise an error?
This Python code tries to start Firefox WebDriver but raises an error. Identify the cause.
Selenium Python
from selenium import webdriver from selenium.webdriver.firefox.service import Service service = Service('/path/to/geckodriver') driver = webdriver.Firefox(service=service) driver.get('https://example.com') driver.quit()
Attempts:
2 left
💡 Hint
Check if the geckodriver executable path is valid and accessible.
✗ Incorrect
If geckodriver path is wrong or lacks execute permission, WebDriver raises an error on startup.
❓ locator
advanced1:30remaining
Which locator strategy is best for stable element selection in Selenium?
You want to select a button element that has a unique id 'submit-btn' on a webpage. Which locator is best practice for stability and speed?
Attempts:
2 left
💡 Hint
Using id locator is usually fastest and most reliable if id is unique.
✗ Incorrect
Locating by id is preferred for unique elements because it is fast and less brittle than xpath or css selectors.
❓ framework
expert3:00remaining
What is the correct way to initialize ChromeDriver with options in Selenium Python?
You want to start ChromeDriver with headless mode enabled and disable GPU usage. Which code snippet correctly sets this up?
Attempts:
2 left
💡 Hint
Options must be created and passed to the driver constructor before starting the browser.
✗ Incorrect
Option D correctly creates Options, adds arguments, creates Service, and passes both to Chrome constructor.