raghavendra t raghavendra t - 6 months ago 49
Javascript Question

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

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.

Answer

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