Permalink
Browse files

moved old test to example and replaced by nodeunit test suite

  • Loading branch information...
1 parent 45798c5 commit 88841313f9ed6a014226313fef413fe4b477d52e @sebv sebv committed May 5, 2012
View
@@ -0,0 +1,2 @@
+node_modules
+.DS_Store
@@ -1,4 +1,3 @@
-// @todo separate example and tests
var webdriver;
try{ webdriver = require('wd'); }catch( err ) {
webdriver = require('../lib/main'); }
@@ -2,7 +2,6 @@
var username = "<USERNAME>",
accessKey = "<ACCESS_KEY>";
-// @todo separate example and tests
var webdriver;
try{ webdriver = require('wd'); }catch( err ) {
webdriver = require('../lib/main'); }
@@ -2,7 +2,6 @@
var username = "<USERNAME>",
accessKey = "<ACCESS_KEY>";
-// @todo separate example and tests
var webdriver;
try{ webdriver = require('wd'); }catch( err ) {
webdriver = require('../lib/main'); }
View
@@ -1,16 +1,24 @@
-{ "name" : "wd"
-, "description" : "WebDriver/Selenium 2 node.js client"
-, "tags" : ["web", "automation", "browser", "javascript"]
-, "version" : "0.0.12"
-, "author" : "Adam Christian <adam.christian@gmail.com>"
-, "repository" :
- { "type" : "git"
- , "url" : "https://github.com/admc/wd.git"
+{
+ "name" : "wd"
+ , "description" : "WebDriver/Selenium 2 node.js client"
+ , "tags" : ["web", "automation", "browser", "javascript"]
+ , "version" : "0.0.12"
+ , "author" : "Adam Christian <adam.christian@gmail.com>"
+ , "repository" :
+ { "type" : "git"
+ , "url" : "https://github.com/admc/wd.git"
+ }
+ , "bugs" :
+ { "url" : "https://github.com/admc/wd/issues" }
+ , "engines" : ["node"]
+ , "main" : "./lib/main"
+ , "bin" : { "wd" : "./lib/bin.js" }
+ , "directories" : { "lib" : "./lib" }
+ , "devDependencies" : {
+ "nodeunit" : "latest"
+ ,"should": "latest"
+ ,"coffee-script": "latest"
+ ,"express": "latest"
+ ,"async": "latest"
}
-, "bugs" :
- { "url" : "https://github.com/admc/wd/issues" }
-, "engines" : ["node"]
-, "main" : "./lib/main"
-, "bin" : { "wd" : "./lib/bin.js" }
-, "directories" : { "lib" : "./lib" }
}
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<head>
+ <meta charset="utf-8" />
+ <title>TEST PAGE</title>
+
+ <script src="http://code.jquery.com/jquery-latest.js"></script>
+
+</head>
+ <body>
+ <div name="elementByName">Hello World!</div>
+ <div id="elementById">Hello World!</div>
+ <div id="elementByCss">Hello World!</div>
+ <div id="elementByLinkText"><a>click helloByLinkText</a></div>
+ <div id="getAttribute" weather="sunny">Hi</div>
+ <div id="getValue">
+ <input class="input-text" type="text" value="Hello getValueTest!">
+ <textarea>Hello getValueTest2!</textarea>
+ </div>
+ <div id="text"><div>text content</div></div>
+ <div id="type"><input class="input-text" type="text"></div>
+ <div id="eval"><ul><li>line 1</li><li>line 2</li></ul></div>
+ <div id="setWaitTimeout"></div>
+ <div id="clickElement"><a href="#">not clicked</a></div>
+ <div id="moveTo">
+ <a class="a1" href="#">a1</a><br>
+ <a class="a2" href="#">a2</a><br>
+ <div class='current'></div>
+ </div>
+ <div id="click"><a href="#">not clicked</a></div>
+ <div id="doubleclick"><a href="#">not clicked</a></div>
+ <div id="clear"><input class="input-text" type="text" value="not cleared"></div>
+ <div id="textPresent">weather is sunny</div>
+ <div id="acceptAlert"><a>click me</a></div>
+ <div id="dismissAlert"><a>click me</a></div>
+ <div id="active">
+ <input class="i1" type="text" value="input 1">
+ <input class="i2" type="text" value="input 2">
+ </div>
+ <div id="mouseButton"><a>hold me</a><div><div></div>
+ </body>
+</html>
@@ -0,0 +1,49 @@
+# nodeunit test
+
+wd = require '../../lib/main'
+should = require 'should'
+assert = require 'assert'
+
+runTestWith = (browser) ->
+ browser = null
+ remote: (test) ->
+ browser = wd.remote()
+ browser.on "status", (info) ->
+ console.log "\u001b[36m%s\u001b[0m", info
+ browser.on "command", (meth, path) ->
+ console.log " > \u001b[33m%s\u001b[0m: %s", meth, path
+ test.done()
+
+ init: (test) ->
+ browser.init
+ browserName: "chrome"
+ tags: [ "examples" ]
+ name: "This is an example test"
+ , ->
+ test.done()
+
+ browsing:
+ 'getting page': (test) ->
+ browser.get "http://saucelabs.com/test/guinea-pig", ->
+ browser.title (err, title) ->
+ assert.ok ~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!"
+ test.done()
+
+ clicking: (test) ->
+ browser.elementById "submit", (err, el) ->
+ browser.clickElement el, ->
+ browser.eval "window.location.href", (err, title) ->
+ assert.ok ~title.indexOf("#"), "Wrong title!"
+ test.done()
+
+ leaving: (test) ->
+ browser.quit ->
+ test.done()
+
+exports.chrome = runTestWith 'chrome'
+exports.firefox = runTestWith 'firefox'
+
+
+
+
+
Oops, something went wrong.

0 comments on commit 8884131

Please sign in to comment.