【问题标题】:Getting Jasmine timeout error while checking an element is Not Present using Protractor使用量角器检查元素不存在时出现 Jasmine 超时错误
【发布时间】:2017-07-27 16:26:20
【问题描述】:

当我检查元素是否存在时,代码工作正常,如果我检查元素不存在得到 Jasmine 超时。

var fee = $$('[ng-if="paymentDetails.responseObject[0].fee_amount > 0"]');
expect(fee.isPresent()).toBe(false);

错误信息-

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

堆栈: 错误:超时 - 在 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定的超时内未调用异步回调。 堆: 在 ontimeout (timers.js:386:14) 在 tryOnTimeout (timers.js:250:5) 在 Timer.listOnTimeout (timers.js:214:5)

在 Config.js 文件中,我将 jasmine 超时设置为 60 秒

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
    {
        browserName: 'chrome',
        shardTestFiles: true,
        maxInstances: 1,
        chromeOptions: {
            args: [
                '--disable-infobars',
                '--disable-extensions',
                'verbose',
                'log-path=./reports/chromedriver.log'
            ],
            prefs: {
                'profile.password_manager_enabled': false,
                'credentials_enable_service': false,
                'password_manager_enabled': false
            }
        }
    },
    {
        browserName: 'internet explorer',
        platform: 'ANY',
        version: '11'
     }
     ],
     framework: 'jasmine2',
      suites: {
      em2_login: ['e2e/tests/login/login.spec.js']
      } 
      useAllAngular2AppRoots: 'true',
      allScriptsTimeout: 60000,
      getPageTimeout: 60000,

      jasmineNodeOpts: {
      showColors: true,
      displayStacktrace: true,
      displaySpecDuration: true,
      defaultTimeoutInterval: 60000,
      disableChecks: true
      },
      params: {
      siteUrl: ''
       },
      onPrepare: function () {

      jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
      },
      },

我确实尝试过插入 browser.sleep(5000)browser.waitforAngular() 仍然超时。

这是当前状态元素的 HTML 代码-

<tbody>
<!-- ngRepeat: lineItem in paymentDetails.responseObject[0].schedules[0].schedule_line_items track by $index -->
<tr class="ng-scope" ng-repeat="lineItem in paymentDetails.responseObject[0].schedules[0].schedule_line_items track by $index">
<td class="ng-binding">Jul 27, 2017</td>
<td>
<td class="ng-binding">$45.00</td>
<!-- ngIf: paymentDetails.responseObject[0].fee_amount > 0 -->
<td class="ng-binding ng-scope" ng-if="paymentDetails.responseObject[0].fee_amount > 0">$0.90</td>
<!-- end ngIf: paymentDetails.responseObject[0].fee_amount > 0 -->
<td>
<td class="" ng-switch="" on="lineItem.statusString" ng-show="lineItem.statusString" style="">
<td class="ng-binding ng-hide" ng-show="!lineItem.statusString" ng-bind-html="receiptTemplate.ready" style="">Ready</td>
<td class="ng-binding" ng-show="lineItem.authorizationString" ng-bind-html="lineItem.authorizationString" style="">53433 Bogus Gateway: Forced success</td>
<td class="ng-hide" ng-show="!lineItem.authorizationString" style=""/>
<td>
</tr>

谁能帮我解决这个问题?

【问题讨论】:

  • 您能否发布完整的conf.js 文件。谢谢!
  • 已发布完整的 conf.js 文件。

标签: protractor


【解决方案1】:

这段代码对我有用。

var fee = $$('[ng-if="paymentDetails.responseObject[0].fee_amount > 0"]').get(0);
expect(fee.isPresent()).toBe(false);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-15
    • 2016-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-10
    相关资源
    最近更新 更多