简体   繁体   中英

assertion error using chai with mocha and webdriverio

I am receiving this error

AssertionError: expected { state: 'pending' } to equal 'Platform Configurator'

I've installed chai , mocha through npm

It runs the test but doesn't pass assertion

var webdriverio = require('webdriverio');
var should = require('chai').should()
var expect = require('chai').expect()
var options = {
    desiredCapabilities: {
        browserName: 'chrome'
    }
};

before(function() {
    browser=webdriverio.remote(options)
    return browser.init()

  });


describe('sauce labs page test', function() {
    it('should assert page title', function(done) {


           browser.url('https://docs.saucelabs.com/reference/platforms-configurator/?_ga=1.5883444.608313.1428365147#/');
           browser.getTitle().should.equal('Platform Configurator');
           done();
    });

});

EDIT:

If I use this, using setTimeout it passes before the test completes or even before the page loads.

var webdriverio = require('webdriverio');
var should = require('chai').should()
var expect = require('chai').expect()
var options = {
    desiredCapabilities: {
        browserName: 'chrome'
    }
};

before(function() {
    browser=webdriverio.remote(options)
    return browser.init()

  });


describe('sauce labs page test', function() {
    it('should assert page title', function() {


           browser.url('https://docs.saucelabs.com/reference/platforms-configurator/?_ga=1.5883444.608313.1428365147#/');

    setTimeout(function () {
          browser.getTitle().should.equal('Platform Configurator');


    }, 10000)



    });

});

Resolving getTitle

browser.getTitle().then(function(title){
  title.should.equal('Platform Configurator');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM