Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NicholasRoge
Created April 12, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasRoge/4bf64fe9de908167b66335f4c8bd4c51 to your computer and use it in GitHub Desktop.
Save NicholasRoge/4bf64fe9de908167b66335f4c8bd4c51 to your computer and use it in GitHub Desktop.
// wdio.conf.js
{
...
before() {
browser.addCommand('foo', function (callback) {
callback.apply(this, [])
})
}
...
}
// test.js
it('should succeed in selecting the body after being selected in a built-in command', function () {
browser.waitUntil(() => {
expect($('body').state).to.equal('success')
return true
})
expect($('body').state).to.equal('success')
})
it('should fail to select the body after being selected in a custom command', function () {
browser.foo(() => expect($('body').state).to.equal('success'))
expect($('body').state).to.equal('failure')
})
@caoxu2000
Copy link

I don't think this would work cause the expect assertion would throw exception itself. You can do something similar like this:
browser.waitUntil(() => {
return $('body').state === 'success';
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment