0
0
Selenium Pythontesting~20 mins

Drag and drop in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Drag and Drop Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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')
ATypeError because drag_and_drop requires different arguments
BNo output, code raises NoSuchElementException
CSyntaxError due to wrong method usage
DDrag and drop performed
Attempts:
2 left
💡 Hint
Check if the method drag_and_drop is used correctly with source and target elements.
locator
intermediate
1: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?
Adriver.find_element('css selector', '#draggable')
Bdriver.find_element('xpath', '//*[@class="draggable"]')
Cdriver.find_element('tag name', 'div')
Ddriver.find_element('link text', 'Drag me')
Attempts:
2 left
💡 Hint
Use the most specific and stable locator possible.
assertion
advanced
1: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
Aassert drop_text == 'Dropped!'
Bassert drop_text.contains('Dropped!')
Cassert drop_text.equals('Dropped!')
Dassert drop_text in 'Dropped!'
Attempts:
2 left
💡 Hint
Check Python string methods and assertion syntax.
🔧 Debug
advanced
2: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()
AActionChains requires a context manager to work
Bperform() must be called before drag_and_drop
CThe arguments to drag_and_drop must be WebElement objects, not strings
Ddrag_and_drop method is deprecated and removed
Attempts:
2 left
💡 Hint
Check the types of arguments passed to drag_and_drop.
framework
expert
2: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?
AUsing unittest's setUpClass to run drag and drop once
BPage Object Model to separate element locators and actions
CUsing pytest fixtures to skip drag and drop tests conditionally
DUsing raw Selenium calls in test methods without abstraction
Attempts:
2 left
💡 Hint
Think about organizing code for readability and reuse.