Skip to content

Commit

Permalink
add isNotNil to UIAELementNil objects, along with other functions (fo…
Browse files Browse the repository at this point in the history
…r consistency)
  • Loading branch information
ianfixes committed Jan 28, 2014
1 parent 7e6feb1 commit 7d6dd73
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions uiautomation-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extend(UIATableView.prototype, {
cellNamed: function(name) {
return this.cells().firstWithName(name);
},

/**
* Asserts that this table has a cell with the name (accessibility label)
* matching the given +name+ argument.
Expand All @@ -19,16 +19,23 @@ extend(UIATableView.prototype, {
}
});

var isNotNil = function() {
var ret = undefined !== this
&& null != this
&& this.toString() != "[object UIAElementNil]";
return ret;
};


extend(UIAElement.prototype, {
/**
* Dump tree in json format for copy/paste use in AssertWindow and friends
*/

elementJSONDump: function (recursive, attributes, visibleOnly) {
if (visibleOnly && !this.isVisible()) {
return "";
}

if (!attributes) {
attributes = ["name", "label", "value", "isVisible"];
} else if (attributes == 'ALL') {
Expand Down Expand Up @@ -161,13 +168,6 @@ extend(UIAElement.prototype, {
+ "\n" + this.elementJSONDump(true, attributes, true));
},

isNotNil: function() {
var ret = undefined !== this
&& null != this
&& this.toString() != "[object UIAElementNil]";
return ret;
},


/**
* Poll till the item becomes visible, up to a specified timeout
Expand Down Expand Up @@ -303,7 +303,15 @@ extend(UIAElement.prototype, {
tapAndWaitForInvalid: function() {
this.tap();
this.waitForInvalid();
}
},

isNotNil: isNotNil,
});

extend(UIAElementNil.prototype, {
isNotNil: isNotNil,
isValid: function() { return false; },
isVisible: function() { return false; }
});

extend(UIAApplication.prototype, {
Expand Down Expand Up @@ -447,7 +455,6 @@ extend(UIAKeyboard.prototype,{
}
});


var typeString = function(pstrString, pbClear) {
pstrString = pstrString.toString();
// handle keyboard not being focused
Expand Down

0 comments on commit 7d6dd73

Please sign in to comment.