Complete the code to define a test function using pytest.
def [1](): assert 2 + 2 == 4
The test function must start with test_ so pytest can recognize it.
Complete the code to import the Selenium WebDriver for Chrome.
from selenium.webdriver import [1]
To automate Chrome browser, import Chrome from selenium.webdriver.
Fix the error in the test class definition for pytest.
class [1]: def test_example(self): assert True
Pytest recognizes test classes only if their names start with Test.
Fill both blanks to create a Selenium test that opens a page and checks the title.
from selenium import webdriver class TestPageTitle: def test_title(self): driver = webdriver.[1]() driver.get('https://example.com') assert driver.title [2] 'Example Domain' driver.quit()
Use webdriver.Chrome() to open Chrome and == to assert the title matches exactly.
Fill all three blanks to create a pytest test function that finds an element by ID and asserts its text.
from selenium import webdriver from selenium.webdriver.common.by import [1] def test_element_text(): driver = webdriver.Chrome() driver.get('https://example.com') element = driver.find_element([2], 'example-id') assert element.text [3] 'Example Domain' driver.quit()
Import By to specify locator type, use By.ID to find by ID, and == to assert text equality.
