Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to pause the test and let the tester solve the CAPTCHA manually.
Selenium Python
input('Please solve the CAPTCHA and press Enter to continue...') # [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sleep() only waits a fixed time and does not wait for user action.
Using pause or wait are not valid Python functions.
✗ Incorrect
Using the input() function pauses the test execution and waits for the tester to press Enter after solving the CAPTCHA manually.
2fill in blank
mediumComplete the code to detect if a CAPTCHA element is present on the page.
Selenium Python
captcha_present = len(driver.find_elements(By.ID, '[1]')) > 0
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or uncommon element IDs.
Using find_element instead of find_elements which throws error if not found.
✗ Incorrect
The CAPTCHA element usually has the ID 'captcha'. Checking if elements with this ID exist helps detect CAPTCHA presence.
3fill in blank
hardFix the error in the code that tries to click the CAPTCHA checkbox but fails if not found.
Selenium Python
try: driver.find_element(By.ID, '[1]').click() except NoSuchElementException: print('CAPTCHA checkbox not found')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic 'captcha' ID that does not match the checkbox.
Not handling exceptions causing test to crash.
✗ Incorrect
The correct ID for the CAPTCHA checkbox is 'captcha_checkbox'. Using this ID avoids NoSuchElementException.
4fill in blank
hardFill both blanks to create a wait that pauses until the CAPTCHA iframe is visible.
Selenium Python
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.[1], '[2]')))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FRAME instead of TAG_NAME causes errors.
Using ID or class_name without correct values.
✗ Incorrect
To wait for an iframe element, use By.TAG_NAME with 'iframe' as the locator value.
5fill in blank
hardFill all three blanks to switch to the CAPTCHA iframe, solve it manually, then switch back.
Selenium Python
driver.switch_to.[1](driver.find_element(By.[2], '[3]')) input('Solve CAPTCHA and press Enter...') driver.switch_to.default_content()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using switch_to.frames (plural) instead of frame (singular).
Using incorrect locator types like id with wrong values.
✗ Incorrect
Use switch_to.frame() with By.TAG_NAME and 'iframe' to switch into the CAPTCHA frame before manual solving.