是否可以使用WebDriver“点击并按住”元素?也就是说,单击一个元素而不释放该单击。
答案 0 :(得分:5)
实际上,对于Python Webdriver API(根据标签)它是Action Chains
Doc是here
from selenium.webdriver.common.action_chains import ActionChains
element = driver.find_element_by_xpath(xpath)
def click_and_hold(driver, element):
ActionChains(driver).click_and_hold(element).perform()
答案 1 :(得分:2)
使用WebDriver“动作”我们可以做到:
Actions clkAndHld = new Actions(driver);
clkAndHld.clickAndHold(WebElement).build().perform();
答案 2 :(得分:0)
WebElement nameofwebelement = driver.find(By.xpath,id,name(""));
Actions builder = new Actions(driver);
builder.clickAndHold(nameofwebelement).perform();