mechanic icon indicating copy to clipboard operation
mechanic copied to clipboard

Element lookup error

Open zmook opened this issue 11 years ago • 1 comments

The following code throws an error in mechanic, as far as I can isolate it as a result of trying to look up an element by identifier after opening and closing the keyboard. If I save a reference to the element obtained before opening the keyboard, it still works fine, but I'm unable to query from mechanic afterward.

 var commentView = $1('#commentTextView');
 commentView.setValue('test text');
app.windows()[1].elements()["Done"].tap();
 app.keyboard().waitUntilInvisible();
 commentView.logElement();  // => IS OK
 $('#commentTextView').log(); // => TypeError: 'undefined' is not a function (evaluating 'el.getElementsByAttr(attr, value)')

zmook avatar Jul 29 '13 20:07 zmook

It appears that UIAKey does not get set up with getElementsByAttr or getElementsByType. I do not understand why, as it is supposed to be a subclass of UIAElement, but adding code like

if (!el.getElementsByAttr) return null;

seems to fix the problem.

zmook avatar Jul 29 '13 23:07 zmook