GithubHelp home page GithubHelp logo

jaykz52 / mechanic Goto Github PK

View Code? Open in Web Editor NEW
138.0 138.0 28.0 5.93 MB

A CSS-style selector engine for iOS UIAutomation

Home Page: www.cozykozy.com/mechanicjs

License: MIT License

Ruby 2.63% JavaScript 95.77% CSS 1.61%

mechanic's People

Contributors

boxiong avatar codef0rmerz avatar hs025828 avatar jackdanger avatar jaykz52 avatar jlipps avatar mansibarodia avatar misttar avatar nachosoto avatar phatmann avatar sourishkrout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mechanic's Issues

find/filter oddness

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

index of issue

I have a cancel uibarbuttonitem. When I do this $("#Cancel").index(), the result is -1. Am I missing something here? Just to clarify, $("#Cancel") does work by itself but .index() won't able to retrieve the right index.

Can't find CollectionView

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.

Support for more complex selectors

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'});

iOS8 beta breaks mechanic

This simple script fails:

#import /Users/saucelabs/Desktop/mechanic.js
$.log("foo");

Looks like #import no longer puts everything into the same scope?

Is $() recursive?

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.

Element lookup error

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)')

Fix formatting in src files

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.)

README.md mistake re mechanic.js

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.

Implement .prev() and .next()

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.

Error on line 67 of mechanic.js

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

predicate() should support key/value map to filter selection

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

Specs should be able to be ran headless

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.