0
0
Selenium Pythontesting~10 mins

Find element by class 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 class name.

Selenium Python
element = driver.find_element_by_[1]("button-primary")
Drag options to blanks, or click blank then click option'
Aname
Bid
Ctag_name
Dclass_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'class_name' when searching by class.
Using 'tag_name' which looks for HTML tags, not classes.
2fill in blank
medium

Complete the code to find all elements with the class name 'item'.

Selenium Python
elements = driver.find_elements_by_[1]("item")
Drag options to blanks, or click blank then click option'
Aclass_name
Bid
Ccss_selector
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element_by_class_name which returns only one element.
Using 'css_selector' without proper syntax.
3fill in blank
hard

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

Selenium Python
element = driver.find_element_by_[1]("btn-primary")
Drag options to blanks, or click blank then click option'
Aclass_name
Bclassname
CclassName
Dclass
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'classname' without underscore.
Using camelCase like 'className'.
4fill in blank
hard

Fill both blanks to find all elements with class 'active' and click the first one.

Selenium Python
elements = driver.find_elements_by_[1]("active")
elements[[2]].click()
Drag options to blanks, or click blank then click option'
Aclass_name
Bid
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'class_name'.
Using index 1 instead of 0 for the first element.
5fill in blank
hard

Fill all three blanks to find an element by class name, get its text, and assert it equals 'Submit'.

Selenium Python
element = driver.find_element_by_[1]("submit-btn")
text = element.[2]
assert text [3] "Submit"
Drag options to blanks, or click blank then click option'
Aclass_name
Btext
C==
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'text' to get the element's text.
Using '=' instead of '==' in the assertion.