diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..7b2ced23e2c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.8" + +before_script: + - npm install -g mocha \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000000..894591fc3f7 --- /dev/null +++ b/index.js @@ -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 + * Licensed under the MIT license. + * + * Contributors: + * Dan Jenkins + * Christian Bromann + */ + +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); + } +}; \ No newline at end of file diff --git a/lib/webdriverjs.js b/lib/webdriverjs.js index d51d9e48c87..9ae91814111 100644 --- a/lib/webdriverjs.js +++ b/lib/webdriverjs.js @@ -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 || {}; @@ -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 = {}; @@ -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); - } -}; +} \ No newline at end of file diff --git a/package.json b/package.json index 8563ba02a09..cf5924e2781 100644 --- a/package.json +++ b/package.json @@ -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 ", "contributors": [ @@ -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": {}, @@ -39,5 +42,5 @@ "webdriverjs", "selenium", "saucelabs" - ], + ] } diff --git a/test/click-test.js b/test/click-test.js new file mode 100644 index 00000000000..c2330c5a044 --- /dev/null +++ b/test/click-test.js @@ -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)); + }); + }); +}); \ No newline at end of file diff --git a/test/getCssProperty.js b/test/getCssProperty.js new file mode 100644 index 00000000000..7bbfe107528 --- /dev/null +++ b/test/getCssProperty.js @@ -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); + }); + }); +}); \ No newline at end of file