Webdriver.IO收到:“ npm ERR!测试失败。有关更多详细信息,请参见上文。”但看不到错误

时间:2019-01-06 13:14:19

标签: javascript selenium-webdriver webdriver-io

我创建了一个简单的测试,可以验证特定站点中面包屑的出现次数为2:

该站点是:https://theculturetrip.com/europe/united-kingdom/england/london/before-you-go/

2个面包屑(蓝色圆圈): breadcrumbs_screenshot

我的测试(“ [itemprop =“ item”]“是面包屑按钮CSS选择器)

it.only('Upper display shows the breadcrumbs', function () {
    let breadcrumbsAppearancesNumber = $$('[itemprop="item"]').length;
    expect(breadcrumbsAppearancesNumber).to.equal(2);
});

对于2来说效果很好。

但是,当我插入3时只是出于测试目的。

it.only('Upper display shows the breadcrumbs', function () {
    let breadcrumbsAppearancesNumber = $$('[itemprop="item"]').length;
    expect(breadcrumbsAppearancesNumber).to.equal(3);
});

它显然失败了,输出:“ npm ERR!测试失败。更多信息请参见上文。”

但是,当我在上方滚动时,没有看到任何错误消息可以向我提供有关失败原因的更多信息...

它显示:

Stdout:

2019-01-06T11:35:15.971Z INFO wdio-cli:Launcher: Run onPrepare hook

2019-01-06T11:35:19.200Z INFO wdio-local-runner: Start worker 0-0 with arg: --spec=tests/InnerArticleTest.js

[0-0] 2019-01-06T11:35:19.579Z INFO wdio-local-runner: Run worker command: run

[0-0] 2019-01-06T11:35:19.749Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session

[0-0] 2019-01-06T11:35:19.749Z INFO webdriver: DATA { capabilities:

   { alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },

  desiredCapabilities: { browserName: 'chrome' } }

[0-0] 2019-01-06T11:35:22.427Z INFO webdriver: COMMAND navigateTo("https://theculturetrip.com/europe/united-kingdom/england/london/before-you-go/")

[0-0] 2019-01-06T11:35:22.428Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/url

[0-0] 2019-01-06T11:35:22.428Z INFO webdriver: DATA { url:

   'https://theculturetrip.com/europe/united-kingdom/england/london/before-you-go/' }

[0-0] 2019-01-06T11:35:28.394Z INFO webdriver: COMMAND findElement("css selector", "[class*="LayoutWrapper"]")

[0-0] 2019-01-06T11:35:28.394Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/element

[0-0] 2019-01-06T11:35:28.394Z INFO webdriver: DATA { using: 'css selector', value: '[class*="LayoutWrapper"]' }

[0-0] 2019-01-06T11:35:28.417Z INFO webdriver: RESULT { ELEMENT: '0.5487788910074598-1' }

[0-0] 2019-01-06T11:35:28.439Z INFO webdriver: COMMAND isElementDisplayed("0.5487788910074598-1")

[0-0] 2019-01-06T11:35:28.439Z INFO webdriver: [GET] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/element/0.5487788910074598-1/displayed

[0-0] 2019-01-06T11:35:28.455Z INFO webdriver: RESULT true

[0-0] 2019-01-06T11:35:28.456Z INFO webdriver: COMMAND findElement("css selector", "[class*="_Icon-"]")

[0-0] 2019-01-06T11:35:28.456Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/element

[0-0] 2019-01-06T11:35:28.456Z INFO webdriver: DATA { using: 'css selector', value: '[class*="_Icon-"]' }

[0-0] 2019-01-06T11:35:28.471Z INFO webdriver: RESULT { ELEMENT: '0.5487788910074598-2' }

[0-0] 2019-01-06T11:35:28.473Z INFO webdriver: COMMAND elementClick("0.5487788910074598-2")

[0-0] 2019-01-06T11:35:28.473Z INFO webdriver: COMMAND elementClick("0.5487788910074598-2")

[0-0] 2019-01-06T11:35:28.473Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/element/0.5487788910074598-2/click

[0-0] 2019-01-06T11:35:28.528Z INFO webdriver: COMMAND findElements("css selector", "[itemprop="item"]")

[0-0] 2019-01-06T11:35:28.528Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592/elements

[0-0] 2019-01-06T11:35:28.528Z INFO webdriver: DATA { using: 'css selector', value: '[itemprop="item"]' }

[0-0] 2019-01-06T11:35:28.543Z INFO webdriver: RESULT [ { ELEMENT: '0.5487788910074598-3' },

  { ELEMENT: '0.5487788910074598-4' } ]

[0-0] 2019-01-06T11:35:28.556Z INFO webdriver: COMMAND deleteSession()

[0-0] 2019-01-06T11:35:28.556Z INFO webdriver: [DELETE] http://127.0.0.1:4444/wd/hub/session/d7e2b630ea4d1841e919ec800890b592

2019-01-06T11:35:28.788Z DEBUG wdio-local-runner: Runner 0-0 finished with exit code 1



Test Suites:     0 passed, 1 failed, 1 total (100% completed)

Time:              13.05s



npm ERR! Test failed.  See above for more details.

您知道为什么吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

LE:这与一个问题(BUG#2639)有关,该问题将在不久的将来在WebdriverIO版本5(webdriverio@5.x.x)中得到解决。此行为会影响所有sync: true WDIO设置。

最后,这是项目负责人维护者对此事的看法:

  

仅供参考:这将在v5中修复,其中底层的monad   结构更加简化,并且可以实际使用。

     

如果有人对此修复程序感兴趣,请随时提出PR   在v4分支上。该问题很可能已在v5中修复。


我认为这与您正在运行的设置几乎是自定义的,除非您添加一些奇特的报告程序以获取更多的详细信息和显示赃物。只需访问Official Guide中的记者部分即可。

替代项:

a。)。您可以使用可选的msg参数在声明级别上提高详细程度:

expect(breadcrumbsAppearancesNumber, `Found: ${breadcrumbsAppearancesNumber} breadcrumbs | Expected: 3 breadcrumbs`).to.equal(3);

b。)或增加logLevel: verbose文件中的日志详细程度(wdio.conf.js):

exports.config = {
  // ...
  //
  // Level of logging verbosity: silent | verbose | command | data | result | error
  logLevel: 'verbose',
  //
  // ... 
};