Reputation: 117
I want to double an element in protractor; i am using as below but it is not doing a double click, instead a single click.
browser.actions().doubleClick(element(by.xpath("//*[@id='optionsTaggingList']/div[1]/div[1]/div[1]/table/tbody/tr/td[1]")).getAttribute(1)).perform()
Is there something am i missing?
Upvotes: 1
Views: 2927
Reputation: 51
I tried all the above ,It didnot help, Try this
Please use sleep(1000) await browser.actions().click(ele.getWebElement()).perform(); await browser.actions().mouseMove(ele).mouseMove(ele).doubleClick().perform();
Upvotes: 0
Reputation: 1
After trying multiple ways to double click an element, I finally came up with a solution:
async performDoubleClick(elemetToBeClicked: ElementFinder) {
await browser.actions().mouseMove(elemetToBeClicked).mouseMove(elemetToBeClicked)
.mouseUp().mouseDown().click().mouseDown().mouseUp().click().doubleClick().perform();
return;
}
You can also check if the following works for you:
async performDoubleClick(elemetToBeClicked: ElementFinder) {
await browser.actions().mouseMove(elemetToBeClicked).mouseMove(elemetToBeClicked).doubleClick().perform();
}
Other events are required to be stringed together because when you double click then these events are also being called in the same sequence. You can verify it from https://unixpapa.com/js/testmouse.html or any other mouse event checker.
Upvotes: 0
Reputation: 117
The below code worked:
var ele = element(by.xpath("//*[@id='optionsTaggingList']//td[1]"))
browser.actions().click(ele).click(ele).perform();
Upvotes: 1
Reputation: 283
just use:
browser.actions().doubleClick(element(by.xpath("//*[@id='optionsTaggingList']/div[1]/div[1]/div[1]/table/tbody/tr/td[1]"))).perform();
But you should use a more simple selector, not so long.
Upvotes: 2