Giter Club home page Giter Club logo

grunt-webdriver-jasmine's Introduction

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 WebdriverJS 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

grunt-webdriver-jasmine's People

Contributors

binarykitchen avatar christian-bromann avatar dmoreno avatar jedi4ever avatar michael-gannon avatar patrickarlt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.