0
0
Selenium Pythontesting~20 mins

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

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Link Text Locator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
locator
intermediate
2:00remaining
Locate element using exact link text
Which Selenium Python code snippet correctly finds a link with the exact text "Home Page"?
Adriver.find_element(By.LINK_TEXT, "Home Page")
Bdriver.find_element(By.PARTIAL_LINK_TEXT, "Home Page")
Cdriver.find_element(By.ID, "Home Page")
Ddriver.find_element(By.CLASS_NAME, "Home Page")
Attempts:
2 left
💡 Hint
Use the locator that matches the full visible text of the link.
Predict Output
intermediate
2:00remaining
Output of finding link by partial text
What will be the output of this Selenium Python code if the page contains a link with text "Contact Us Today"?
Selenium Python
element = driver.find_element(By.PARTIAL_LINK_TEXT, "Contact")
print(element.text)
A"Us Today"
B"Contact"
C"Contact Us Today"
DNoSuchElementException
Attempts:
2 left
💡 Hint
Partial link text matches any part of the link's visible text.
assertion
advanced
2:00remaining
Valid assertion for link text presence
Which assertion correctly verifies that a link with text "About Us" is present on the page using Selenium Python?
Selenium Python
element = driver.find_element(By.LINK_TEXT, "About Us")
Aassert element.text == "About Us"
Bassert element.get_attribute("href") == "About Us"
Cassert element.is_displayed() == False
Dassert element.text != "About Us"
Attempts:
2 left
💡 Hint
Check the visible text of the found element.
🔧 Debug
advanced
2:00remaining
Identify error in link text locator code
What error will this Selenium Python code raise?
driver.find_element(By.LINKTEXT, "Services")
Selenium Python
driver.find_element(By.LINKTEXT, "Services")
ASyntaxError
BNoSuchElementException
CTypeError
DAttributeError: module 'selenium.webdriver.common.by' has no attribute 'LINKTEXT'
Attempts:
2 left
💡 Hint
Check the spelling of the locator constant.
framework
expert
2:00remaining
Best practice for waiting for link by text
In Selenium Python, which code snippet correctly waits up to 10 seconds for a link with text "Login" to be clickable before clicking it?
Adriver.find_element(By.LINK_TEXT, "Login").click()
BWebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Login"))).click()
C
time.sleep(10)
driver.find_element(By.LINK_TEXT, "Login").click()
DWebDriverWait(driver, 10).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Login"))).click()
Attempts:
2 left
💡 Hint
Use explicit waits with expected conditions for clickable elements.