0
0
Selenium Pythontesting~10 mins

Find element by name 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 find an element by its name attribute.

Selenium Python
element = driver.find_element_by_[1]("username")
Drag options to blanks, or click blank then click option'
Aname
Bid
Cclass_name
Dtag_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element_by_id instead of find_element_by_name
Using incorrect attribute names
2fill in blank
medium

Complete the code to send text to an input field found by name.

Selenium Python
driver.find_element_by_[1]("email").send_keys("test@example.com")
Drag options to blanks, or click blank then click option'
Aid
Bname
Ccss_selector
Dxpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element_by_id when the element has no id
Forgetting to call send_keys after finding the element
3fill in blank
hard

Fix the error in the code to correctly find an element by name.

Selenium Python
element = driver.find_element_by_[1]("password")
Drag options to blanks, or click blank then click option'
Atag_name
Bid
Cclass_name
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element_by_id instead of find_element_by_name
Using find_element instead of find_element_by_name
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps element names to their text.

Selenium Python
elements = driver.find_elements_by_[1]("item")
texts = {el.get_attribute([2]): el.text for el in elements}
Drag options to blanks, or click blank then click option'
Aname
B"name"
C"id"
Dclass_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'name' in either blank
Not quoting the attribute name string in get_attribute
5fill in blank
hard

Fill all three blanks to find an element by name, check if it is displayed, and assert it is visible.

Selenium Python
element = driver.find_element_by_[1]("submit")
visible = element.is_[2]()
assert visible is [3]
Drag options to blanks, or click blank then click option'
Aname
Bdisplayed
CTrue
Denabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'enabled' instead of 'displayed' for visibility check
Asserting with 'False' instead of 'True'