Python 无法执行拖放操作

Python 无法执行拖放操作,python,selenium,drag-and-drop,Python,Selenium,Drag And Drop,我用selenium创建了一个测试,并用python导出了它。该测试包括将元素拖放到div。当我在python中运行测试时,无法执行拖放。我使用的代码是: source_element = self.driver.find_elements_by_xpath("//*[contains(@id, 'plinkTest')]") dest_element = self.driver.find_elements_by_xpath("//* [@id='tools_dep_jstree_id

我用selenium创建了一个测试,并用python导出了它。该测试包括将元素拖放到div。当我在python中运行测试时,无法执行拖放。我使用的代码是:

source_element =  self.driver.find_elements_by_xpath("//*[contains(@id, 
'plinkTest')]")
 dest_element = self.driver.find_elements_by_xpath("//* 
 [@id='tools_dep_jstree_id']")

actions = ActionChains(self.driver)
actions.move_to_element(source_element).click_and_hold().perform()
actions = ActionChains(self.driver)

actions.move_to_element(dest_element).perform()
actions = ActionChains(self.driver)
actions.move_to_element(dest_element).release().perform()

我得到的错误是“move\u to required a web element”。

find\u elements\u by\u xpath()
将返回列表而非web element

将以下行从通过xpath()查找元素更改为

通过xpath()查找元素


问题是使用按xpath查找元素而不是按xpath查找元素(第一个返回列表,jus打字错误),并且源元素只能通过使用链接文本找到:

source_element = self.driver.find_element_by_partial_link_text('plink')
dest_element = self.driver.find_element_by_xpath("//*[@id='tools_dep_jstree_id']/ul")

actions = ActionChains(self.driver)
actions.move_to_element(source_element).click_and_hold().perform()

time.sleep(2)
actions = ActionChains(self.driver)
actions.move_to_element(dest_element).perform()

actions = ActionChains(self.driver)
actions.move_to_element(dest_element).release().perform()

相关的HTML请?
 source_element =  self.driver.find_element_by_xpath("//*[contains(@id, 
'plinkTest')]")
 dest_element = self.driver.find_element_by_xpath("//* 
 [@id='tools_dep_jstree_id']")
source_element = self.driver.find_element_by_partial_link_text('plink')
dest_element = self.driver.find_element_by_xpath("//*[@id='tools_dep_jstree_id']/ul")

actions = ActionChains(self.driver)
actions.move_to_element(source_element).click_and_hold().perform()

time.sleep(2)
actions = ActionChains(self.driver)
actions.move_to_element(dest_element).perform()

actions = ActionChains(self.driver)
actions.move_to_element(dest_element).release().perform()