How to click on calendar icon using class in angul

2019-04-13 01:39发布

问题:

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 protractor angular automation, I am trying to click on calendar icon using class but am not able to click. Using ng-click I can click on the icon but I have to do using class. Please help me, I am new to angular protractor.

回答1:

The problem is that the classes this button has a "layout-oriented" and it's not a good idea to rely on them. But, if you insist:

element(by.css("button.btn.btn-default.btn-sm.pull-right"));

Probably, the most reliable and readable locator in this case (given what is given) is ng-click:

element(by.css("button[ng-click*=move]"));