首页 > 解决方案 > 在python中的react-beautiful-dnd页面上的ActionChain Drag_and_drop

问题描述

有没有人使用 selenium webdriver ActionChain 在 react-beautiful-dnd 页面上执行拖放操作?我可以使用以下方法在一个示例页面上执行拖放操作,但我无法在 react-beautiful-dnd 页面上使用它。它只是显示“您已将一个项目提升到适当的位置,使用箭头键移动,空格键放下,退出键取消。”

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(desired_capabilities=DesiredCapabilities.CHROME, command_executor='http://localhost:4444/wd/hub')

#drag and drop it does not work
driver.get("https://react-beautiful-dnd.netlify.com/iframe.html?selectedKind=board&selectedStory=simple")
loc = '//div[@class="quote-list__DropZone-sc-1fzhh8p-1 fuOOyc"]'
source_loc = driver.find_elements_by_xpath(loc)[1]
target_loc = driver.find_elements_by_xpath(loc)[2]

#error You have lifted an item in position
Use the arrow keys to move, space bar to drop, and escape to cancel.

#work for no problem
driver.get("http://jqueryui.com/resources/demos/droppable/default.html")
source_loc = driver.find_element_by_xpath('//div[@id="draggable"]')
target_loc = driver.find_element_by_xpath('//div[@id="droppable"]')
act = ActionChains(driver).drag_and_drop(source_loc, target_loc)
act.perform()

标签: pythonpython-3.xselenium-webdriver

解决方案


推荐阅读