0
0
Selenium Pythontesting~10 mins

Typing text (send_keys) 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 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'
Aclick
Bsubmit
Cclear
Dsend_keys
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.
2fill in blank
medium

Complete 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'
ACLASS_NAME
BID
CNAME
DTAG_NAME
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.
3fill in blank
hard

Fix 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'
A"#user"
B'#user'
C'user'
D"user"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the selector string.
Using the selector without '#' for id.
4fill in blank
hard

Fill 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'
Aclear
Bsend_keys
Cclick
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Typing without clearing old text.
Using 'click' instead of 'clear' or 'send_keys'.
5fill in blank
hard

Fill 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'
AXPATH
B"//input[@name='search']"
Cclear
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.ID with an XPath string.
Not clearing the input before typing.