0
0
Selenium Pythontesting~10 mins

Find element by partial 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 an element by partial link text.

Selenium Python
element = driver.find_element_by_[1]("Learn")
Drag options to blanks, or click blank then click option'
Aclass_name
Bid
Cpartial_link_text
Dtag_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' or 'class_name' instead of 'partial_link_text' to find a link by text.
2fill in blank
medium

Complete the code to click on a link found by partial link text.

Selenium Python
driver.find_element_by_[1]("Contact").[2]()
Drag options to blanks, or click blank then click option'
Asend_keys
Bclick
Cpartial_link_text
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using send_keys instead of click to activate the link.
3fill in blank
hard

Fix the error in the code to correctly find an element by partial link text.

Selenium Python
element = driver.find_element_by_[1]("About Us")
Drag options to blanks, or click blank then click option'
Apartial_link_text
Blink_text
Cxpath
Dcss_selector
Attempts:
3 left
💡 Hint
Common Mistakes
Using link_text when partial matching is needed.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that finds elements by partial link text and stores their texts.

Selenium Python
links_text = {el.text: el for el in driver.find_elements_by_[1]("[2]")}
Drag options to blanks, or click blank then click option'
Apartial_link_text
BContact
CAbout
Dlink_text
Attempts:
3 left
💡 Hint
Common Mistakes
Using link_text instead of partial_link_text for partial matches.
Using full link text instead of partial text.
5fill in blank
hard

Fill all three blanks to filter links by partial link text and check if their text length is greater than 5.

Selenium Python
filtered_links = [el for el in driver.find_elements_by_[1]("[2]") if len(el.text) [3] 5]
Drag options to blanks, or click blank then click option'
Apartial_link_text
BContact
C>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using link_text instead of partial_link_text.
Using wrong comparison operators like '<' or '==' instead of '>'.