Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find the first <button> element on the page.
Selenium Python
button = driver.find_element(By.[1], "button")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.ID or By.CLASS_NAME instead of By.TAG_NAME.
Forgetting to import By from selenium.webdriver.common.by.
✗ Incorrect
To find an element by its tag name, use By.TAG_NAME in Selenium.
2fill in blank
mediumComplete the code to find all <div> elements on the page.
Selenium Python
divs = driver.find_elements(By.[1], "div")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element instead of find_elements to get multiple elements.
Using wrong locator type like CLASS_NAME for tag name search.
✗ Incorrect
Use find_elements with By.TAG_NAME to get all elements with a specific tag.
3fill in blank
hardFix the error in the code to find the <h1> element by tag name.
Selenium Python
header = driver.find_element(By.[1], "h1")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.CLASS_NAME or By.ID when searching by tag name.
Typos in the locator string.
✗ Incorrect
The correct locator for tag name is By.TAG_NAME, not CLASS_NAME or others.
4fill in blank
hardFill both blanks to find all <li> elements and get the text of the first one.
Selenium Python
items = driver.find_elements(By.[1], "li") first_text = items[[2]].text
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 instead of 0 to get the first element.
Using wrong locator like CLASS_NAME for tag name search.
✗ Incorrect
Use By.TAG_NAME to find elements by tag, and index 0 to get the first item.
5fill in blank
hardFill all three blanks to find the first <a> element, get its href attribute, and check it contains 'http'.
Selenium Python
link = driver.find_element(By.[1], "a") href = link.get_attribute([2]) assert [3] in href
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'src' instead of 'href' for link attribute.
Checking for 'src' or wrong substring in href.
Using wrong locator instead of TAG_NAME.
✗ Incorrect
Find by tag name 'a', get 'href' attribute, and check if 'http' is in the href string.