lib/appium_lib/ios/element/generic.rb in appium_lib-0.3.1 vs lib/appium_lib/ios/element/generic.rb in appium_lib-0.3.2

- old
+ new

@@ -28,18 +28,20 @@ end def name_contains_js # execute_script 'au.mainApp.getNameContains("sign")' # execute_script 'au.mainApp.getNameContains("zzz")' + # must check .isVisible or a hidden element may be returned. + # .tap() will error on invisible elements. <<-JS UIAElement.prototype.getNameContains = function(targetName) { var target = UIATarget.localTarget(); target.pushTimeout(0); - var search = "name contains[c] '" + targetName + "' || label contains[c] '" + targetName + "'"; + var search = "(name contains[c] '" + targetName + "' || label contains[c] '" + targetName + "') && visible == 1"; var searchElements = function(element) { var children = element.elements(); var result = children.firstWithPredicate(search); - if (result.type() !== 'UIAElementNil') { + if (result.type() !== 'UIAElementNil' && result.isVisible() === 1) { return result; } for ( var a = 0, len = children.length; a < len; a++) { result = searchElements(children[a]); \ No newline at end of file