Challenge - 5 Problems
Parameterization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of parameterized test with multiple data sets
Given the following pytest test function using parameterization, what will be the output when running the test?
Selenium Python
import pytest @pytest.mark.parametrize('input,expected', [(2, 4), (3, 9), (4, 16)]) def test_square(input, expected): assert input * input == expected # What is the test result summary?
Attempts:
2 left
💡 Hint
Check if the assertion matches the expected square values.
✗ Incorrect
Each input is squared and compared to the expected value. All pairs are correct, so all tests pass.
❓ assertion
intermediate2:00remaining
Correct assertion for parameterized Selenium test
You have a Selenium test that checks page titles for multiple URLs using parameterization. Which assertion correctly verifies the page title matches the expected title?
Selenium Python
from selenium import webdriver import pytest @pytest.mark.parametrize('url,expected_title', [ ('https://example.com', 'Example Domain'), ('https://www.python.org', 'Welcome to Python.org') ]) def test_page_title(url, expected_title): driver = webdriver.Chrome() driver.get(url) # Which assertion is correct here? # assert ??? driver.quit()
Attempts:
2 left
💡 Hint
Page title is accessed by driver.title property.
✗ Incorrect
The correct way to check the page title is to compare driver.title with the expected title string.
🔧 Debug
advanced2:00remaining
Identify the error in parameterized Selenium test code
What error will occur when running this parameterized Selenium test code?
Selenium Python
import pytest from selenium import webdriver @pytest.mark.parametrize('url', ['https://example.com', 'https://python.org']) def test_open_page(url): driver = webdriver.Chrome driver.get(url) assert 'Example' in driver.title driver.quit()
Attempts:
2 left
💡 Hint
Check how the webdriver.Chrome is used.
✗ Incorrect
webdriver.Chrome is a class and must be called with parentheses to create an instance. Missing parentheses means driver is assigned the class itself, not an instance, so driver.get() causes AttributeError.
❓ framework
advanced2:00remaining
Best practice for parameterizing Selenium tests with pytest fixtures
Which option shows the best way to combine pytest fixtures and parameterization for Selenium tests to reuse the browser instance efficiently?
Attempts:
2 left
💡 Hint
Think about reusing browser instance to speed up tests.
✗ Incorrect
Using a session-scoped fixture creates the driver once per test session, improving efficiency. Parameterizing tests separately allows running tests with different data using the same driver instance.
🧠 Conceptual
expert2:00remaining
Why parameterize tests in Selenium automation?
What is the main advantage of parameterizing Selenium tests with multiple data sets?
Attempts:
2 left
💡 Hint
Think about how parameterization affects test coverage and code reuse.
✗ Incorrect
Parameterization helps run the same test code with different inputs, reducing duplication and increasing coverage without writing multiple test functions.