Skip to content

Instantly share code, notes, and snippets.

@sbmaxx
Created September 9, 2015 16:17
Show Gist options
  • Save sbmaxx/0fece972759b068d4562 to your computer and use it in GitHub Desktop.
Save sbmaxx/0fece972759b068d4562 to your computer and use it in GitHub Desktop.
webriver.mocha.chai.js
var chai = require('chai'),
assert = chai.assert,
webdriverio = require('../../index');
describe('firefox', function(){
this.timeout(99999999);
var client = {};
before(function(done){
client = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'} });
client.init(done);
});
it('should fill input', function() {
return testInput(client);
});
after(function(done) {
client.end(done);
});
});
describe('chrome', function(){
this.timeout(99999999);
var client = {};
before(function(done){
client = webdriverio.remote({ desiredCapabilities: {browserName: 'chrome'} });
client.init(done);
});
it('should fill input', function() {
return testInput(client);
});
after(function(done) {
client.end(done);
});
});
function testInput(client) {
var input = 'input[name=q]';
return client
.url('https://google.com')
.waitForVisible(input, 5000).then(function(isVisible) {
assert(isVisible, 'input not visible');
})
.click(input)
.keys('ololo')
.getValue(input).then(function(value) {
assert.equal('ololo', value);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment