node-使用async / await在堆栈跟踪中缺少某些文件引用

时间:2017-11-23 01:55:14

标签: node.js jasmine protractor jasmine-spec-reporter

Stacktrace没有对量角器触发错误的实际文件名的引用。

Spec报告配置:

jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true,}}));

示例规范:

it('Protractor stacktrce issue', async () =>
 { 
   const helper = new SearchHelper(); 
   await helper.doSearch('test'); 
});

搜索-helper.ts:

async doSearch(text) { 
  await browser.get('http://google.com'); 
  await browser.wait(EC.visibilityOf(element(by.name('q1'))), 10000, 'No Element found'); 
  await element(by.name('q1')).click(); //invalid locator 
}

1。使用browser.wait堆栈跟踪

✗ Protractor stack trace issue 
-Failed: No Element found Wait timed out after 10007ms
Wait timed out after 10007ms 
at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5) 
at TimeoutError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:238:5) 
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2107:17 
at process._tickCallback (internal/process/next_tick.js:109:7) 

From asynchronous test: Error at Suite.<anonymous> (/Users/e2e/sample-spec.ts:27:3) 
at Object.<anonymous> (/Users/e2e/sample-spec.ts:15:1) 
at Module._compile (module.js:570:32) at Module.m._compile (/Users/node_modules/ts-node/src/index.ts:392:23) 
at Module._extensions..js (module.js:579:10) 
at Object.require.extensions.(anonymous function) [as .ts] (/Users/node_modules/ts-node/src/index.ts:395:12)

2。如果我们注释browser.wait语句,那么stacktrace是

✗ Protractor stack trace issue 
 Failed: No element found using locator: By(css selector, *[name="q1"]) 
 at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5) 
 at NoSuchElementError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:168:5) 
 at elementArrayFinder.getWebElements.then (/usr/local/lib/node_modules/protractor/lib/element.ts:851:17) 
 at process._tickCallback (internal/process/next_tick.js:109:7)Error 
 at ElementArrayFinder.applyAction_ (/usr/local/lib/node_modules/protractor/lib/element.ts:482:23) 
 at ElementArrayFinder.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/lib/element.ts:96:21) 
 at ElementFinder.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/lib/element.ts:873:14) 
 at SearchHelper.<anonymous> (/Users/e2e/search-helper.ts:14:34) **at step (/Users/e2e/search-helper.ts:32:23) 
 at Object.next (/Users/e2e/search-heper.ts:13:53) 
 at fulfilled (/Users/e2e/search-helper.ts:4:58)** 
 at process._tickCallback (internal/process/next_tick.js:109:7) 

 From asynchronous test: Error at Suite.<anonymous> (/Users/e2e/sample-spec.ts:27:3) 
 at Object.<anonymous> (/Users/e2e/sample-spec.ts:15:1) at Module._compile (module.js:570:32) 
 at Module.m._compile (/Users/node_modules/ts-node/src/index.ts:392:23) 
 at Module._extensions..js (module.js:579:10) 
 at Object.require.extensions.(anonymous function) [as .ts] (/Users/node_modules/ts-node/src/index.ts:395:12)

观察第二个堆栈跟踪,它有对search-helper文件的引用,但它不在第一个堆栈跟踪中。在堆栈跟踪中使用此引用进行调试非常重要。

0 个答案:

没有答案