Kevin
Kevin

Reputation: 95

Double click on a button with Protractor

Snippet Code:

<div class="add create_Amenities" hs-gesture="{handler:showPopup, param:menu_group}" ng-if="showPlus(menu_group,$index)">

Desired action: Double click on a button which would proceed to the next page.

I enter the below command, my browser comes up but I have to manually click on the “Add” button one more time to proceed to the next page. The command does one click

Question: How can I make this command a double clicked on the (Add) button. I tried it different ways but I was not successful. Any ideas?

browser.driver.actions().mouseMove(element(by.css('.add.create_Amenities'))).perform();

element.all(by.css('.add.create_Amenities')).then(function (elm) {

    elm[0].click();
});

Upvotes: 2

Views: 3525

Answers (3)

Kevin
Kevin

Reputation: 95

I used multiples helps from online community and I made the Double click working for me. The key for me to work was to have 1 sec of delay between each click. If I remove the delay, the double click does not occur.

var AddButton = element(by.css(".add.create_Amenities" ));
browser.actions().mouseDown(AddButton).mouseUp().perform();
browser.sleep(1000);    
browser.actions().mouseMove(AddButton).click().perform();

Upvotes: 0

Nick
Nick

Reputation: 504

Try this:

browser.actions().doubleClick(browser.element(by.css('.add.create_Amenities'))).perform();

Upvotes: 0

Xotabu4
Xotabu4

Reputation: 3091

let addButton = $('.add.create_Amenities');
addButton.click();
addButton.click();

Or if you prefer actions:

let addButton = $('.add.create_Amenities');

browser.actions()
    .click(addButton)
    .click(addButton)
.perform();

// Didn't tried this:
browser.actions().doubleClick(addButton).perform();

Upvotes: 3

Related Questions