jaykz52 / mechanic Goto Github PK
View Code? Open in Web Editor NEWA CSS-style selector engine for iOS UIAutomation
Home Page: www.cozykozy.com/mechanicjs
License: MIT License
A CSS-style selector engine for iOS UIAutomation
Home Page: www.cozykozy.com/mechanicjs
License: MIT License
The first two mechanic calls below behave as expected. The filter in the next call returns an empty set when I expected the same result as immediatlely prior. The second set of three mechanic calls reverse the selectors. Using UIATextField results in one element being returned (which is correct). mechanic does not like it if you try to chain a find or filter to a single element result. The filter returns an empty set (same as above, it should have returned the same element). The filter version just hangs which is probably just Instruments being unfriendly. I'm happy to help debug some more.
UIALogger.logMessage("find #account");
mechanic(signInWin).find('#account').logTree();
UIALogger.logMessage("find #account find UIATextField");
mechanic(signInWin).find('#account').find('UIATextField').logTree();
UIALogger.logMessage("find #account filter UIATextField");
mechanic(signInWin).find('#account').filter('UIATextField').logTree();
UIALogger.logMessage("find UIATextField");
mechanic(signInWin).find('UIATextField').logTree();
UIALogger.logMessage("find UIATextField filter #account ");
mechanic(signInWin).find('UIATextField').filter('#account').logTree();
UIALogger.logMessage("find UIATextField find #account ");
mechanic(signInWin).find('UIATextField').find('#account').logTree();
=>
2012-08-17 22:14:30 +0000 Default: find #account
2012-08-17 22:14:30 +0000 logElementTree:
UIATableCell "account" {{321, 254}, {381, 45}}
elements: {
UIATextField "account" {{341, 267}, {361, 43}}
}
2012-08-17 22:14:30 +0000 Default: find #account find UIATextField
2012-08-17 22:14:31 +0000 logElementTree:
UIATextField "account" {{341, 267}, {361, 43}}
2012-08-17 22:14:31 +0000 Default: find #account filter UIATextField
2012-08-17 22:14:31 +0000 Default: find UIATextField
2012-08-17 22:14:31 +0000 logElementTree:
UIATextField "account" {{341, 267}, {361, 43}}
2012-08-17 22:14:31 +0000 Default: find UIATextField filter #account
2012-08-17 22:14:31 +0000 Default: find UIATextField find #account
Instruments Trace Complete
Plenty of good, recent code is missing from the official release. How about releasing a new version?
I should be able to pass the key to a "getter" function into pluck
function. The passed function should be evaluated and it's return value returned.
I have a cancel uibarbuttonitem. When I do this
The Appium folks made a fix for this. I verified that it works.
UIAWindow
UIACollectionView
UIACollectionCell......
No matter what I do, it won't find the collectionView or the cells.
I have tried
$('collection')
$('UIACollectionView')
$('collectionCell')
zero elements are always found.
The signal-to-noise ratio would go down if mechanic supported "chained" selectors that could be transformed into a chained calls of the selector functions. For example:
$("cell > text");
would get translated into
$("cell").children("text");
Another example might be
$("button[name='niceButton']");
would internally call
$("button").predicate({'name' : 'niceButton'});
This simple script fails:
#import /Users/saucelabs/Desktop/mechanic.js
$.log("foo");
Looks like #import
no longer puts everything into the same scope?
If I'm looking for the UIAButton in the following structure
UIAWindow
UIATableView
UIATableCell
UIAButton: name:edit
will $('#edit')
return the correct element? I'm digging through the code (rusty JS coder) and it's not clear that this would work.
Attempting to select by label name with a percent sign fails.
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)')
There is inconsistent indentation throughout the src files for some reason. Fix this while keeping the current layout of the functions themselves (i.e. don't move single-line functions into multiple lines, etc.)
In the Including Mechanic.js section of the READEME.md file it says I just include mechanic.js
to use mechanic features. But there is no mechanic.js file in the src directory. Am I missing something?
I assume the contents of mechanic.js
should be:
#import "mechanic-core.js"
#import "data.js"
#import "events.js"
#import "logging.js"
Note that data.js
depends on mechanic from mechanic-core.js
being defined.
Currently, .prev and .next (common in most selector frameworks) are missing. These functions could be useful especially in the context of table views / table view cells.
The script breaks immediately, even when just importing it, does anyone else have this issue?
Error: Script threw an uncaught JavaScript error: 'undefined' is not a function (evaluating 'typeShortcuts[key].forEach(function(shortcut) { typeSelectorREString += shortcut + "|"; })') on line 67 of mechanic.js
The predicate function should accept either a string or an object literal.
For example, when a string is passed into predicate, internally the withPredicate function should be used:
$('button').withPredicate('name == 'Awesome Button');
// Internally, this will collect (map) el.withPredicate('name == 'Awesome Button')
When an object literal is passed to the predicate function, the selector should be filtered down using each key/value pair:
$('button').withPredicate({
name: 'Awesome Button',
someProperty: 'Some value'
});
// Internally, this will collect (map) the intersect of el.withValueForKey(value, key) for each key
Currently, specs must be ran in a browser via a static HTML file that servers as a spec runner. Add support for jasmine-headless and update RakeFile accordingly so that tests can be ran via rake outside of the browser.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.