diff --git a/README.md b/README.md index 850a0534ead..2af93804fae 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ describe('my webdriverjs tests', function(){ after(function(done) { client.end(done); - }) + }); }); ``` diff --git a/examples/example.command.mixed.webdriver.js b/examples/example.command.mixed.webdriver.js deleted file mode 100644 index a46baf7cd07..00000000000 --- a/examples/example.command.mixed.webdriver.js +++ /dev/null @@ -1,30 +0,0 @@ -// example of webdriver with mixed commands. -// some are chained, some are inside the callbacks. - -var webdriverjs = require("webdriverjs"); -var client = webdriverjs.remote(); - -client - .init() // initiate the client - .url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/index2.html") // go to a specific url - .getSize("#foo", function(result){ /*console.log(result); */ }) // get the width and hight of an element with the id #foo - .getCssProperty("#foo", "color", function(result){ /*console.log(result); */ }) // get the color css property for an object with the id #foo - .getTitle( // get the title of the page and when its done go to a new url - function() - { - client.url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/index.html"); - } - ) - .pause(1000) // pause for 1 sec - .isVisible("#sign") // check if an elemnt with the id #sign is visible - .getCssProperty("#sign", "display", function(result){ /*console.log(result); */ }) - .click("#submit") - .getCssProperty("#sign", "display", function(result){ /*console.log(result); */ }) - //.waitFor("#datamaskin", 10000, function(foundIt) - // { - // console.log("FOUND ", foundIt) - // } - //) - .isVisible("#sign") - .getTitle() - .end(); diff --git a/examples/example.command.webdriver.js b/examples/example.command.webdriver.js deleted file mode 100644 index 3f9e6e9cd2b..00000000000 --- a/examples/example.command.webdriver.js +++ /dev/null @@ -1,16 +0,0 @@ -// example of webdriver with queued commands - -var webdriverjs = require("webdriverjs"); -var client = webdriverjs.remote(); - -client - .init() - .url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/") - .getElementSize("id", "foo", function(result){ /*console.log(result); */ }) - .getTitle() - .getElementCssProperty("id", "foo", "color", function(result){ /*console.log(result); */ }) - .end(); - - - - diff --git a/examples/example.error.screenshot.webdriver.js b/examples/example.error.screenshot.webdriver.js deleted file mode 100644 index edc07e45d09..00000000000 --- a/examples/example.error.screenshot.webdriver.js +++ /dev/null @@ -1,11 +0,0 @@ -// example of webdriver with queued commands - -var webdriverjs = require("webdriverjs"); -var client = webdriverjs.remote(); -var fs = require('fs'); - -client - .init() - .url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/popupopener.html") - .getSize("#fkjfj") - .end(); diff --git a/examples/example.submit.js b/examples/example.submit.js deleted file mode 100644 index 9f1f5687ba8..00000000000 --- a/examples/example.submit.js +++ /dev/null @@ -1,11 +0,0 @@ -var client = require("webdriverjs").remote(); - -client - .init() - .url("http://www.google.com") - .setValue("#lst-ib", "webdriver") - .submitForm("#tsf") - .end(); - - - diff --git a/examples/example.test.github.webdriver.js b/examples/example.test.github.webdriver.js deleted file mode 100644 index ad6aab3b765..00000000000 --- a/examples/example.test.github.webdriver.js +++ /dev/null @@ -1,17 +0,0 @@ -// example of webdriver with queued commands in test mode - -var webdriverjs = require("webdriverjs"); -var client = webdriverjs.remote(); - -client - .testMode() - .init() - .url("https://github.com") - .tests.cssPropertyEquals(".login a", "color", "#4183c4", "Color of #tjena is #4183c4") - .tests.titleEquals("GitHub - Social Coding", "Title of the page is 'GitHub - Social Coding'") - .click(".pricing a") - .tests.titleEquals("Plans & Pricing - GitHub", "Title of the page is 'Plans & Pricing - GitHub'") - .tests.visible(".pagehead", true, ".pagehead is visible after click") - .end(); - - diff --git a/examples/example.test.webdriver.js b/examples/example.test.webdriver.js deleted file mode 100644 index 66c71042c7a..00000000000 --- a/examples/example.test.webdriver.js +++ /dev/null @@ -1,17 +0,0 @@ -// example of webdriver with queued commands - -var webdriverjs = require("webdriverjs"); -//var client = webdriverjs.remote("172.16.135.132"); -var client = webdriverjs.remote(); -client - .testMode() - .init() - .url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/") - .tests.cssPropertyEquals("#foo", "color", "#000000", "Color of #tjena is #000000") - .tests.titleEquals("Foo", "Title of the page is 'Foo'") - .tests.visible("#sign", false, "#sign is not visible before click") - .click("#submit") - .tests.visible("#sign", true, "#sign is visible after click") - .end(); - - diff --git a/examples/example.webdriver.js b/examples/example.webdriver.js deleted file mode 100644 index eea73b20ab5..00000000000 --- a/examples/example.webdriver.js +++ /dev/null @@ -1,26 +0,0 @@ -// example of webdriver with queued commands, callaback commands and other stuff - -var webdriverjs = require("webdriverjs"); -var client = webdriverjs.remote(); - - -client.init(); -client.url("http://www.onezerozeroone.com/projects/webdriverjs/testsite/", function() {}); -client.url(function(result) { /*console.log("URL:", result.value); */}); -client.execute("return document.title", function(result) { /*console.log("document.title:", result.value);*/ }); -client.title(function(result) { /*console.log("URL:", result.value); */}); - -client.element("id", "foo", function(result) { - - client.elementIdCssProperty(result.value.ELEMENT, "color", function(result) { /*console.log("element width id 'hoz':", result.value); */}); - client.elementIdSize(result.value.ELEMENT, function(result) { /*console.log(result.value); */}); - client.elementIdDisplayed(result.value.ELEMENT, function(result) { /*console.log(result.value); */}); - client.elements("tag name", "script", function(result) { /*console.log(result);*/ }); - client.value(result.value.ELEMENT, "Data", function(result) { /*console.log(result);*/ }); - client.value(result.value.ELEMENT, function(result) { /*console.log(result);*/ }); - client.screenshot(function(result) { /*console.log("element width id 'hoz':", result.value); */}); - client.session("delete"); - -}); - - diff --git a/examples/readme.md b/examples/readme.md deleted file mode 100644 index 1129855466e..00000000000 --- a/examples/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -#Examples -These files are different types of examples on how to use webdriverjs. I will write more about then soon. \ No newline at end of file diff --git a/examples/webdriverjs.with.buster.js b/examples/webdriverjs.with.buster.js new file mode 100644 index 00000000000..c229b8eec1b --- /dev/null +++ b/examples/webdriverjs.with.buster.js @@ -0,0 +1,35 @@ +var buster = require("buster"), + webdriverjs = require('../index'); + +buster.testCase("my webdriverjs tests", { + + 'setUp': function() { + this.timeout = 9999999; + + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(); + }, + + 'test it': function (done) { + client + .url('https://github.com/') + .getElementSize('.header-logo-wordmark', function(err, result) { + assert(err === null); + assert(result.height === 30); + assert(result.width === 68); + }) + .getTitle(function(err, title) { + assert(err === null); + assert(title === 'GitHub · Build software better, together.'); + }) + .getElementCssProperty('class name','subheading', 'color', function(err, result){ + assert(err === null); + assert(result === 'rgba(136, 136, 136, 1)'); + }) + .call(done); + }, + + 'tearDown': function(done) { + client.end(done); + } +}); \ No newline at end of file diff --git a/examples/webdriverjs.with.jasmine.spec.js b/examples/webdriverjs.with.jasmine.spec.js new file mode 100644 index 00000000000..12a28c82e51 --- /dev/null +++ b/examples/webdriverjs.with.jasmine.spec.js @@ -0,0 +1,35 @@ +var webdriverjs = require('../index'); + +describe('my webdriverjs tests', function() { + + var client = {}; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 9999999; + + beforeEach(function() { + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(); + }); + + it('test it', function(done) { + client + .url('https://github.com/') + .getElementSize('.header-logo-wordmark', function(err, result) { + expect(err).toBe(null); + expect(result.height).toBe(30); + expect(result.width).toBe(68); + }) + .getTitle(function(err, title) { + expect(err).toBe(null); + expect(title).toBe('GitHub · Build software better, together.'); + }) + .getElementCssProperty('class name','subheading', 'color', function(err, result){ + expect(err).toBe(null); + expect(result).toBe('rgba(136, 136, 136, 1)'); + }) + .call(done); + }); + + afterEach(function(done) { + client.end(done); + }); +}); \ No newline at end of file diff --git a/examples/webdriverjs.with.mocha.and.chai.js b/examples/webdriverjs.with.mocha.and.chai.js new file mode 100644 index 00000000000..151236236b6 --- /dev/null +++ b/examples/webdriverjs.with.mocha.and.chai.js @@ -0,0 +1,42 @@ +/* jshint -W024 */ +/* jshint expr:true */ + +var chai = require('chai'), + assert = chai.assert, + should = chai.should(), + expect = chai.expect, + webdriverjs = require('../index'); + +describe('my webdriverjs tests', function(){ + + this.timeout(99999999); + var client = {}; + + before(function(){ + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(); + }); + + it('Github test',function(done) { + client + .url('https://github.com/') + .getElementSize('.header-logo-wordmark', function(err, result) { + expect(err).to.be.null; + assert.strictEqual(result.height , 30); + assert.strictEqual(result.width, 68); + }) + .getTitle(function(err, title) { + expect(err).to.be.null; + assert.strictEqual(title,'GitHub · Build software better, together.'); + }) + .getElementCssProperty('class name','subheading', 'color', function(err, result){ + expect(err).to.be.null; + assert.strictEqual(result, 'rgba(136, 136, 136, 1)'); + }) + .call(done); + }); + + after(function(done) { + client.end(done); + }); +}); \ No newline at end of file diff --git a/examples/webdriverjs.with.mocha.js b/examples/webdriverjs.with.mocha.js new file mode 100644 index 00000000000..454009b2e38 --- /dev/null +++ b/examples/webdriverjs.with.mocha.js @@ -0,0 +1,39 @@ +/* jshint -W024 */ +/* jshint expr:true */ + +var webdriverjs = require('../index'), + assert = require('assert'); + +describe('my webdriverjs tests', function(){ + + this.timeout(99999999); + var client = {}; + + before(function(){ + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(); + }); + + it('Github test',function(done) { + client + .url('https://github.com/') + .getElementSize('.header-logo-wordmark', function(err, result) { + assert(err === null); + assert(result.height === 30); + assert(result.width === 68); + }) + .getTitle(function(err, title) { + assert(err === null); + assert(title === 'GitHub · Build software better, together.'); + }) + .getElementCssProperty('class name','subheading', 'color', function(err, result){ + assert(err === null); + assert(result === 'rgba(136, 136, 136, 1)'); + }) + .call(done); + }); + + after(function(done) { + client.end(done); + }); +}); \ No newline at end of file diff --git a/examples/webdriverjs.with.nodeunit.js b/examples/webdriverjs.with.nodeunit.js new file mode 100644 index 00000000000..99ea407ea48 --- /dev/null +++ b/examples/webdriverjs.with.nodeunit.js @@ -0,0 +1,38 @@ +/* jshint -W024 */ +/* jshint expr:true */ + +var webdriverjs = require('../index'), + assert = require('assert'); + +module.exports = { + + setUp: function (callback) { + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(); + + callback(); + }, + test1: function (test) { + client + .url('https://github.com/') + .getElementSize('.header-logo-wordmark', function(err, result) { + test.ok(err === null, 'getElementSize() should cause no error'); + test.ok(result.height === 30, 'logo height should be 30px'); + test.ok(result.width === 68, 'logo width should be 68px'); + }) + .getTitle(function(err, title) { + test.ok(err === null, 'getTitle() should cause no error'); + test.ok(title === 'GitHub · Build software better, together.', 'title should be "GitHub · Build software better, together."'); + }) + .getElementCssProperty('class name','subheading', 'color', function(err, result){ + test.ok(err === null, 'getElementCssProperty() should cause no error'); + test.ok(result === 'rgba(136, 136, 136, 1)', 'color should be rgba(136, 136, 136, 1)'); + }); + + test.done(); + }, + tearDown: function (callback) { + // clean up + client.end(callback); + } +}; \ No newline at end of file diff --git a/examples/webdriverjs.with.vows.js b/examples/webdriverjs.with.vows.js new file mode 100644 index 00000000000..c29c62d6dff --- /dev/null +++ b/examples/webdriverjs.with.vows.js @@ -0,0 +1,92 @@ +// division-by-zero-test.js + +var vows = require('vows'), + assert = require('assert'), + webdriverjs = require('../index'), + fs = require('fs'); + +var client; + +// Create a Test Suite +vows.describe('my github tests').addBatch({ + + 'init webdriverjs': { + + topic: function () { + client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs'} }); + client.init(this.callback); + }, + + 'starting webdriverjs successfully': { + + topic: function (init) { + client.url('https://github.com/', this.callback); + }, + + 'check logo dimension': { + + topic: function (url) { + client.getElementSize('.header-logo-wordmark', this.callback); + }, + + 'getElementSize() should cause no error': function(err,result) { + assert(err === null); + }, + + 'height is 30px': function(err,result) { + assert(result.height === 30); + }, + + 'width is 68px': function(err,result) { + assert(result.width === 68); + } + + }, + + 'check title': { + + topic: function() { + client.getTitle(this.callback); + }, + + 'getTitle() should cause no error': function(err,result) { + assert(err === null); + }, + + 'title should be "GitHub · Build software better, together."': function(err,result) { + assert(result === 'GitHub · Build software better, together.'); + } + + }, + + 'check color of subheading': { + + topic: function() { + client.getElementCssProperty('class name','subheading', 'color', this.callback); + }, + + 'getElementCssProperty() should cause no error': function(err,result) { + assert(err === null); + }, + + 'color should be rgba(136, 136, 136, 1)': function(err,result) { + assert(result === 'rgba(136, 136, 136, 1)'); + } + + } + }, + + 'end webdriverjs': { + + topic: function() { + client.end(this.callback); + }, + + 'should end successfully': function(err,result) { + assert(err === null); + } + + } + } + +}).run(); // Run it \ No newline at end of file