0
0
Selenium Pythontesting~20 mins

Find element by partial link text in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Partial Link Text Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
locator
intermediate
2:00remaining
Locate element using partial link text
You want to find a link on a webpage that contains the text "Learn" anywhere in its visible text. Which Selenium locator will correctly find this element?
Adriver.find_element(By.LINK_TEXT, "Learn")
Bdriver.find_element(By.PARTIAL_LINK_TEXT, "Learn")
Cdriver.find_element(By.PARTIAL_LINK_TEXT, "learn")
Ddriver.find_element(By.CSS_SELECTOR, "a[href*='Learn']")
Attempts:
2 left
💡 Hint
Partial link text matches part of the visible text, case sensitive.
Predict Output
intermediate
2:00remaining
Output of partial link text locator code
Given the following HTML snippet:
<a href='/home'>Home Page</a>
<a href='/learn'>Learn Selenium</a>
<a href='/contact'>Contact Us</a>

What will be the text of the element found by:
element = driver.find_element(By.PARTIAL_LINK_TEXT, "Learn")
print(element.text)
ALearn Selenium
BContact Us
CHome Page
DNoSuchElementException
Attempts:
2 left
💡 Hint
Partial link text matches visible text containing the substring.
assertion
advanced
2:00remaining
Assertion for partial link text element presence
You want to write a test assertion to verify that a link containing the text "Docs" is present on the page using Selenium in Python. Which assertion is correct?
Selenium Python
element = driver.find_element(By.PARTIAL_LINK_TEXT, "Docs")
Aassert element == None
Bassert element.text == "Docs"
Cassert element.is_displayed()
Dassert element.get_attribute('href') == "Docs"
Attempts:
2 left
💡 Hint
Check if the element is visible, not exact text or attribute.
🔧 Debug
advanced
2:00remaining
Debugging partial link text locator failure
You wrote this code to find a link containing "Help":
element = driver.find_element(By.PARTIAL_LINK_TEXT, "help")

But it raises NoSuchElementException even though the page has a link with text "Help Center". What is the most likely cause?
AThe element is inside an iframe and not accessible
BThe link text "Help Center" is too long for partial link text
CThe locator By.PARTIAL_LINK_TEXT does not work with spaces
DPartial link text matching is case sensitive, "help" does not match "Help"
Attempts:
2 left
💡 Hint
Check case sensitivity of partial link text.
framework
expert
2:00remaining
Best practice for waiting for partial link text element
In a Selenium test, you want to wait up to 10 seconds for a link containing "Start" to appear before interacting with it. Which code snippet correctly implements this wait using WebDriverWait and partial link text locator?
Aelement = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Start")))
Belement = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "a:contains('Start')")))
Celement = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "start")))
Delement = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.LINK_TEXT, "Start")))
Attempts:
2 left
💡 Hint
Use correct locator and expected condition for presence.