Search code examples
javascriptwebdriver-io

How to click and hold using the webdriverio


I am trying to figure out how to click and hold using webdriverio. In selenium it is like this:

WebElement elementToInteractWith = driver.findElement(By.id("myElement"));

Actions holdClick = new Actions(driver);

holdClick.clickAndHold(elementToInteractWith).perform();

//wait for however long you need to hold

holdClick.release().perform();

However i am not sure how to do that in webdriver io but cannot find anything on the documentation


Solution

  • I believe you can try this.

    https://webdriver.io/docs/api/jsonwp.html#buttondown

    You can have a pause after this for the time you need to and then buttonup should follow.

    Cheers!