Skip to content

Instantly share code, notes, and snippets.

@chodorowicz chodorowicz/assertions.js
Last active Nov 4, 2016

Embed
What would you like to do?
webdriver
// count elements
// http://webdriver.io/api/protocol/elements.html
browser.elements('.OrdersList .Row')
.then(elements => {
assert.equal(elements.value.length, 999);
})
const elementWithText = 'h2=Create a new Order Sheet';
const cssSelector = '.ProductsBig span';
remote
// http://webdriver.io/api/utility/waitForExist.html
// exists
.waitForExist('.selector', 500)
// doesn't exist
.waitForExist('.selector', 500, true)
const webdriverio = require('webdriverio');
const chai = require('chai');
const expect = chai.expect;
const options = { desiredCapabilities: { browserName: 'chrome' } };
const remote = webdriverio.remote(options);
const testingUrl = 'http://google.com/';
const waitShort = 5000;
describe('Google', function() {
/** setting timeout for help describe block → this won't work with arrow functions */
this.timeout(40000);
beforeEach(() => {
/** return remote - it's a promise */
return remote.init();
});
it('should display page with title', function() {
/** either return promise or use done callback, in Mocha 3.* doing both fails test */
return remote
.url(testingUrl)
.getTitle().then((title) => {
expect(title).to.equal('Google');
})
.click('[href="http://google.com/some-link"]')
.waitUntil(() => remote.isVisible('.some-div'), waitShort)
});
afterEach(() => remote.end());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.