Last active
November 4, 2016 15:02
-
-
Save chodorowicz/9c0dc4cc930897dbcc850b0ada12c41c to your computer and use it in GitHub Desktop.
webdriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// count elements | |
// http://webdriver.io/api/protocol/elements.html | |
browser.elements('.OrdersList .Row') | |
.then(elements => { | |
assert.equal(elements.value.length, 999); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elementWithText = 'h2=Create a new Order Sheet'; | |
const cssSelector = '.ProductsBig span'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remote | |
// http://webdriver.io/api/utility/waitForExist.html | |
// exists | |
.waitForExist('.selector', 500) | |
// doesn't exist | |
.waitForExist('.selector', 500, true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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