我无法使用Python WebDriver绑定进行拖放。我与谷歌Chrome和Firefox在Mac OS X的工作有一个线程在这里如果有人有类似的问题。
我尝试使用ActionsChains
:
from selenium import webdriver
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
actionChains = ActionChains(driver)
actionChains.drag_and_drop(source, target).perform()
您是否设法使Python WebDriver拖放工作?
为了给出更新的答案,我已经验证了它现在确实可以在Mac上运行。
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Firefox()
driver.get("your.site.with.dragndrop.functionality.com")
source_element = driver.find_element_by_name('your element to drag')
dest_element = driver.find_element_by_name('element to drag to')
ActionChains(driver).drag_and_drop(source_element, dest_element).perform()