Skip to main content
 首页 » 编程设计

python之拖放不适用于 Selenium Python

2025年02月15日1098°冷暖

我想用 selenium python 实现一个简单的拖放。我正在使用 Chrome WebDriver,下面是我的代码。什么都没发生。非常感谢任何帮助。

from selenium.webdriver.common.by import By 
from selenium.webdriver.common.keys import Keys 
from selenium import webdriver 
from selenium.common import exceptions 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.support.ui import Select 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver import ActionChains 
driver = webdriver.Chrome() 
driver.get("http://html5demos.com/drag") 
dragElement=driver.find_element_by_id("one") 
dropElement=driver.find_element_by_id("bin") 
 
action_chains = ActionChains(driver) 
action_chains.drag_and_drop(dragElement, dropElement).perform() 

请您参考如下方法:

您现在可以尝试使用我在上面提到的解决方法。 我还把它打包成一个 Python 包,所以它很容易使用。

您可以使用 pip install seletools 安装包

用法示例是 here .