1

First element html code:

<div class="block ng-scope" ng-repeat="skills in data.primary_skills">
                    <div class="block skillsLineItem" ng-class="{manditorySkillsLineItem:skills.mandatory, skillsLineItem:!skills.mandatory}"> 

 <label title="Testing" class="skill-name col-xs-5 text-overflow-ellipsis ng-binding" ng-click="toggleMandatory(skills)">
                              <!-- ngIf: skills.mandatory -->
                              <!-- ngIf: skills.userdefined -->
                              &nbsp;Testing
                            </label>

Second element Html code

<label title="Test Scripts" class="skill-name col-xs-5 text-overflow-ellipsis ng-binding" ng-click="toggleMandatory(skills)">
                          <!-- ngIf: skills.mandatory -->
                          <!-- ngIf: skills.userdefined -->
                          &nbsp;Test Scripts
                        </label>

In our application multiple elements having same class name and ng-click values so how can i click on multiple elements using same class or ng-click values. I have to click on both elements so please help me.

1 Answer 1

3

You can find all of them and use each():

element.all(by.css("label[ng-click*=toggleMandatory]")).each(function (label) {
    label.click();
});

You can use filter() to filter out only necessary elements:

element.all(by.css("label[ng-click*=toggleMandatory]")).filter(function (label, index) {
    return index <= 5;
}).each(function (label) {
    label.click();
});
Sign up to request clarification or add additional context in comments.

4 Comments

I can't use title because skill name will be generate based on the job description.
@raghavendrat okay, how about now?
Using class or ng-click i have to do so please help me "alecxe".
Yeah its working nicely but it is selecting all the elements, i want to click on only 6 elements ..please help me

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.