【问题标题】:WDIO Javascript Mocha/Chai crashes NPM when expect failsWDIO Javascript Mocha/Chai 在期望失败时使 NPM 崩溃
【发布时间】:2017-12-14 06:46:51
【问题描述】:

运行测试时,it 块正在执行,我得到了这个输出。

我无法理解的是为什么 npm 命令会出现错误退出?

3) GAMETRIBE CELL C WAP DOI - SUCCESS FLOW Webdriver should target and click the subscription CTA:
An element could not be located on the page using the given search parameters ("[class='button']").
running phantomjs
Error: An element could not be located on the page using the given search parameters ("[class='button']").
    at getText() - index.js:312:3


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webdriver_typescript@1.0.0 test-cellc: `node ./node_modules/typescript/lib/tsc.js && node ./node_modules/webdriverio/bin/wdio ./dist/wdio.conf.mcm.js --suite cellcWapDoi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webdriver_typescript@1.0.0 test-cellc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/davidabes/.npm/_logs/2017-12-14T06_44_07_155Z-debug.log

我的测试用例如下所示:

export default function() {
it('Webdriver should target and click the subscription CTA', function() {
    const yesLink = browser.element("[class='button']");
    console.log(yesLink.getText());
    console.log(yesLink.getTagName());
    yesLink.click();
});

【问题讨论】:

  • 只是出于好奇,你为什么不用browser.element('.button') 而不是[class="button"]?
  • 因为它没有找到所需的元素([class='button'])。这是预期的行为。您应该在对其执行任何操作之前添加 browser.waitForVisible() 命令。

标签: webdriver-io


【解决方案1】:

如果有任何测试失败,那么似乎 mocha 退出并显示错误代码 1 ...我只是不记得我在文档中的哪个位置阅读了这个。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-04
    • 1970-01-01
    • 2023-04-10
    • 2023-03-08
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多