Comparing version 0.0.18 to 0.0.19
@@ -679,5 +679,7 @@ <table class="wikitable"> | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
NA | ||
</td> | ||
<ul> | ||
<li> | ||
getComputedCSS(element, styleName, cb) -> cb(err, value) | ||
</li> | ||
</ul> | ||
</tr> | ||
@@ -1002,2 +1004,20 @@ <tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: waitForElement<br> | ||
Waits for an element to be in the DOM. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
waitForElement(using, value, cb) -> cb(err) | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: isVisible<br> | ||
Checks if a element is in the dom and it's not display:none. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
isVisible(using, value, cb) -> cb(err, boolean) | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: waitForCondition<br> | ||
@@ -1004,0 +1024,0 @@ Waits for JavaScript condition to be true (polling within wd client). |
@@ -488,2 +488,29 @@ <table class="wikitable"> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: waitForElement<br> | ||
Waits for an element to be in the DOM. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
waitForElement(using, value, cb) -> cb(err) | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/element/:id/css/:propertyName">/session/:sessionId/element/:id/css/:propertyName</a><br> | ||
Query the value of an element's computed CSS property. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
getComputedCSS(element, styleName, cb) -> cb(err, value) | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: isVisible<br> | ||
Checks if a element is in the dom and it's not display:none. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
isVisible(using, value, cb) -> cb(err, boolean) | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA: waitForCondition<br> | ||
@@ -490,0 +517,0 @@ Waits for JavaScript condition to be true (polling within wd client). |
@@ -42,2 +42,7 @@ //Element object | ||
element.prototype.getComputedCSS = function(styleName, cb) { | ||
_this = this; | ||
_this.wd.getComputedCSS(_this, styleName, cb); | ||
}; | ||
element.prototype.clear = function(cb) { | ||
@@ -44,0 +49,0 @@ _this = this; |
var fs = require('fs'); | ||
var builder = require('./builder'); | ||
var element = require('./element').element; | ||
var async = require("async"); | ||
console.log(element); | ||
var methodBuilder = builder.methodBuilder | ||
@@ -29,3 +28,45 @@ , callbackWithData = builder.callbackWithData | ||
protocol.chain = function(){ | ||
var _this = this; | ||
//add queue if not already here | ||
if(!_this._queue){ | ||
_this._queue = async.queue(function (task, callback) { | ||
if(task.args.length > 0 && typeof task.args[task.args.length-1] === "function"){ | ||
//wrap the existing callback | ||
var func = task.args[task.args.length-1]; | ||
task.args[task.args.length-1] = function(){ | ||
func.apply(null, arguments); | ||
callback(); | ||
} | ||
} else { | ||
//add a callback | ||
task.args.push(callback); | ||
} | ||
//call the function | ||
_this[task.name].apply(_this, task.args); | ||
}, 1); | ||
} | ||
var chain = {}; | ||
//builds a placeHolder functions | ||
var buildPlaceholder = function(name){ | ||
return function(){ | ||
_this._queue.push({name: name, args: Array.prototype.slice.apply(arguments)}); | ||
return chain; | ||
} | ||
} | ||
//fill the chain with placeholders | ||
for(var name in _this){ | ||
if(typeof _this[name] === "function" && name !== "chain"){ | ||
chain[name] = buildPlaceholder(name); | ||
} | ||
} | ||
return chain; | ||
} | ||
// alternate strategy to get session capabilities | ||
@@ -364,2 +405,9 @@ // extract session capabilities from session list | ||
protocol.getComputedCSS = methodBuilder({ | ||
method: 'GET' | ||
, relPath: function(element, styleName) { | ||
return '/element/' + element + '/css/' + styleName; } | ||
, cb: function(element, styleName, cb) { return callbackWithData(cb); } | ||
}); | ||
protocol.moveTo = methodBuilder({ | ||
@@ -530,3 +578,47 @@ method: 'POST' | ||
protocol.isVisible = function(queryType, querySelector, callback){ | ||
this.elementIfExists(queryType, querySelector, function(err, element){ | ||
if(err){ | ||
return callback(err); | ||
} | ||
if(element == null){ | ||
return callback(null, false); | ||
} | ||
element.getComputedCSS("display", function(err, display){ | ||
if(err){ | ||
return callback(err); | ||
} | ||
callback(null, display !== "none"); | ||
}); | ||
}); | ||
} | ||
protocol.waitForElement = function(queryType, querySelector, timeout, callback){ | ||
var _this = this; | ||
var endTime = Date.now() + timeout; | ||
var poll = function(){ | ||
_this.hasElement(queryType, querySelector, function(err, isHere){ | ||
if(err){ | ||
return callback(err); | ||
} | ||
if(isHere){ | ||
callback(); | ||
} else { | ||
if(Date.now() > endTime){ | ||
callback(new Error("Element didn't appear")); | ||
} else { | ||
setTimeout(poll, 200); | ||
} | ||
} | ||
}); | ||
} | ||
poll(); | ||
} | ||
// waitForCondition recursive implementation | ||
@@ -533,0 +625,0 @@ var waitForConditionImpl = function(conditionExpr, limit, poll, cb) { |
@@ -5,3 +5,3 @@ { | ||
, "tags" : ["web", "automation", "browser", "javascript"] | ||
, "version" : "0.0.18" | ||
, "version" : "0.0.19" | ||
, "author" : "Adam Christian <adam.christian@gmail.com>" | ||
@@ -18,2 +18,5 @@ , "repository" : | ||
, "directories" : { "lib" : "./lib" } | ||
, "dependencies" : { | ||
"async" : "0.1.22" | ||
} | ||
, "devDependencies" : { | ||
@@ -24,5 +27,4 @@ "nodeunit" : "latest" | ||
,"express": "latest" | ||
,"async": "latest" | ||
,"gleak": "latest" | ||
} | ||
} |
@@ -19,2 +19,3 @@ # WD.js -- A light weight WebDriver/Se2 client for node.js | ||
- Seb Vincent ([sebv](https://github.com/sebv)) | ||
- Peter 'Pita' Martischka ([pita](https://github.com/Pita)) | ||
@@ -21,0 +22,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273179
5
3383
614
1
+ Addedasync@0.1.22
+ Addedasync@0.1.22(transitive)