Basic test with Selenium

To run a basic test with Selenium, you need a few things installed: node, mocha, and selenium-webdriver. Follow the normal install procedure for those.

Mocha is a command line program, and can be run with:


I include the “-t 0” parameter to ignore timeout warnings.

A sample script to launch chrome, navigate to a site, and get the title of the page:

var webdriver = require(‘selenium-webdriver’)
var chrome = require(‘selenium-webdriver/chrome’)

var driver = new webdriver.Builder()

describe(‘Sample test’, function(){
it(‘gets TITLE from the site’, function(){
console.log(‘title is:’, title)

If the test does not run, you may need to install the Chrome webdriver executable.