Reputation: 116403
Is it possible to "click and hold" and element with WebDriver? That is, click an element and not release the click.
Upvotes: 6
Views: 12641
Reputation: 2019
Actually, for Python Webdriver API (according to tags) it's Action Chains
Doc is 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()
Upvotes: 8
Reputation: 19
WebElement nameofwebelement = driver.find(By.xpath,id,name(""));
Actions builder = new Actions(driver);
builder.clickAndHold(nameofwebelement).perform();
Upvotes: 0
Reputation: 4536
With WebDriver 'Actions' we can do that:
Actions clkAndHld = new Actions(driver);
clkAndHld.clickAndHold(WebElement).build().perform();
Upvotes: 4