How to click on particular button if multiple buttons are having same classes in protractor?

Issue

Html code

<button type="button" class="btn btn-default btn-sm pull-right" ng-click="move(1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-right"></i></button>

In angular protractor, is there any way to click on particular button if multiple buttons are having same classes. Please help me out on this.

Solution

You can click on the button by :-

By Id :

 element(by.id('id')).click().then(function() {
 });

By xpath :

element(by.xpath('//div[@id="ui-datepicker-div"]//a[@title="Next"]')).click(); // whatever your xpath is 

Answered By – Hmahwish

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published