Search code examples
calabashcalabash-ioscalabash-android

Is there a NOT operator in calabash query syntax?


The title pretty well covers my question. How can I (for instance) obtain all the TextView elements whose IDs do NOT CONTAIN "some_prefix"? I can obtain all TextView elements and iterate over them, kicking out the ones I don't like (and I probably will), but I'd rather have a clear query which does that for me.


Solution

  • It's inefficient, but you can do:

    query("android.widget.TextView") -
        query("android.widget.TextView {id CONTAINS[c] 'some_prefix'}")
    

    The first query gets the set of all TextViews, then excludes those that contain 'some_prefix' as returned in the second query.