在Python的react-beautiful-dnd页面上具有ActionChain Drag_and_drop

时间:2018-12-18 23:13:02

标签: python python-3.x selenium-webdriver

有人使用硒Web驱动程序ActionChain在react-beautiful-dnd页面上执行拖放吗?我可以使用以下命令在一个示例页面上执行drag_and_drop,但无法在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()

0 个答案:

没有答案