🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

grunt-webdriver

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-webdriver - npm Package Compare versions

Comparing version

to
0.1.2

lib/startSelenium.js

4

Gruntfile.js

@@ -19,5 +19,3 @@ /*

dev: {
options: {
url: 'http://github.com'
},
url: 'http://github.com',
tests: './test/*.js'

@@ -24,0 +22,0 @@ }

{
"name": "grunt-webdriver",
"description": "grunt-webdriver is a grunt plugin to run selenium tests with BusterJS and webdriverjs",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/christianbromann/grunt-webdriver",

@@ -6,0 +6,0 @@ "author": {

@@ -31,9 +31,11 @@ # grunt-webdriver

_Run this task with the `grunt webdriver` command._
```js
grunt.initConfig({
webdriver: {
options: {
url: '<start-url>'
},
files: ['<path-to-your-testfiles>'],
dev: {
url: '<start-url>',
tests: ['<path-to-your-testfiles>']
}
},

@@ -43,7 +45,29 @@ })

### Options
#### browser
Type: `String`<br>
Default: *chrome*<br>
Options: *chrome|firefox|opera|safari*
Defines the browser
#### logLevel
Type: `String`<br>
Default: *silent*<br>
Options *silent|verbose*
Set log level of webdriverjs API
#### binary
Type: `String`<br>
Default: standard MacOSX browser path (e.g. Chrome: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
Specify the binary path for the indicated browser __(important for windows user)__
### Usage Examples
#### Required Options
In this example, the required options are used to execute a simple test script.
In this example, the minimum required options are used to execute a simple
test script.

@@ -54,5 +78,3 @@ ```js

dev: {
options: {
url: 'http://github.com'
},
url: 'http://github.com',
tests: './test/github-test.js'

@@ -65,3 +87,4 @@ }

The corresponding *Hello World* test script, using webdriverjs API to search the
grunt-webdriver repository on github.
grunt-webdriver repository on github. See more functions and test examples
in the [webdriverjs](https://github.com/Camme/webdriverjs) repository on GitHub.

@@ -76,3 +99,3 @@ ```js

name: "first hello world test",
name: "search plugin on github",
func: function(done) {

@@ -95,1 +118,2 @@

* 2013-03-13   v0.1.1   first working version, without special features
* 2013-03-14   v0.1.2   bugfixing, enhanced task option, improved test case

@@ -11,5 +11,5 @@ /*

var buster = require('buster'),
webdriverjs = require('webdriverjs'),
isSeleniumServerRunning = require('../lib/isSeleniumServerRunning');
var buster = require('buster'),
webdriverjs = require('webdriverjs'),
startSelenium = require('../lib/startSelenium');

@@ -22,12 +22,55 @@ module.exports = function(grunt) {

done = this.async(),
options = this.options();
base = process.cwd(),
options = this.options({
browser: 'chrome',
logLevel: 'silent',
capabilities: {
chrome: {
'browserName': 'chrome',
'chrome.binary': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
},
firefox: {
'browserName': 'firefox',
'firefox_binary': '/Applications/Firefox.app/Contents/MacOS/firefox'
},
opera: {
'browserName': 'opera',
'opera.binary': '/Applications/Opera.app/Contents/MacOS/Opera'
},
safari: {
'browserName': 'safari',
'safari.binary': '/Applications/Safari.app/Contents/MacOS/Safari'
}
}
}),
capabilities = [];
/**
* display a warning and abort task immediately if test URL is not defined
*/
if(this.data.url === undefined) {
grunt.fail.fatal('the test url is not defined');
}
/**
* set capabilities for webdriverjs
*/
if(options.binary === undefined) {
capabilities = options.capabilities[options.browser];
} else {
var seperator = options.browser === 'firefox' ? '_' : '.';
capabilities['browserName'] = options.browser,
capabilities[options.browser+seperator+'binary'] = options.binary;
}
/**
* initialize webdriver
*/
var driver = webdriverjs.remote({desiredCapabilities:{
"browserName": "chrome",
"chrome.binary": "/Applications/Browser/Google Chrome.app/Contents/MacOS/Google Chrome"
},logLevel: 'silent'});
var driver = webdriverjs.remote({desiredCapabilities:capabilities,logLevel: options.logLevel});
/**
* specify special driver commands
* @param {Function} testSuite command function
* @return {Object} driver object
*/
driver.initTest = function(testSuite) {

@@ -40,7 +83,17 @@ for(var test in testSuite) {

isSeleniumServerRunning(function() {
/**
* starts selenium standalone server if its not running
* @param {Function} callback function on success
* @param {Function} done grunt done function for async callbacks
* @param {Object} grunt grunt object
* @return null
*/
startSelenium(function() {
/**
* require given test files and run buster
*/
var reporter = buster.reporters.dots.create({ color: true }),
runner = buster.testRunner.create(),
testCases = grunt.file.expand(grunt.file.expand(that.data.tests));
testCases = grunt.file.expand(grunt.file.expand(base + '/' + that.data.tests));

@@ -50,7 +103,7 @@ // get tests context

testCases.forEach(function(testCase) {
var context = require('.'+testCase);
var context = require(testCase);
context.setUp = function() {
this.timeout = 9999999;
driver.init().url(options.url);
driver.init().url(that.data.url);
};

@@ -57,0 +110,0 @@

@@ -0,1 +1,9 @@

/*
* grunt-webdriver
* https://github.com/christianbromann/grunt-webdriver
*
* Copyright (c) 2013 Christian Bromann
* Licensed under the MIT license.
*/
'use strict';

@@ -5,12 +13,16 @@

exports.name = "Hello World Test";
exports.name = "Simple Github Test";
exports.tests = [{
name: "first hello world test",
name: "checks if title contains the search query",
func: function(done) {
var query = 'grunt-webdriver';
exports.driver
.click('.search a')
.setValue('.search-page-input','grunt-webdriver')
.setValue('.search-page-input',query)
.click('#search_form .button')
.getTitle(function(title) {
buster.assertions.assert(title.indexOf(query) !== -1);
})
.end(done);

@@ -17,0 +29,0 @@