我有一个案例需要使用Selenium webdriver和Python拖放元素。
我尝试使用Selenium的try {
$dbh = new PDO('mysql:host=127.0.0.1;dbname=PHP_PDO', "root", "root", array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
} catch(PDOException $e) {
die("FATAL ERROR OCCURED");
}
$stmt = $dbh->prepare("SELECT realname FROM users WHERE name = :name" );
$stmt->bindParam(":name", $name);
$name = "mivuckovaca"; // NOT IN DATA BASE
类,代码有点像这样:
ActionChains
我得到的错误是:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
source = ("//span[text()='user1']", Selector.XPATH)
target = ("//span[text()='user2']", Selector.XPATH)
acs = ActionChains(webdriver_api)
change = acs.drag_and_drop(source, target)
change.perform()
答案 0 :(得分:0)
source
和target
需要WebElement
个实例:
source = webdriver_api.find_element_by_xpath("//span[text()='user1']")
target = webdriver_api.find_element_by_xpath("//span[text()='user2']")
acs = ActionChains(webdriver_api)
change = acs.drag_and_drop(source, target)
change.perform()