Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to type 'hello' into the input box.
Selenium Python
input_box = driver.find_element(By.ID, 'username') input_box.[1]('hello')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'send_keys' to type text.
Trying to use 'clear' to type text.
Using 'submit' which submits the form instead of typing.
✗ Incorrect
The send_keys method types text into an input field.
2fill in blank
mediumComplete the code to find the password input by its name and type 'mypassword'.
Selenium Python
password_input = driver.find_element(By.[1], 'password') password_input.send_keys('mypassword')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
By.ID when the element is identified by name.Using
By.CLASS_NAME or By.TAG_NAME incorrectly.✗ Incorrect
The By.NAME locator finds elements by their name attribute.
3fill in blank
hardFix the error in the code to type 'admin' into the input field found by CSS selector.
Selenium Python
input_field = driver.find_element(By.CSS_SELECTOR, [1]) input_field.send_keys('admin')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the selector string.
Using the selector without '#' for id.
✗ Incorrect
CSS selectors must be strings with quotes. Single or double quotes work, but quotes must be included.
4fill in blank
hardFill both blanks to clear the input field and then type 'test123'.
Selenium Python
input_element = driver.find_element(By.ID, 'input1') input_element.[1]() input_element.[2]('test123')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Typing without clearing old text.
Using 'click' instead of 'clear' or 'send_keys'.
✗ Incorrect
First clear the input with clear(), then type text with send_keys().
5fill in blank
hardFill all three blanks to find the input by XPath, clear it, and type 'hello world'.
Selenium Python
input_box = driver.find_element(By.[1], [2]) input_box.[3]() input_box.send_keys('hello world')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
By.ID with an XPath string.Not clearing the input before typing.
✗ Incorrect
Use By.XPATH with the XPath string, then clear the input before typing.