Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 078ca01dc772dca8ac13962af4bf09049d6bed75 @sebv committed May 21, 2012
@@ -0,0 +1,2 @@
+node_modules
+.DS_Store
@@ -0,0 +1,23 @@
+DEV_DIRS = ['lib','test']
+COFFEE_PATHS = DEV_DIRS.concat ['index.coffee']
+JS_PATHS = DEV_DIRS.concat ['index.js']
+TEST_ENV = ['test/sync-test.coffee']
+
+u = require 'sv-cake-utils'
+
+task 'compile', 'Compile All coffee files', ->
+ u.coffee.compile COFFEE_PATHS
+
+task 'compile:watch', 'Compile All coffee files and watch for changes', ->
+ u.coffee.compile COFFEE_PATHS, watch:true
+
+task 'clean', 'Remove all js files', ->
+ u.js.clean JS_PATHS, undefined, /browser\-scripts/
+
+task 'test', 'Run All tests', ->
+ ./node_modules/.bin/nodeunit 'test/unit/*.coffee'
+
+task 'grep:dirty', 'Lookup for debugger and console.log in code', ->
+ u.grep.debug()
+ u.grep.log()
+
@@ -0,0 +1,15 @@
+Apache License, Version 2.0
+
+Copyright (c) 2012 Seb Vincent
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
@@ -0,0 +1,10 @@
+Work just started on this
+
+# wd-zombie
+
+Trying to reimplement wd using zombie for headless testing
+
+# TODO
+
+* moveTo args
+* click button number support
@@ -0,0 +1 @@
+module.exports = require './lib/wd-zombie'

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,32 @@
+// run in the browser
+
+//parse arguments
+var condExpr = arguments[0], timeout = arguments[1],
+poll = arguments[2], cb = arguments[3];
+
+// recursive implementation
+var waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
+
+ // timeout check
+ if (Date.now() < limit) {
+ // condition check
+ var res = eval(conditionExpr);
+ if (res == true ) {
+ // condition ok
+ return cb(res);
+ } else {
+ // wait for poll and try again
+ setTimeout(function() {
+ waitForConditionImpl(conditionExpr, limit, poll, cb);
+ }, poll);
+ }
+ } else {
+ // try one last time
+ res = eval(conditionExpr);
+ return cb(res);
+ }
+};
+
+// calling impl
+var limit = Date.now() + timeout;
+waitForConditionImpl(condExpr, limit, poll, cb);
@@ -0,0 +1,36 @@
+Browser = require "zombie"
+
+browser = new Browser debug: true
+
+browser.visit "http://www.google.com?a=1", (err,browser, status) ->
+ throw err if err?
+ browser.wait 1000
+
+ browser.onalert (message) ->
+ console.log "OKOK", message
+ true
+
+ browser.window.alert "THIS IS AN ALERT"
+
+
+ #el = browser.querySelector "p"
+ #console.log "OKOK", el.textContent
+ #for k,v of el
+ # console.log k, typeof v
+
+###
+
+ browser.visit "http://www.apple.com", (err,browser, status) ->
+ throw err if err?
+ for k,v of browser.history
+ console.log k
+ console.log "browser.history.back=" + browser.history.back()
+ console.log "browser.history.forward=" + browser.history.forward()
+
+
+ console.log "title=", browser.document.title
+ console.log (browser.querySelector "body #main")
+ res = browser.document.getElementsByTagName "a"
+ console.log res[1].textContent
+ #for k,v of res[0]
+ # console.log k

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 078ca01

Please sign in to comment.