Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find a link by its exact text.
Selenium Python
element = driver.find_element_by_link_text([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using partial text instead of exact text
Forgetting quotes around the text
Using wrong method like find_element_by_id
✗ Incorrect
The method find_element_by_link_text requires the exact visible text of the link. "Click here" matches the link text we want to find.
2fill in blank
mediumComplete the code to click on the link found by its text.
Selenium Python
driver.find_element_by_link_text([1]).click() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using partial link text instead of exact
Not calling click() after finding the element
✗ Incorrect
To click the link with text "About Us", we pass that exact string to find_element_by_link_text and then call click().
3fill in blank
hardFix the error in the code to find a link by its text.
Selenium Python
element = driver.find_element_by_link_text([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes around the string
Using underscores instead of spaces
Using mismatched quotes
✗ Incorrect
The link text must be a string literal with matching quotes. Option A correctly uses double quotes around the text.
4fill in blank
hardFill both blanks to find a link by text and get its href attribute.
Selenium Python
link = driver.find_element_by_link_text([1]) href = link.get_attribute([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute name like 'src' instead of 'href'
Using partial link text instead of exact
✗ Incorrect
We find the link by its exact text "Learn More" and then get its 'href' attribute to know the URL it points to.
5fill in blank
hardFill all three blanks to find a link by text, check if it is displayed, and then click it.
Selenium Python
link = driver.find_element_by_link_text([1]) if link.is_displayed() == [2]: link.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'False' instead of 'True' in the condition
Forgetting to call click() as a method with parentheses
Using partial link text
✗ Incorrect
We find the link with text "Sign Up", check if it is visible (True), and then call click() to activate it.