Challenge - 5 Problems
Tag Name Locator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ locator
intermediate2:00remaining
Locate the first
Which Selenium Python code snippet correctly finds the first
Attempts:
2 left
💡 Hint
Use the correct Selenium method and locator strategy for tag name.
✗ Incorrect
The correct method to find an element by tag name in Selenium Python is find_element with By.TAG_NAME and the tag name string.
❓ assertion
intermediate2:00remaining
Assert the text of the first
element
Given the code below, which assertion correctly checks that the first
element's text is exactly 'Welcome'?
Selenium Python
element = driver.find_element(By.TAG_NAME, 'h1')
text = element.textAttempts:
2 left
💡 Hint
Use Python string equality to check exact match.
✗ Incorrect
In Python, to check exact string equality, use '==' operator. Methods like contains or equals do not exist on strings.
❓ Predict Output
advanced2:00remaining
Output of finding multiple elements by tag name
What is the output of the following code snippet if the page contains exactly 3 elements?
Selenium Python
elements = driver.find_elements(By.TAG_NAME, 'li') print(len(elements))
Attempts:
2 left
💡 Hint
find_elements returns a list of matching elements.
✗ Incorrect
find_elements returns a list of all matching elements. len() returns the count. Since there are 3 elements, output is 3.
🔧 Debug
advanced2:00remaining
Identify the error in finding element by tag name
What error will the following code raise if no
Selenium Python
element = driver.find_element(By.TAG_NAME, 'footer')Attempts:
2 left
💡 Hint
find_element raises an exception if no element is found.
✗ Incorrect
If find_element does not find any matching element, it raises NoSuchElementException in Selenium.
❓ framework
expert3:00remaining
Best practice for waiting for an element by tag name
Which Selenium Python code snippet correctly waits up to 10 seconds for the first
Attempts:
2 left
💡 Hint
Use explicit waits with expected conditions for reliable waiting.
✗ Incorrect
Explicit wait with WebDriverWait and expected_conditions waits up to the timeout for the element to appear, avoiding unnecessary delays or errors.