0
0
Selenium Pythontesting~10 mins

Finding multiple elements 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 all buttons on the page using Selenium.

Selenium Python
buttons = driver.find_elements_by_[1]('button')
Drag options to blanks, or click blank then click option'
Aclass_name
Bid
Cname
Dtag_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element instead of find_elements returns only one element.
Using 'id' or 'name' will not find multiple buttons by tag.
2fill in blank
medium

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

Selenium Python
items = driver.find_elements_by_[1]('item')
Drag options to blanks, or click blank then click option'
Acss_selector
Bclass_name
Cid
Dtag_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'class_name' will not find multiple elements.
Using 'tag_name' will find elements by tag, not class.
3fill in blank
hard

Fix the error in the code to find all links with tag 'a'.

Selenium Python
links = driver.find_elements_by_[1]('a')
Drag options to blanks, or click blank then click option'
Atag_name
Bid
Cname
Dclass_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class_name' or 'id' will not find all links by tag.
Using find_element instead of find_elements returns only one element.
4fill in blank
hard

Fill both blanks to find all input elements with type 'checkbox'.

Selenium Python
checkboxes = driver.find_elements_by_[1]('input[type=[2]]')
Drag options to blanks, or click blank then click option'
Acss_selector
Bclass_name
Ccheckbox
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class_name' instead of 'css_selector' will not work with attribute selectors.
Using 'id' or 'checkbox' as a method name is invalid.
5fill in blank
hard

Fill all three blanks to create a dictionary of element texts keyed by their ids for all divs with class 'card'.

Selenium Python
cards = driver.find_elements_by_[1]('div.card')
texts_by_id = {card.get_attribute([2]): card.text for card in cards if card.get_attribute([3]) is not None}
Drag options to blanks, or click blank then click option'
Acss_selector
B'id'
Dclass_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class_name' instead of 'css_selector' will not select by combined tag and class.
Forgetting to check if 'id' attribute is not None causes errors.