Skip to content

Commit

Permalink
regex functions for UIAElementArray objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfixes committed Jun 13, 2014
1 parent 111ee80 commit 78db598
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions uiautomation-ext.js
Expand Up @@ -24,6 +24,32 @@ var isNotNil = function () {
return ret;
};

extend(UIAElementArray.prototype, {
/**
* Same as withName, but takes a regular expression
*/
withNameRegex: function(pattern) {
var ret = [];
for (var i = 0; i < this.length; ++i) {
var elem = this[i];
if (elem.isNotNil() && elem.name().match(pattern) !== null) {
ret.push(elem);
}
}
return ret;
},

/**
* Same as firstWithName, but takes a regular expression
*/
firstWithNameRegex: function(pattern) {
for (var i = 0; i < this.length; ++i) {
var elem = this[i];
if (elem.isNotNil() && elem.name().match(pattern) !== null) return elem;
}
return new UIAElementNil();
}
});

extend(UIAElement.prototype, {

Expand Down

0 comments on commit 78db598

Please sign in to comment.