mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.08k stars 1.52k forks source link

HTML5 drag and drop does not work #1450

Open Herst opened 5 years ago

Herst commented 5 years ago

System

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

geckodriver.log

whimboo commented 5 years ago

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.

alex-pancho commented 3 years ago

3 years and this one still open? Its need to solve!

satya081 commented 2 years ago

Any update on this issue?

whimboo commented 1 year ago

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.