由于我的应用程序的付款状态每次都会根据设置进行更改,因此我希望在报告中发布,对于此测试案例,付款已完成。 这是代码 -
<td class="" ng-switch="" on="lineItem.statusString" ng-show="lineItem.statusString" style="">
<!-- ngSwitchWhen: Unknown -->
<!-- ngSwitchWhen: Initiated -->
<!-- ngSwitchWhen: Validating -->
<!-- ngSwitchWhen: Processing -->
<!-- ngSwitchWhen: Failed -->
<!-- ngSwitchWhen: Cancelled -->
<!-- ngSwitchWhen: Refunded -->
<!-- ngSwitchWhen: Ready -->
<!-- ngSwitchWhen: Completed -->
<div class="ng-scope" ng-switch-when="Completed" style="">
<!-- end ngSwitchWhen: -->
<!-- ngSwitchWhen: Skipped -->
<!-- ngSwitchWhen: Errored -->
</td>
<td class="ng-binding ng-hide" ng-show="!lineItem.statusString" ng-bind-html="receiptTemplate.ready" style="">Ready</td>
<div class="ng-scope" ng-switch-when="Completed" style="">
<img src="/images/success.gif"/>
<span class="ng-binding" ng-bind-html="receiptTemplate.complete">Completed</span>
</div>
<!-- end ngSwitchWhen: -->
<!-- ngSwitchWhen: Skipped -->
<!-- ngSwitchWhen: Errored -->
</td>
以下是我尝试使用Protractor的代码段
element(by.css('[ng-bind-html="receiptTemplate.ready"]')).isPresent().then(function () {
browser.sleep(5000);
(element.all(by.binding('receiptTemplate.skip'))).isPresent().then(function (skip) {
if (skip) {
console.log('Payment is Skipped');
}
});
element.all(by.binding('receiptTemplate.complete')).isPresent().then(function (complete) {
if (complete) {
console.log('Payment is Completed');
}
});
});
请让我知道如何让我的代码更顺序和更好的报告。谢谢!
答案 0 :(得分:0)
如果所有状态都在span
且一次只能有一种状态,您可以尝试:
element(by.css('[ng-bind-html="receiptTemplate.ready"]')).isPresent().then(function () {
browser.sleep(5000);
element.all(by.css('span')).getText().then(function (currentText) {
console.log(currentText);
});
});