Is it possible to "click and hold" and element with WebDriver? That is, click an element and not release the click.
To hold down a key simultaneously while another key is being pressed, we use the keyDown() and keyUp() methods. Both these methods accept the modifier key as a parameter. The action of these two methods on a key yields a special functionality of a key. All these methods are a part of Actions class in Selenium.
clickAndHold(webelement).
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()
With WebDriver 'Actions' we can do that:
Actions clkAndHld = new Actions(driver);
clkAndHld.clickAndHold(WebElement).build().perform();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With