kavitha
kavitha

Reputation: 117

Protractor + double click an element?

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

Answers (4)

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

Aishwarya Vatsa
Aishwarya Vatsa

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

kavitha
kavitha

Reputation: 117

The below code worked:

var ele = element(by.xpath("//*[@id='optionsTaggingList']//td[1]"))   
browser.actions().click(ele).click(ele).perform();

Upvotes: 1

Bob Bai
Bob Bai

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

Related Questions