Challenge - 5 Problems
Drag and Drop Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium drag and drop code?
Consider the following Selenium Python code snippet that performs a drag and drop action. What will be printed after execution?
Selenium Python
from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains # Assume driver is already initialized and navigated to the page source = driver.find_element('id', 'drag-source') target = driver.find_element('id', 'drop-target') actions = ActionChains(driver) actions.drag_and_drop(source, target).perform() print('Drag and drop performed')
Attempts:
2 left
💡 Hint
Check if the method drag_and_drop is used correctly with source and target elements.
✗ Incorrect
The code uses the correct Selenium ActionChains method drag_and_drop with valid source and target elements. If elements exist, the action performs and prints the message.
❓ locator
intermediate1:30remaining
Which locator is best for identifying a draggable element?
You want to locate a draggable element on a web page for drag and drop testing. Which locator strategy is best practice?
Attempts:
2 left
💡 Hint
Use the most specific and stable locator possible.
✗ Incorrect
Using an ID selector (#draggable) is the most specific and stable locator compared to class, tag name, or link text for a draggable element.
❓ assertion
advanced1:30remaining
Which assertion correctly verifies a successful drop?
After performing drag and drop, you want to assert that the drop target contains the text 'Dropped!'. Which assertion is correct?
Selenium Python
drop_target = driver.find_element('id', 'drop-target') drop_text = drop_target.text
Attempts:
2 left
💡 Hint
Check Python string methods and assertion syntax.
✗ Incorrect
In Python, to check equality, use '==' operator. The method contains() and equals() do not exist for strings. 'in' checks substring membership but reversed here.
🔧 Debug
advanced2:00remaining
Why does this drag and drop code raise an error?
This Selenium Python code raises an error. Identify the cause.
Selenium Python
actions = ActionChains(driver) actions.drag_and_drop('source', 'target').perform()
Attempts:
2 left
💡 Hint
Check the types of arguments passed to drag_and_drop.
✗ Incorrect
drag_and_drop requires WebElement objects as source and target, not string IDs or names.
❓ framework
expert2:30remaining
Which test framework feature best supports drag and drop tests?
You want to write maintainable drag and drop tests in Selenium Python. Which framework feature helps most?
Attempts:
2 left
💡 Hint
Think about organizing code for readability and reuse.
✗ Incorrect
Page Object Model helps keep locators and actions organized, making drag and drop tests easier to maintain and update.