gpt4 book ai didi

error-handling - 哪一行导致此 Protractor 错误?

转载 作者:行者123 更新时间:2023-12-04 06:41:32 25 4
gpt4 key购买 nike

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

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。

这是我的 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

规范文件/测试的内容将是:
HeaderNavigationPartialPage.myAppButton.click();
LeftNavigationPartialPage.myAppToolsLink.ERROR-ON-PURPOSE.click();
browser.wait(EC.elementToBeClickable(LeftNavigationPartialPage.myAppSearchLink), 10000);
LeftNavigationPartialPage.myAppSearchLink.click();

最佳答案

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

  • Stack traces for Jasmine2 don't include asynchronous events

  • 该问题现已修复,使用 jasmine升级到 >=2.3.1 .

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

    旧答案:

    作为解决方法,请返回 jasmine 1.x :
    exports.config = {
    framework: 'jasmine',

    ...
    }

    关于error-handling - 哪一行导致此 Protractor 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29000389/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com