哪条线导致这个量角器错误? [英] What line is causing this Protractor error?

查看:11
本文介绍了哪条线导致这个量角器错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

量角器有没有办法在控制台日志中显示错误发生在哪一行?我只是收到这种类型的消息:

Is there a way for Protractor to show in the console log what line the error occurred on? I just get this type of message:

Message:
    Failed: Cannot call method 'click' of undefined
  Stack:
    Error: Failed: Cannot call method 'click' of undefined
        at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:104:16
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
        at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
        at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)

1 spec, 1 failure

很难弄清楚我是否有这么多的点击命令.我正在运行 Protractor 1.8.0.

It's hard to figure out if I have so many click commands. I'm running Protractor 1.8.0.

这是我的 protractor.conf.js :

exports.config = {
  framework: 'jasmine2',

  seleniumAddress: 'http://11.111.1.11:4444/wd/hub',

  multiCapabilities: [{
    'browserName': 'chrome',
    'chromeOptions': {
        args: ['--test-type']
    }
  }],

  specs: ['./tests/my_test/*_spec.js'],

  onPrepare: function(){

      global.EC = protractor.ExpectedConditions;

      browser.manage().window().maximize();

      var jasmineReporters = require('jasmine-reporters');

      jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        filePrefix: 'tests_xmloutput',
        savePath: './test_results_report'
      }));
  },

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

完整的错误信息是:

Failures:
1) test name description
  Message:
    Failed: Cannot call method 'click' of undefined
  Stack:
    Error: Failed: Cannot call method 'click' of undefined
        at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:104:16
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
        at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
        at notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)

1 spec, 1 failure
Finished in 3.206 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

规范文件/测试的内容是:

The content of the spec file/test would be:

HeaderNavigationPartialPage.myAppButton.click();
LeftNavigationPartialPage.myAppToolsLink.ERROR-ON-PURPOSE.click();  
browser.wait(EC.elementToBeClickable(LeftNavigationPartialPage.myAppSearchLink), 10000);
LeftNavigationPartialPage.myAppSearchLink.click();

推荐答案

这是 jasminewd 的相关问题protractor 在后台使用的 项目:

Here is a related issue at jasminewd project that protractor uses under-the-hood:

问题现已修复,jasmine 升级到 >=2.3.1.

The issue is now fixed, with jasmine upgrade to >=2.3.1.

你应该做的是升级protractor>=2.1.0.

What you should do is to upgrade protractor to >=2.1.0.

旧答案:

作为一种解决方法,回到 jasmine 1.x:

As a workaround, get back to jasmine 1.x:

exports.config = {
    framework: 'jasmine',

    ...
}

这篇关于哪条线导致这个量角器错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆