如何在量角器中报告已过帐的付款已完成或跳过或失败

How to report posted payment is completed or skipped or failed in protractor

由于我的应用程序的付款状态每次都会根据设置发生变化,因此我想在一份报告中发布该测试用例的付款已完成。 这是代码-

<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');
                }
            });
        });

请告诉我如何使我的代码更有顺序性和更好的报告。谢谢!

如果所有状态都在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);
    });
});