Webdriver Selenium测试通过但应失败

时间:2018-11-26 16:08:54

标签: node.js selenium testing selenium-webdriver webdriver

我正在使用Nodejs,Webdriverio,wdio.conf.js和测试。

当我运行测试时,例如:

describe('Admin Interface', function() {
  it('should have the correct header title', function *() {

    var header = yield browser.getText('h1');
    header.should.be.equal('blahblah');

   });
 });

..它通过...即使不应该通过(标头错误)

[Chrome 48.0 Windows 10 #0-0] Running: Chrome (v48.0) on Windows 10
[Chrome 48.0 Windows 10 #0-0]
[Chrome 48.0 Windows 10 #0-0] Admin Interface
[Chrome 48.0 Windows 10 #0-0]   √ should have the window title based on user 
settings
[Chrome 48.0 Windows 10 #0-0]   √ should have the correct header title
[Chrome 48.0 Windows 10 #0-0] 2 passing (3s)

这是我的wdio.conf.js

exports.config = {
  specs: [
    './test/views/admin/**.test.js',
],
 capabilities: [{
    browserName: 'Chrome',
    browser_version: '48.0',
    os: 'Windows',
    os_version: '10',
    resolution: '1024x768',
    'browserstack.local': true,
    'browserstack.debug': true
}],
 baseUrl: 'http://localhost:5000',
 (and some more...)
}

为什么我的考试通过了?什么时候不应该? 就像我可以写任何东西一样,它仍然会通过。

1 个答案:

答案 0 :(得分:1)

删除产量和功能时,它可以工作*

describe('Admin Interface', function() {
 it('should have the correct header title', function () {

   var header = browser.getText('h1');
   header.should.be.equal('blahblah');

  });
});

现在测试失败