0
0
Selenium Pythontesting~10 mins

Drag and drop 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 import the correct Selenium class for drag and drop.

Selenium Python
from selenium.webdriver import [1]
Drag options to blanks, or click blank then click option'
ABy
BWebDriverWait
CActionChains
DKeys
Attempts:
3 left
💡 Hint
Common Mistakes
Importing By or Keys instead of ActionChains.
2fill in blank
medium

Complete the code to locate the draggable element by its ID.

Selenium Python
draggable = driver.find_element([1], "draggable")
Drag options to blanks, or click blank then click option'
ABy.ID
BBy.TAG_NAME
CBy.CLASS_NAME
DBy.NAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.CLASS_NAME or By.NAME instead of By.ID.
3fill in blank
hard

Fix the error in the drag and drop action method call.

Selenium Python
actions = ActionChains(driver)
actions.[1](draggable, droppable).perform()
Drag options to blanks, or click blank then click option'
Adragdrop_perform
Bdragdrop
Cdragdrop_action
Ddrag_and_drop
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like dragdrop or dragdrop_action.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps element text to its attribute.

Selenium Python
result = {elem.text: elem.get_attribute([1]) for elem in elements if elem.text [2] ''}
Drag options to blanks, or click blank then click option'
A"id"
B!=
C==
D"class"
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of != in the condition.
Using wrong attribute names.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary from elements with text length greater than 3.

Selenium Python
filtered = {elem.[1]: elem.get_attribute([2]) for elem in elements if len(elem.[3]) > 3}
Drag options to blanks, or click blank then click option'
Atext
B"data-value"
Dtag_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using tag_name instead of text.
Using wrong attribute names.