Skip to content Skip to sidebar Skip to footer

Protractor: Ctrl Click

I am trying to select multiple elements on my page using ctrl click on successive elements. This functionality works fine when done manually, but I am having some troubles with its

Solution 1:

The problem is, you are executing the actions sequence for each loop by calling perform() method. Instead, you need to chain all-action sequence in the loop and then execute it at last. Try the below example,

this.selectElements = function (names) {
    var actionSequence = browser.actions().keyDown(protractor.Key.CONTROL);
    for(var i = 0; i < names.length; i++){
        var parentElement = element(by.xpath('//div[@aria-label="select group ' + names[i] + '"]'));
        actionSequence = actionSequence.mouseMove(parentElement).click();
    }
    actionSequence.perform();
}

Post a Comment for "Protractor: Ctrl Click"