0
0
Selenium Pythontesting~10 mins

Why form handling is common in testing in Selenium Python - Test Your Understanding

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

Complete the code to locate the username input field by its name attribute.

Selenium Python
username_input = driver.find_element(By.[1], 'username')
Drag options to blanks, or click blank then click option'
ATAG_NAME
BID
CCLASS_NAME
DNAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' when the element does not have an id attribute.
Using 'class_name' which may select multiple elements.
2fill in blank
medium

Complete the code to enter text into the password field.

Selenium Python
password_input = driver.find_element(By.ID, 'password')
password_input.[1]('mysecret')
Drag options to blanks, or click blank then click option'
Asend_keys
Bsubmit
Cclear
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' which only clicks the element.
Using 'clear' which erases text but does not type.
3fill in blank
hard

Fix the error in the code to submit the form by clicking the submit button.

Selenium Python
submit_button = driver.find_element(By.CSS_SELECTOR, 'button[type=[1]]')
submit_button.click()
Drag options to blanks, or click blank then click option'
A'button'
B'submit'
C'input'
D'reset'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'button' as type which is invalid.
Using 'reset' which resets the form instead of submitting.
4fill in blank
hard

Fill both blanks to check if the form submission was successful by verifying the success message text.

Selenium Python
success_message = driver.find_element(By.CLASS_NAME, '[1]')
assert '[2]' in success_message.text
Drag options to blanks, or click blank then click option'
Asuccess
BWelcome
Calert
DError
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alert' which may be for warnings.
Checking for 'Error' which indicates failure.
5fill in blank
hard

Fill all three blanks to create a dictionary of form data and fill the username field using Selenium.

Selenium Python
form_data = {'username': '[1]', 'password': '[2]'}
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys(form_data['[3]'])
Drag options to blanks, or click blank then click option'
Auser1
Bpassword
Cusername
Dpass123
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values in the dictionary.
Using wrong keys when accessing dictionary values.