User Interface Search - sikuli/sieveable GitHub Wiki

User Interface Search

Sieveable can search for apps by providing it with example elements from the layout files that define the appearance of the app's user interfaces.

Syntax:

A valid XML element or multiple elements using Android's XML layout syntax. For more information, see the official Android Layout documentation.

Sieveable UI Query Examples:

  • Find apps that have a LinearLayout with at least five Buttons.
MATCH app
WHERE
    <LinearLayout>
        <Button/>
        <Button/>
        <Button/>
        <Button/>
        <Button/>
    </LinearLayout>
RETURN app
  • Find apps that use a navigation drawer.
MATCH app
WHERE
    <android.support.v4.widget.DrawerLayout>
        <RelativeLayout/>
    </android.support.v4.widget.DrawerLayout>
RETURN app
  • Find apps that have a Sign up Button.
MATCH app
WHERE
    <Button android:text="Sign Up"/>
RETURN app
  • Find apps that have a Sign up TextView.
MATCH app
WHERE
    <TextView android:text="Sign Up"/>
RETURN app

Screenshots of the returned apps: App: Airbnb, version: 3.14.0

  • Find apps that have lists.
MATCH app
WHERE
    <ListView>
        <FrameLayout/>
        <FrameLayout/>
    </ListView>
RETURN app
  • Find apps Navigation Drawer.
MATCH app
WHERE
	<android.support.v4.widget.DrawerLayout>
	    <RelativeLayout>
	       <View/>
	       <FrameLayout/>
	    </RelativeLayout>
	</android.support.v4.widget.DrawerLayout>
RETURN app

Screenshots of the returned apps: App: Planet Fitness, version: 3.8

Advanced Examples

JSON Response

You can send an HTTP GET request to Sieveable and receive a JSON response from sieveable's server.

Get Button text values

MATCH app
WHERE
    <Button android:text="(*)"/>
RETURN app

Example: In this example, we use a user-friendly cURL-like tool named HTTPie to send an HTTP GET request to the server for the query shown above.

http GET http://localhost:3000/q/json \
queryText=='MATCH app\
WHERE\
<Button android:text="(*)"/>\
RETURN app, $1'

Below is a portion of the response:

Response:

    {
        "app": {
            "id": "com.google.android.apps.books-20921", 
            "packageName": "com.google.android.apps.books", 
            "version": "20921"
        }, 
        "listing": {}, 
        "manifest": {}, 
        "ui": {
            "returnAttributes": {
                "$1": [
                    "Rate & review", 
                    "Share", 
                    "Add account", 
                    "Wikipedia", 
                    "Search", 
                    "Rate & review", 
                    "Share", 
                    "Rate & review", 
                    "Share"
                ]
            }
        }
    } 

You may also rename the default $1 field using any alias you like.

Example:

http GET http://localhost:3000/q/json \
queryText=='MATCH app\
WHERE\
<Button android:text="(*)"/>\
RETURN app, u$1 as buttonText'

Notice the u in u$1 for the UI field. If you have more than one field, you can do: Return app, u$1 as foo, u$2 as bar and so on.

Response:

 {
        "app": {
            "id": "com.outfit7.talkingtom-73", 
            "packageName": "com.outfit7.talkingtom", 
            "version": "73"
        }, 
        "listing": {}, 
        "manifest": {}, 
        "ui": {
            "returnAttributes": {
                "buttonText": [
                    "Upload to Facebook", 
                    "Upload to YouTube", 
                    "Upload to Renren", 
                    "Upload to Facebook", 
                    "Upload to Renren", 
                    "Upload to YouTube", 
                    "OK", 
                    "Upload to Facebook", 
                    "Upload to YouTube", 
                    "Upload to Renren"
                ]
            }
        }
    }
⚠️ **GitHub.com Fallback** ⚠️