0
0
Selenium Pythontesting~10 mins

Find element by link text in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A"Home"
B"Submit"
C"Click here"
D"Login"
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
2fill in blank
medium

Complete 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'
A"About Us"
B"Contact"
C"Services"
D"Help"
Attempts:
3 left
💡 Hint
Common Mistakes
Using partial link text instead of exact
Not calling click() after finding the element
3fill in blank
hard

Fix 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'
A"Click here"
BClick here
C'Click here
DClick_here
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes around the string
Using underscores instead of spaces
Using mismatched quotes
4fill in blank
hard

Fill 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'
A"Learn More"
B"href"
C"src"
D"Click here"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute name like 'src' instead of 'href'
Using partial link text instead of exact
5fill in blank
hard

Fill 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'
A"Sign Up"
BTrue
Cclick
DFalse
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