Skip to content

Instantly share code, notes, and snippets.

@kevin-miles
Created June 15, 2014 21:54
Show Gist options
  • Save kevin-miles/4b672dfe715729ee05fd to your computer and use it in GitHub Desktop.
Save kevin-miles/4b672dfe715729ee05fd to your computer and use it in GitHub Desktop.
Selenium Webdriver Node Mocha
var BASE_URL = 'http://google.com';
var assert = require('assert'),
webdriver = require('selenium-webdriver'),
colors = require('colors');
//build all the drivers to be used
var chrome_driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var firefox_driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.firefox()).
build();
//compile an array that will be iterated over for the testing
var drivers = [chrome_driver, firefox_driver];
//iterate over each driver and complete the test
drivers.forEach(function (driver, index, arr){
describe('basic test', function () {
it('should be on correct page', function (done) {
driver.get(BASE_URL);
driver.getTitle()
.then(function(title) {
assert.equal(title, 'Google');
done();
});
driver.quit();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment