I'm trying to drag and drop an element using ActionChains. But can't get it to work.
Environment:
So there are two drag and drop methods:
drag_and_drop
drag_and_drop_by_offset
When I try with offset it works but when I use regular drag_and_drop it doesn't.
driver = webdriver.Chrome()
driver.get("https://demoqa.com/")
sortable_button = driver.find_element(
By.CSS_SELECTOR, "aside.widget:nth-of-type(1) li:nth-of-type(1)")
sortable_button.click()
items = driver.find_elements(By.CSS_SELECTOR, "#sortable li")
actions = ActionChains(driver)
actions.drag_and_drop_by_offset(items[0], 0, 200).perform()
# actions.drag_and_drop(items[0], items[4]).perform()
time.sleep(5)
driver.close()
It appears that drag_and_drop method doesn't work with HTML5
Here's a reference that provides a workaround and a confirmation by selenium dev that indeed it doesn't work on HTML5
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/3604
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments