jaykz52 / mechanic

A CSS-style selector engine for iOS UIAutomation

Home Page:www.cozykozy.com/mechanicjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Element lookup error

zmook opened this issue · 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)')

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.