Complete the code to import the Selenium WebDriver module.
from selenium import [1]
The correct import is webdriver from the selenium package to use Selenium WebDriver.
Complete the code to define the constructor method for the page class.
class LoginPage: def [1](self, driver): self.driver = driver
The constructor method in Python classes is named __init__. It initializes the object.
Fix the error in the locator definition for the username field.
from selenium.webdriver.common.by import By class LoginPage: def __init__(self, driver): self.driver = driver self.username_input = (By.[1], "username")
By.The By class uses uppercase constants like ID to specify locator types.
Fill in the blank to define a method that clicks the login button.
class LoginPage: def __init__(self, driver): self.driver = driver self.login_button = (By.ID, "loginBtn") def click_login(self): self.driver.find_element([1]).click()
To click the login button, use self.driver.find_element(*self.login_button).click(). The asterisk unpacks the locator tuple.
Fill all three blanks to complete a method that enters text into the username field.
class LoginPage: def __init__(self, driver): self.driver = driver self.username_input = (By.ID, "username") def enter_username(self, username): element = self.driver.find_element([1]) element.[2]([3])
click instead of send_keys to enter text.The method finds the username input by unpacking the locator tuple, then calls send_keys with the username argument to enter text.