geckodriver
geckodriver copied to clipboard
HTML5 drag and drop does not work
System
- Version: geckodriver 0.23.0 (2018-10-04)
- Platform: Linux (but I'm guessing it applies to any)
- Firefox: 65.0b2
- Selenium: 3.141.0 (Python bindings)
Testcase
Testcase opens https://mdn.github.io/dom-examples/drag-and-drop/copy-move-DataTransfer.html (the demo page linked from the MDN page on HTML5 DnD) and tries to interact with it but fails, the dragged element never gets properly dropped.
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
# options = webdriver.chrome.options.Options()
# options.binary_location = "/usr/bin/google-chrome-beta"
# driver = webdriver.Chrome(options=options, service_args=["--verbose", "--log-path=chromedriver.log"])
options = webdriver.firefox.options.Options()
# options.binary = "/home/bob/firefox/firefox"
options.log.level = "trace"
driver = webdriver.Firefox(options=options)
# driver = webdriver.Safari()
# class ActionChains(webdriver.ActionChains):
# def __init__(self, driver):
# super(ActionChains, self).__init__(driver)
# self.w3c_actions.key_action.pause = lambda *a, **k: None
wait = WebDriverWait(driver, 5)
driver.get("https://mdn.github.io/dom-examples/drag-and-drop/copy-move-DataTransfer.html")
wait.until(
EC.title_contains("Using Drag and Drop API to copy and move elements"),
"Page did not load"
)
ActionChains(driver) \
.drag_and_drop(
driver.find_element_by_css_selector("#src_copy"),
driver.find_element_by_css_selector("#dest_copy")
) \
.perform()
wait.until(
EC.presence_of_element_located((By.CSS_SELECTOR, "#dest_copy #newId")),
"1st drag failed"
)
ActionChains(driver) \
.drag_and_drop(
driver.find_element_by_css_selector("#src_move"),
driver.find_element_by_css_selector("#dest_move")
) \
.perform()
wait.until(
EC.presence_of_element_located((By.CSS_SELECTOR, "#dest_copy #src_move")),
"2nd drag failed"
)
Stacktrace
Traceback (most recent call last):
File "test_dnd.py", line 39, in <module>
"1st drag failed"
File "/home/bob/PycharmProjects/Aiuvucta/env/lib/python3.6/site-packages/selenium/webdriver/support/wait.py", line 83, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 1st drag failed
Trace-level log
Thanks for filing this issue. As it looks like this seems to be a problem with Marionette. I appropriately filed https://bugzilla.mozilla.org/show_bug.cgi?id=1515879 to handle that.
3 years and this one still open? Its need to solve!
Any update on this issue?
https://github.com/w3c/webdriver/issues/1488#issuecomment-1474112065 seems to have a (not yet verified) workaround by adding a duration to the pointerMove
action.