0

We are migrating from Protractor to using SeleniumWebdriver for Node.js: https://www.npmjs.com/package/selenium-webdriver

Using Protractor for AngularJS, we can do:

element.all(by.repeater('r in roles')).first().element(by.css('.update-role')).click();

I am trying to figure out what an equivalent call might look like using require('selenium-webdriver'), anybody have an idea?

Specifically, the by.repeater() call, is what I don't know an equivalent for.

2
  • 1
    just use css with attribute selectors to grab by repeater attribute. idk what the webdriver syntax would be but [ng-repeat="r in roles"] is the gist
    – Gunderson
    Commented Jan 3, 2018 at 0:27
  • Post some example HTML of the elements that would find?
    – JeffC
    Commented Jan 3, 2018 at 2:45

1 Answer 1

1

this is fairly simple. you need to find all the elements, and treat them as similar elements.

element.all(by.css('[ng-repeat="r in roles"]')).then(function(eachRepeat){
    for(var i=0;i<eachRepeat.length; i++){
        // do something else with the repeat. where eachRepeat[0] is the first element
       console.log(eachRepeat[i]);
    }
});

you could also add a condition for the element number. or element's text.

element.all(by.css('[ng-repeat="r in roles"]')).getText().then(function(eachRepeat){
        for(var i=0;i<eachRepeat.length; i++){
           console.log(eachRepeat[i]);
           if(eachRepeat[i] === 'someSpecificText'){
                eachRepeat[i].click();
           }else{
           console.log('error');
           }
        }
    });

Let me know if you have any questions on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.