Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to clear the input field using Selenium.
Selenium Python
input_element = driver.find_element(By.ID, "username") input_element.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using send_keys instead of clear to remove text.
Trying to click the input field to clear it.
✗ Incorrect
The clear() method removes any text from the input field.
2fill in blank
mediumComplete the code to find the input field by its name attribute and clear it.
Selenium Python
input_field = driver.find_element(By.[1], "email") input_field.clear()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ID instead of NAME when the element has no ID.
Using CLASS_NAME which looks for CSS classes.
✗ Incorrect
The NAME locator finds elements by their name attribute.
3fill in blank
hardFix the error in the code to clear the input field correctly.
Selenium Python
search_box = driver.find_element(By.ID, "search") search_box.[1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses after method name.
Using incorrect method names like clear_text or clearInput.
✗ Incorrect
The clear() method must be called with parentheses to execute it.
4fill in blank
hardFill both blanks to clear the input field found by CSS selector.
Selenium Python
input_field = driver.find_element(By.[1], "[2]") input_field.clear()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using XPATH instead of CSS_SELECTOR.
Using class selector when id selector is needed.
✗ Incorrect
Use CSS_SELECTOR to find by CSS and #user-input to select element with id 'user-input'.
5fill in blank
hardFill all three blanks to clear the input field found by XPath and verify it is empty.
Selenium Python
input_el = driver.find_element(By.[1], "[2]") input_el.[3]() assert input_el.get_attribute('value') == ''
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of clear() to empty input.
Using incorrect locator type for XPath.
✗ Incorrect
Use XPATH locator with the XPath string, then call clear() to empty the field.