diff --git a/uiautomation-ext.js b/uiautomation-ext.js index ede15eb..37e1352 100644 --- a/uiautomation-ext.js +++ b/uiautomation-ext.js @@ -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. @@ -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') { @@ -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 @@ -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, { @@ -447,7 +455,6 @@ extend(UIAKeyboard.prototype,{ } }); - var typeString = function(pstrString, pbClear) { pstrString = pstrString.toString(); // handle keyboard not being focused