Complete the code to import the parameterized decorator from the correct module.
from [1] import parameterized class TestLogin: @parameterized.expand([ ("user1", "pass1"), ("user2", "pass2") ]) def test_login(self, username, password): pass
The parameterized decorator is imported from the parameterized module to enable parameterized tests.
Complete the code to use the parameterized decorator to run the test with multiple username and password pairs.
@parameterized.expand([
("user1", "pass1"),
("user2", [1])
])
def test_login(self, username, password):
passThe second tuple should have the password "pass2" to match the example pairs for parameterized testing.
Fix the error in the test method signature to accept parameters from the parameterized decorator.
@parameterized.expand([
("user1", "pass1"),
("user2", "pass2")
])
def test_login(self, [1]):
passThe test method must accept the parameters username and password to receive the values from the parameterized decorator.
Fill both blanks to assert the page title after login using parameterized username and password.
def test_login(self, username, password): self.driver.get("http://example.com/login") self.driver.find_element_by_id("username").send_keys(username) self.driver.find_element_by_id("password").send_keys(password) self.driver.find_element_by_id("submit").click() assert self.driver.title [1] [2]
The assertion checks if the page title equals "Dashboard" after login.
Fill all three blanks to create a parameterized test that checks login with multiple credentials and asserts the welcome message.
from parameterized import parameterized class TestLogin: @parameterized.expand([ ("user1", "pass1", [1]), ("user2", "pass2", [2]) ]) def test_login(self, username, password, expected_message): self.driver.get("http://example.com/login") self.driver.find_element_by_id("username").send_keys(username) self.driver.find_element_by_id("password").send_keys(password) self.driver.find_element_by_id("submit").click() message = self.driver.find_element_by_id("welcome").text assert message == [3]
The test uses parameterized tuples with expected welcome messages. The assertion compares the actual message to the expected_message parameter.