Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor fix

  • Loading branch information...
commit cbf640afcf502b13acae324daea472d22ffedc2a 1 parent a946793
@sebv authored
Showing with 100 additions and 2 deletions.
  1. +1 −1  index.js
  2. +99 −1 lib/webdriver.js
View
2  index.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.3.3
(function() {
- module.exports = require('./lib/wd-zombie');
+ module.exports = require('./lib/main');
}).call(this);
View
100 lib/webdriver.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.3.3
(function() {
- var ASCII_SPECIAL_KEYS, Browser, Element, EventEmitter, MODIFIER_KEYS, MODIFIER_KEY_ARRAY, SPECIAL_KEYS, SPECIAL_KEY_ARRAY, Webdriver, convertCookie, elFuncFullType, elFuncSuffix, elementFuncTypes, fs, getAsciiVirtualKey, k, newError, newModifierKeys, querySelectorAllOrNull, querySelectorOrNull, rawText, rawType, transformRes, uuid, v, wait, waitAfterExecute, waitAfterPage, waitForConditionImpl, waitForConditionInBrowserJsScript, waitForOp, _fn, _i, _len, _searchType,
+ var ASCII_SPECIAL_KEYS, Browser, Element, EventEmitter, MODIFIER_KEYS, MODIFIER_KEY_ARRAY, SPECIAL_KEYS, SPECIAL_KEY_ARRAY, Webdriver, async, convertCookie, elFuncFullType, elFuncSuffix, elementFuncTypes, fs, getAsciiVirtualKey, k, newError, newModifierKeys, querySelectorAllOrNull, querySelectorOrNull, rawText, rawType, transformRes, uuid, v, wait, waitAfterExecute, waitAfterPage, waitForConditionImpl, waitForConditionInBrowserJsScript, waitForOp, _fn, _i, _len, _searchType,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice,
@@ -8,6 +8,8 @@
fs = require('fs');
+ async = require('async');
+
EventEmitter = require("events").EventEmitter;
Browser = require('zombie');
@@ -128,6 +130,12 @@
function Webdriver() {
this.browser = null;
+ this.defaultCapabilities = {
+ browserName: 'zombie',
+ version: '',
+ javascriptEnabled: true,
+ platform: 'ANY'
+ };
}
return Webdriver;
@@ -150,6 +158,52 @@
return done(null, this.browser);
};
+
+Webdriver.prototype.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;
+}
+;
+
+
Webdriver.prototype.status = function(done) {
return done(null, {
status: 'OK'
@@ -737,6 +791,50 @@
]);
};
+ Webdriver.prototype.getTagName = function(element, done) {
+ var _ref;
+ if (element instanceof Element) {
+ element = element.value;
+ }
+ return done(null, (_ref = element.tagName) != null ? _ref.toLowerCase() : void 0);
+ };
+
+ Webdriver.prototype.isDisplayed = function(element, cb) {
+ var current, visible;
+ if (element instanceof Element) {
+ element = element.value;
+ }
+ current = element;
+ visible = true;
+ visible = visible && current.type !== 'hidden';
+ while (current != null) {
+ if (current.tagName != null) {
+ (function() {
+ return visible = visible && current.style.getPropertyValue('display') !== 'none';
+ })();
+ }
+ current = current.parentNode;
+ }
+ return cb(null, visible);
+ };
+
+ Webdriver.prototype.displayed = Webdriver.prototype.isDisplayed;
+
+ Webdriver.prototype.getComputedCss = function(element, cssProperty, cb) {
+ var value, _ref;
+ if (element instanceof Element) {
+ element = element.value;
+ }
+ _ref = this.browser.window.getComputedStyle(element, null);
+ for (k in _ref) {
+ v = _ref[k];
+ console.log("AKAKAK", k, typeof v);
+ }
+ value = element.style.getPropertyCSSValue(cssProperty);
+ console.log("OKOKO value=", value);
+ return cb(null, value);
+ };
+
rawText = function(element, done) {
var _this = this;
if (element instanceof Element) {
Please sign in to comment.
Something went wrong with that request. Please try again.