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

时间:2017-07-19 17:51:09

标签: javascript protractor jasmine-node jasmine2.0

由于我的应用程序的付款状态每次都会根据设置进行更改,因此我希望在报告中发布,对于此测试案例,付款已完成。 这是代码 -

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

请让我知道如何让我的代码更顺序和更好的报告。谢谢!

1 个答案:

答案 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);
    });
});