我正在使用Protractor在Angular JS应用程序(带有Node.js后端)上运行一些e2e测试。
当发生错误时,有没有办法缩短调用堆栈,以便只出现我自己的代码?
这是量角器的输出:
Message:
Failed: Invalid locator
Stack:
TypeError: Invalid locator
at Object.check [as checkedLocator] (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/by.js:267:9)
at WebDriver.findElements (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:919:18)
at /Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/built/element.js:160:44
at ManagedPromise.invokeCallback_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27)
at /Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)Error
at ElementArrayFinder.applyAction_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/built/element.js:397:27)
at ElementArrayFinder._this.(anonymous function) [as click] (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/built/element.js:100:30)
at ElementFinder.(anonymous function) [as click] (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/built/element.js:728:22)
at Object.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:21:48)
at /Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/jasminewd2/index.js:94:23
at new ManagedPromise (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1082:7)
at controlFlowExecute (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/jasminewd2/index.js:80:18)
at TaskQueue.execute_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25)
From: Task: Run it("from home to cookie policy using footer links") in control flow
at Object.<anonymous> (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/jasminewd2/index.js:79:14)
at /Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/jasminewd2/index.js:16:5
at ManagedPromise.invokeCallback_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/Documents/Work/blah/node_modules/gulp-angular-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27)
From asynchronous test:
Error
at Suite.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:19:9)
at /Documents/Work/blah/tests/e2e/nav_spec.js:4:5
at Object.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:38:2)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
8 specs, 1 failure
Finished in 19.842 seconds
[19:05:23] I/launcher - 0 instance(s) of WebDriver still running
[19:05:23] I/launcher - chrome #01 failed 1 test(s)
[19:05:23] I/launcher - overall: 1 failed spec(s)
[19:05:23] E/launcher - Process exited with error code 1
[19:05:23] 'e2e' errored after 22 s
[19:05:23] Error in plugin 'gulp-angular-protractor'
相反,我更愿意看到:
Message:
Failed: Invalid locator
Stack:
TypeError: Invalid locator
at Object.check [as checkedLocator]
at Object.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:21:48)
From: Task: Run it("from here to there using footer links") in control flow
From asynchronous test:
Error
at Suite.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:19:9)
at /Documents/Work/blah/tests/e2e/nav_spec.js:4:5
at Object.<anonymous> (/Documents/Work/blah/tests/e2e/nav_spec.js:38:2)
8 specs, 1 failure
Finished in 19.842 seconds
[19:05:23] I/launcher - 0 instance(s) of WebDriver still running
[19:05:23] I/launcher - chrome #01 failed 1 test(s)
[19:05:23] I/launcher - overall: 1 failed spec(s)
[19:05:23] E/launcher - Process exited with error code 1
[19:05:23] 'e2e' errored after 22 s
[19:05:23] Error in plugin 'gulp-angular-protractor'