Skip to content

grunt-webdriver is a grunt plugin to run selenium tests with Jasmine and WebdriverIO

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

florianorpeliere/grunt-webdriver-jasmine

 
 

Repository files navigation

grunt-webdriver-jasmine

grunt-webdriver-jasmine is a grunt plugin to run selenium tests with Jasmine and WebdriverJS

This plugin is based on grunt-webdriver and grunt-jasmine-node.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-webdriver-jasmine --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-webdriver-jasmine');

The "webdriver-jasmine" task

Overview

In your project's Gruntfile, add a section named webdriver-jasmine to the data object passed into grunt.initConfig().

Run this task with the grunt webdriver_jasmine command.

grunt.initConfig({
  webdriver_jasmine: {
    options: {
        extensions: 'js', //the extension of your spec files
      	specNameMatcher: 'spec', // used to regex spec files
        desiredCapabilities: {
            browserName: 'chrome'
        }
    },
    login: {
        options: {
            // folder where tests are located
            specFolders: ['test/spec/login'],
            // overwrite default settings
            desiredCapabilities: {
                browserName: 'firefox'
            }
        }
    },
    form: {
    	// folder where tests are located
        specFolders: ['test/spec/form']
    }
    // ...
  },
})

example using Sauce Labs

If you specify a tunnel-identifier within your desiredCapabilities object, the task will automatically try to establish a tunnel connection via Sauce Connect.

grunt.initConfig({
  webdriver_jasmine: {
    options: {
        host: 'ondemand.saucelabs.com',
        port: 80,
        user: SAUCE_USERNAME,
        key: SAUCE_ACCESS_KEY,
        desiredCapabilities: {
            browserName: 'chrome',
            version: '27',
            platform: 'XP',
            'tunnel-identifier': 'my-tunnel'
        }
    },
    login: {
        specFolders: ['test/spec/login']
    },
    form: {
        specFolders: ['test/spec/form']
    }
    // ...
  },
})

Options

All options get passed into the WebdriverJS remote function. So this is the place where you can define your driver instance. You'll find more informations about all WebdriverJS options here. You can overwrite these options in any target. Additionally you can define several task and jasmine options.The following are supported:

Your options are also passed into grunt-jasmine-node so you can specify any of the Jasmine Node options available here

task specific options

updateSauceJob

Type: Boolean
Default: false

If true it will automatically update the current job and does publish it.

output

Type: String Default: null

If set grunt-webdriver-jasmine will pipe reporter output into given file path

quiet

Type: Boolean Default: false

If true it prevents the original process.stdout.write from executing - no output at all

nospawn

Type: Boolean
Default: false

If true it will not spawn a new selenium server process (useful when using Sauce Labs)

jasmine specific options

match

Type: String
Default: .

Match only specs containing "REGEXPspec"

matchall

Type: Boolean
Default: false

Relax requirement of "spec" in spec file names

specNameMatcher

Type: String
Default: spec

Will only load spec files with name finishing with given matcher

helperNameMatcher

Type: String
Default: helpers

Will only load helper files with name finishing with given matcher

showColors

Type: Boolean Default: true

Indicates spec output should uses color to indicates passing (green) or failing (red) specs

includeStackTrace

Type: Boolean Default: true

Indicates if the stack trace will be generated from a test failure

useHelpers

Type: Boolean Default: false

If true task will try to load helper files

verbose

Type: Boolean Default: false

Verbose output as the specs are running

jUnit

Type: Object Default:

{
    report: false,
    savePath : "./reports/",
    useDotNotation: true,
    consolidate: true
}

export tests results as junitreport xml format

Usage Examples

Required Options

In this example, the minimum required options are used to execute a simple test script.

grunt.initConfig({
  webdriver: {
    githubTest: {
      tests: './test/github-test.js'
    }
  },
})

The corresponding Hello World test script is using WebdriverJS API to search the grunt-webdriver-jasmine repository on GitHub. The global browser variable lets you access your client instance. See more functions and test examples in the WebdriverIO repository.

'use strict';

describe('grunt-webdriverjs test', function () {

    it('checks if title contains the search query', function(done) {

        browser
            .url('http://github.com')
            .setValue('#js-command-bar-field','grunt-webdriver')
            .submitForm('.command-bar-form')
            .getTitle(function(err,title) {
				expect(title.indexOf('grunt-webdriver')).not.toBe(-1);
				expect(err).toBe(null);
				done();
            })
            .end();

    });

});

Contributing

Please fork, add specs, and send pull requests! In lieu of a formal styleguide, take care to maintain the existing coding style.

Release History

  • 2014-04-21   v0.1.0   first working version, based on grunt-webdriver and grunt-jasmine-node

About

grunt-webdriver is a grunt plugin to run selenium tests with Jasmine and WebdriverIO

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%