Complete the code to open a browser using Selenium.
from selenium import webdriver browser = webdriver.[1]() browser.get('https://example.com')
The webdriver.Firefox() command opens a Firefox browser controlled by Selenium.
Complete the code to find an element by its ID.
element = browser.find_element_by_[1]('submit-button')
To find an element by its ID attribute, use find_element_by_id.
Fix the error in the code to click a button.
button = browser.find_element_by_id('login') button.[1]()
The click() method simulates a mouse click on the button element.
Fill both blanks to wait until an element is visible before clicking.
from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC wait = WebDriverWait(browser, 10) element = wait.until(EC.[1]((By.[2], 'submit'))) element.click()
Use visibility_of_element_located to wait until the element is visible, and By.ID to locate by ID.
Fill all three blanks to write a test that opens a browser, navigates, and asserts the page title.
from selenium import webdriver browser = webdriver.[1]() browser.get('https://example.com') assert browser.title [2] 'Example Domain' browser.[3]()
The test opens Firefox, checks the page title equals 'Example Domain', then closes the browser with quit().
