0
0
Selenium Pythontesting~10 mins

Clearing input fields in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aclear
Bclick
Csend_keys
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using send_keys instead of clear to remove text.
Trying to click the input field to clear it.
2fill in blank
medium

Complete 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'
ANAME
BTAG_NAME
CID
DCLASS_NAME
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.
3fill in blank
hard

Fix 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'
AclearInput()
Bclear
Cclear_text()
Dclear()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses after method name.
Using incorrect method names like clear_text or clearInput.
4fill in blank
hard

Fill 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'
ACSS_SELECTOR
BXPATH
C#user-input
D.input-class
Attempts:
3 left
💡 Hint
Common Mistakes
Using XPATH instead of CSS_SELECTOR.
Using class selector when id selector is needed.
5fill in blank
hard

Fill 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'
AXPATH
B//input[@name='password']
Cclear
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of clear() to empty input.
Using incorrect locator type for XPath.