Randomblue
Randomblue

Reputation: 116403

"click and hold" with WebDriver

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

Answers (3)

Furious Duck
Furious Duck

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

sree
sree

Reputation: 19

WebElement nameofwebelement = driver.find(By.xpath,id,name("")); 
Actions builder = new Actions(driver);   
builder.clickAndHold(nameofwebelement).perform();

Upvotes: 0

Surya
Surya

Reputation: 4536

With WebDriver 'Actions' we can do that:

Actions clkAndHld = new Actions(driver);
clkAndHld.clickAndHold(WebElement).build().perform();

Upvotes: 4

Related Questions