
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
grunt-webdriver
Advanced tools
grunt-webdriver is a grunt plugin to run selenium tests with Mocha and WebdriverIO
grunt-webdriver is a grunt plugin to run selenium tests with Mocha and WebdriverIO
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 --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-webdriver');
In your project's Gruntfile, add a section named webdriver
to the data
object passed into grunt.initConfig()
.
Run this task with the grunt webdriver
command.
grunt.initConfig({
webdriver: {
options: {
desiredCapabilities: {
browserName: 'chrome'
}
},
login: {
tests: ['test/spec/login/*.js'],
options: {
// overwrite default settings
desiredCapabilities: {
browserName: 'firefox'
}
}
},
form: {
tests: ['test/spec/form/*.js']
}
// ...
},
})
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: {
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: {
tests: ['test/spec/login/*.js']
},
form: {
tests: ['test/spec/form/*.js']
}
// ...
},
})
All options get passed into the WebdriverIO remote
function. So this is the place where
you can define your driver instance. You'll find more informations about all WebdriverIO
options here. You can overwrite these
options in any target. Also you have to define all Mocha options here. The following
are supported:
Type: Boolean
Default: false
If true you are only interested in the first execption
Type: String
Default: bdd
Options: bdd | tdd | qunit | exports
Specify the interface to use.
Type: String
Default: spec
Options: Base | Dot | Doc | TAP | JSON | HTML | List | Min | Spec | Nyan | XUnit | Markdown | Progress | Landing | JSONCov | HTMLCov | JSONStream
Allows you to specify the reporter that will be used.
Type: Number
Default: 75
Specify the "slow" test threshold, defaulting to 75ms. Mocha uses this to highlight test-cases that are taking too long.
Type: Number
Default: 1000000
Specifies the test-case timeout.
Type: String
When specified will trigger mocha to only run tests matching the given pattern which is internally compiled to a RegExp
.
Type: Boolean
Default: false
If true it will automatically update the current job and does publish it.
Type: String
Default: null
If set grunt-webdriver will pipe reporter output into given file path
Type: Boolean
Default: false
If true it prevents the original process.stdout.write from executing - no output at all
Type: Boolean
Default: false
If true it will not spawn a new selenium server process (useful if you use Sauce Labs without Sauce Tunnel)
Type: Object
Default: {}
Options for starting the Selenium server. For more information check out the selenium-standalone project.
Type: Object
Default: {}
Options for installing Selenium dependencies. For more information check out the selenium-standalone project.
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 WebdriverIO API to search the
grunt-webdriver 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';
var assert = require('assert');
describe('grunt-webdriver 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) {
assert(title.indexOf('grunt-webdriver') !== -1);
})
.call(done);
});
});
If you like to write your tests in CoffeeScript just add the following on the top of your Gruntfile and you are set.
require('coffee-script/register');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// ...
});
}
Please fork, add specs, and send pull requests! In lieu of a formal styleguide, take care to maintain the existing coding style.
FAQs
grunt-webdriver is a grunt plugin to run selenium tests with the WebdriverIO test runner
The npm package grunt-webdriver receives a total of 408 weekly downloads. As such, grunt-webdriver popularity was classified as not popular.
We found that grunt-webdriver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.