如何使用量角器检查班级名称的变化

use*_*804 2 javascript angularjs angularjs-e2e protractor e2e-testing

在执行特定操作后需要测试类名的更改.在我的应用程序中,按下按钮后,页脚进度条显示进度.

页脚代码中唯一的变化是类名更改.以下是代码段:

之前:

<i class="fa fa-check-circle pull-left" ng-class="{processComplete : sent}"></i>
Run Code Online (Sandbox Code Playgroud)

完成后:

<i class="fa fa-check-circle pull-left processComplete" ng-class="{processComplete : sent}"></i>
Run Code Online (Sandbox Code Playgroud)

如何使用量角器测试类名的变化?

ale*_*cxe 12

您可以检查是否存在具有processComplete类的元素:

expect(element(by.css('.processComplete')).isPresent()).toBe(true);
Run Code Online (Sandbox Code Playgroud)

或者,您可以检查特定元素是否具有processComplete类:

expect(element(by.css('i.fa.fa-check-circle')).getAttribute('class')).not.toMatch('processComplete');

// perform some action

expect(element(by.css('i.fa.fa-check-circle')).getAttribute('class')).toMatch('processComplete');
Run Code Online (Sandbox Code Playgroud)