Reputation: 33
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
Upvotes: 0
Views: 3998
Reputation: 33
nothing seems to work above but i tried this in the end and it worked:
browser.$('//div[@data-test="touch-area"]').moveTo(0,0)
browser.buttonDown(0);
browser.pause(3000)
Upvotes: 0
Reputation: 97
You can test it with buttonDown on w3school page.
browser.url("https://www.w3schools.com/css/css3_buttons.asp");
browser.buttonDown("//button[text()='Default Button']");
browser.pause(5000);
browser.buttonUp("//button[text()='Default Button']");
However, this is for webdriverio v4. It says this is deprecated soon, but maybe V5 has the same api.
Upvotes: 1
Reputation: 2509
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!
Upvotes: 2