Skip to content

Commit

Permalink
- created index file with remote function
Browse files Browse the repository at this point in the history
- added mocha tests and travis.yml
  • Loading branch information
christian-bromann committed Mar 21, 2013
1 parent e954d16 commit dea2bd6
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.8"

before_script:
- npm install -g mocha
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* webdriverjs
* https://github.com/Camme/webdriverjs
*
* A WebDriver module for nodejs. Either use the super easy help commands or use the base
* Webdriver wire protocol commands. Its totally inspired by jellyfishs webdriver, but the
* goal is to make all the webdriver protocol items available, as near the original as possible.
*
* Copyright (c) 2013 Camilo Tapia <[email protected]>
* Licensed under the MIT license.
*
* Contributors:
* Dan Jenkins <[email protected]>
* Christian Bromann <[email protected]>
*/

var singletonInstance = null,
WebdriverJS = require('./lib/webdriverjs');

// expose the man function
// if we need a singleton, we provide the option here
exports.remote = function(options) {

// make sure we have a default options if none are provided
options = options || {};
console.log(WebdriverJS);
if (options.singleton) {
if (!singletonInstance) {
singletonInstance = new WebdriverJS(options);
}
return singletonInstance;
} else {
return new WebdriverJS(options);
}
};
46 changes: 4 additions & 42 deletions lib/webdriverjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
var http = require("http"),
fs = require('fs'),
path = require('path'),
colors = require('assets/colors'),
errorCodes = require('assets/errorCodes'),
colors = require('./assets/colors'),
errorCodes = require('./assets/errorCodes'),
infoHasBeenShown = false;

var WebdriverJs = function(options)//host, port, username, pass)
{
var WebdriverJs = module.exports = function(options) {

options = options || {};

Expand Down Expand Up @@ -699,22 +698,6 @@ for(var i = 0, ii = protocolFiles.length; i < ii; i++)
}


/*
// ------------------ tests helpers ----------------
var testFiles = fs.readdirSync(__dirname + "/tests/");
for(var i = 0, ii = testFiles.length; i < ii; i++)
{
var commandName = path.basename(testFiles[i], '.js');
WebdriverJs.prototype[commandName] = require("./tests/" + testFiles[i]).command;
}
*/
// save the command list to a variable available to all






var commandFiles = fs.readdirSync(__dirname + "/commands/");
var commandList = {};

Expand Down Expand Up @@ -744,25 +727,4 @@ for(var i = 0, ii = assertFiles.length; i < ii; i++) {
var commandName = path.basename(assertFiles[i], '.js');
assertList[commandName] = require("./asserts/" + assertFiles[i]).command;
}
}



var singletonInstance = null;

// expose the man function
// if we need a singleton, we provide the option here
exports.remote = function(options)//host, port, username, pass)
{
// make sure we have a default options if none are provided
options = options || {};

if (options.singleton) {
if (!singletonInstance) {
singletonInstance = new WebdriverJs(options);
}
return singletonInstance;
} else {
return new WebdriverJs(options);//host, port, username, pass);
}
};
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webdriverjs",
"description": "A nodejs bindings implementation for selenium 2.0/webdriver",
"version": "0.7",
"version": "0.6.9",
"homepage": "https://github.com/Camme/webdriverjs",
"author": "camilo tapia <[email protected]>",
"contributors": [
Expand All @@ -21,10 +21,13 @@
"url": "https://github.com/Camme/webdriverjs/blob/master/LICENSE-MIT"
}
],
"main": "./lib/webdriverjs",
"main": "./index",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "mocha"
},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
Expand All @@ -39,5 +42,5 @@
"webdriverjs",
"selenium",
"saucelabs"
],
]
}
9 changes: 9 additions & 0 deletions test/click-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var assert = require("assert");
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
});
});
});
35 changes: 35 additions & 0 deletions test/getCssProperty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var assert = require("assert"),
webdriverjs = require("../index");

describe('Test command getCssProperty(cssSelector, cssProperty, callback)', function(){

this.timeout(99999999);

var client = {};

before(function(){
// init client
var capabilities = {
'browserName': 'chrome',
'chrome.binary': '/Applications/Browser/Google Chrome.app/Contents/MacOS/Google Chrome'
};
client = webdriverjs.remote({desiredCapabilities:capabilities});
});

beforeEach(function(){
client
.init()
.url('https://github.com/Camme/webdriverjs');
});

describe('check CSS property of several tags', function(){
it('should return #777777 as font-color', function(done){
client
.getElementCssProperty('id', 'footer', 'color', function(result) {
console.log('result: rgba(119,119,119,1) === ' + result);
assert('rgba(119,119,119,1)' === result);
})
.end(done);
});
});
});

0 comments on commit dea2bd6

Please sign in to comment.