### Target Context API Source: http://dtmilano.github.io/AndroidViewClient APIs for managing the target application context, including starting activities. ```APIDOC ## POST /targetcontext/start_activity ### Description Starts a specified activity within an application package. ### Method POST ### Endpoint /targetcontext/start_activity ### Parameters #### Request Body - **pkg** (string) - Required - The package name of the application. - **cls** (string) - Required - The fully qualified class name of the Activity to start. - **uri** (string) - Optional - A URI to be passed to the activity. ### Response #### Success Response (200) - **response** (object) - The API response from starting the activity. #### Response Example ```json { "response": {"success": true} } ``` ``` -------------------------------- ### WifiManager API Source: http://dtmilano.github.io/AndroidViewClient Simulates the Android WifiManager to get Wi-Fi state. ```APIDOC ## GET /wifimanager/state ### Description Gets the current Wi-Fi enabled state of the device. ### Method GET ### Endpoint /wifimanager/state ### Response #### Success Response (200) - **state** (string) - The Wi-Fi state (e.g., WIFI_STATE_DISABLED, WIFI_STATE_ENABLED). #### Response Example ```json { "state": "WIFI_STATE_ENABLED" } ``` ``` -------------------------------- ### ViewClient Initialization and Backends Source: http://dtmilano.github.io/AndroidViewClient Details on how to initialize the ViewClient and the different backend options available for interacting with the Android device. ```APIDOC ## ViewClient Class ViewClient is a ViewServer client. ### Backends * **ViewServer backend**: If not running, the ViewServer is started on the target device or emulator, and then the port mapping is created. * **LocalViewServer backend**: ViewServer is started as an application service instead of as a system service. * **UiAutomator backend**: No service is started. * **null backend**: Allows only operations using PX or DIP as hierarchy is not dumped and thus Views not recognized. * **UiAutomatorHelper backend**: Requires CulebraTester2-public installed on Android device. ### Initialization Parameters - `_device_`: The Android device object. - `_serialno_`: The serial number of the device. - `_adb_`: ADB client instance (optional). - `_autodump_`: Whether to automatically dump the view hierarchy (default: True). - `_forceviewserveruse_`: Force the use of ViewServer (default: False). - `_localport_`: Local port for ViewServer (optional). - `_remoteport_`: Remote port for ViewServer (optional). - `_startviewserver_`: Whether to start ViewServer (default: True). - `_ignoreuiautomatorkilled_`: Ignore if UiAutomator is killed (default: False). - `_compresseddump_`: Use compressed dump (default: True). - `_useuiautomatorhelper_`: Use UiAutomatorHelper (default: False). - `_debug_`: Debugging options (default: {}). ``` -------------------------------- ### Get Root Node Source: http://dtmilano.github.io/AndroidViewClient Method to get the root node of the View tree. ```APIDOC ## Get Root Node Gets the root node of the C{View} tree. ### Method GET ### Endpoint /getRoot ### Response #### Success Response (200) - **rootNode** (View) - The root node of the C{View} tree. ``` -------------------------------- ### Logging and Setup/Teardown Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for logging messages and setting up/tearing down test fixtures. ```APIDOC ## Logging and Setup/Teardown Methods ### `log(_message_ , _priority ='D'_)` Logs a message with the specified priority. Priority can be 'D' (Debug), 'I' (Info), 'W' (Warning), 'E' (Error), 'F' (Fatal). ### `setUp()` Hook method for setting up the test fixture before exercising it. ### `setUpClass()` Class method hook for setting up the class fixture before running tests in the class. ### `tearDown()` Hook method for deconstructing the test fixture after testing it. ### `tearDownClass()` Class method hook for deconstructing the class fixture after all tests in the class have run. ``` -------------------------------- ### connect() Function Source: http://dtmilano.github.io/AndroidViewClient Function to establish a connection to a device. ```APIDOC ## connect() Function ### Description Establishes a connection to an Android device. ``` -------------------------------- ### System Actions Source: http://dtmilano.github.io/AndroidViewClient APIs for performing system-level actions like pressing back, enter, or home buttons. ```APIDOC ## POST /press_back ### Description Simulates a press of the system's back button. ### Method POST ### Endpoint /press_back ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /press_enter ### Description Simulates a press of the system's enter button. ### Method POST ### Endpoint /press_enter ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /press_home ### Description Simulates a press of the system's home button. ### Method POST ### Endpoint /press_home ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /press_recent_apps ### Description Simulates a press of the system's recent apps button. ### Method POST ### Endpoint /press_recent_apps ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### UiDevice Class Source: http://dtmilano.github.io/AndroidViewClient Provides access to device state and simulation of user actions. ```APIDOC ## UiDevice Class ### `UiDevice(_vc_)` Constructor for the UiDevice class. ### `openNotification()` Opens the notification shade. ### `openQuickSettings()` Opens the Quick Settings shade. ### `openQuickSettingsSettings()` Opens the Quick Settings shade and then attempts to open Settings from there. ``` -------------------------------- ### UiAutomator2AndroidViewClient Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for UiAutomator2AndroidViewClient, including XML parsing callbacks. ```APIDOC ## UiAutomator2AndroidViewClient Methods ### Description Implements AndroidViewClient functionality using UiAutomator2, including SAX XML parsing callbacks. ### Methods - `CharacterData()` - `EndElement()` ``` -------------------------------- ### AdbClient Methods Source: http://dtmilano.github.io/AndroidViewClient This section details the methods available in the AdbClient class for interacting with an Android device via ADB. ```APIDOC ## AdbClient Methods ### Description Provides methods for interacting with an Android device using ADB commands. ### Methods #### `build()` ##### Description Gets build properties of the device. #### `display` ##### Description Provides access to the device's physical display properties (width, height, density). #### `drag(x0, y0, x1, y1, duration, steps=1, orientation=-1)` ##### Description Sends a drag event in Pixels (uses `input swipe` command). ##### Parameters - **(x0, y0)** (tuple) - Starting point in PX. - **(x1, y1)** (tuple) - Ending point in PX. - **duration** (int) - Duration of the event in milliseconds. - **steps** (int) - Number of steps (currently ignored). - **orientation** (int) - The orientation (-1: undefined). #### `dragDip(x0, y0, x1, y1, duration, steps=1, orientation=-1)` ##### Description Sends a drag event in Density-Independent Pixels (uses `input swipe` command). ##### Parameters - **(x0, y0)** (tuple) - Starting point in DIP. - **(x1, y1)** (tuple) - Ending point in DIP. - **duration** (int) - Duration of the event in milliseconds. - **steps** (int) - Number of steps (currently ignored). - **orientation** (int) - The orientation (-1: undefined). #### `getFocusedWindow()` ##### Description Gets the currently focused window. ##### Returns - **Window** - The focused window object. #### `getFocusedWindowName()` ##### Description Gets the name of the currently focused window. ##### Returns - **str** - The focused window name. #### `getLogicalDisplayInfo()` ##### Description Obtains logical display dimensions and density, including rotation, from `dumpsys`. #### `getPhysicalDisplayInfo()` ##### Description Obtains physical display dimensions and density from `dumpsys`. #### `getProperty(key, strip=True)` ##### Description Gets the value of a specific device property. ##### Parameters - **key** (str) - The property key. - **strip** (bool) - Whether to strip whitespace from the value. #### `getRestrictedScreen()` ##### Description Obtains restricted screen dimensions from `dumpsys`. #### `getSdkVersion()` ##### Description Gets the Android SDK version of the device. #### `imageInScreen(screen, image)` ##### Description Checks if a given image is present within a larger screen image. ##### Parameters - **screen** (Image) - The screen image. - **image** (Image) - The partial image to search for. ##### Returns - **bool** - True if the image is found, False otherwise. #### `imageToData(image, output_type=None)` ##### Description Extracts text and bounding box information from an image. ##### Parameters - **image** (Image) - The input image. - **output_type** (any) - The desired output format (default: pytesseract.Output.DICT). ##### Returns - **dict** - Data extracted from the image. #### `isKeyboardShown()` ##### Description Checks if the device's virtual keyboard is currently displayed. ##### Returns - **bool** - True if the keyboard is shown, False otherwise. #### `isLocked()` ##### Description Checks if the device screen is locked. ##### Returns - **bool** - True if the device is locked, False otherwise. #### `isScreenOn()` ##### Description Checks if the device screen is currently on. ##### Returns - **bool** - True if the screen is on, False otherwise. #### `longTouch(x, y, duration=2000, orientation=-1)` ##### Description Performs a long touch action at the specified coordinates. ##### Parameters - **x** (int) - The x-coordinate. - **y** (int) - The y-coordinate. - **duration** (int) - The duration of the touch in milliseconds (default: 2000). - **orientation** (int) - The orientation (-1: undefined). #### `percentSame(image1, image2)` ##### Description Compares two images and returns the percentage of identical pixels. ##### Parameters - **image1** (Image) - The first image. - **image2** (Image) - The second image. ##### Returns - **float** - The percentage of matching pixels. #### `sameAs(image1, image2, percent=1.0)` ##### Description Compares two images for similarity based on a percentage threshold. ##### Parameters - **image1** (Image) - The first image. - **image2** (Image) - The second image. - **percent** (float) - The similarity threshold (default: 1.0). ##### Returns - **bool** - True if images are similar enough, False otherwise. #### `screenshot_number` ##### Description Provides the current screenshot number count. #### `setTimer(timeout, description=None)` ##### Description Sets a timer for a specific operation. ##### Parameters - **timeout** (int) - The timeout duration in seconds. - **description** (str) - An optional description for the timer. ##### Returns - **timerId** - The ID of the set timer. #### `startActivity(component=None, flags=None, uri=None, package=None)` ##### Description Starts an Android Activity. If a package is provided, the main activity for that package will be resolved and launched. ##### Parameters - **component** (str) - The activity component name. - **flags** (str) - Activity flags. - **uri** (str) - A URI to launch with the activity. - **package** (str) - The package name. #### `takeSnapshot(reconnect=False, box=None)` ##### Description Takes a screenshot of the device. ##### Parameters - **reconnect** (bool) - Whether to reconnect after taking the screenshot (default: False). - **box** (tuple) - A tuple (left, top, right, bottom) to specify a region of the screen to capture. ##### Returns - **Image** - The captured screenshot as a PIL Image object. #### `unlock()` ##### Description Unlocks the device screen. ``` -------------------------------- ### UiAutomatorHelper TargetContext Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for interacting with the target application context. ```APIDOC ## UiAutomatorHelper TargetContext Methods ### Description Provides methods to interact with the application's context. ### Methods - `start_activity()` ``` -------------------------------- ### Window Hierarchy and Object Interaction Source: http://dtmilano.github.io/AndroidViewClient APIs for retrieving window hierarchy, finding objects, and checking for object existence. ```APIDOC ## GET /hierarchy ### Description Retrieves the window hierarchy of the current Android application. ### Method GET ### Endpoint /hierarchy ### Query Parameters - **_format** (string) - Optional - The desired format for the hierarchy (e.g., JSON, XML). ### Response #### Success Response (200) - **window_hierarchy** (object) - The hierarchical structure of the UI. ### Response Example ```json { "window_hierarchy": { "activity": "com.example.MainActivity", "views": [ { "id": "1", "class": "android.widget.LinearLayout", "children": [] } ] } } ``` ``` ```APIDOC ## POST /find_objects ### Description Finds UI objects based on provided criteria. This endpoint can use GET or POST depending on the arguments passed. ### Method GET or POST ### Endpoint /find_objects ### Request Body - **kwargs** (object) - Optional - Criteria for finding objects. ### Response #### Success Response (200) - **found_objects** (array) - A list of UI objects that match the criteria. ### Response Example ```json { "found_objects": [ { "id": "123", "text": "Sample Button" } ] } ``` ``` ```APIDOC ## POST /has_object ### Description Checks if a UI object with specific criteria exists. This endpoint can use GET or POST depending on the arguments passed. ### Method GET or POST ### Endpoint /has_object ### Request Body - **kwargs** (object) - Optional - Criteria for checking object existence. ### Response #### Success Response (200) - **exists** (boolean) - True if the object exists, False otherwise. ### Response Example ```json { "exists": true } ``` ``` ```APIDOC ## POST /ui_object/dump ### Description Dumps information about a specific UI element. ### Method POST ### Endpoint /ui_object/dump ### Request Body - **oid** (integer) - Required - The object ID of the UI element. ### Response #### Success Response (200) - **dump_info** (object) - Information about the UI element. ### Response Example ```json { "dump_info": { "text": "Button Text", "class": "android.widget.Button" } } ``` ``` ```APIDOC ## POST /ui_object/exists ### Description Checks if a specific UI element exists. ### Method POST ### Endpoint /ui_object/exists ### Request Body - **oid** (integer) - Required - The object ID of the UI element. ### Response #### Success Response (200) - **exists** (boolean) - True if the element exists, False otherwise. ### Response Example ```json { "exists": true } ``` ``` ```APIDOC ## POST /ui_object/get_child_count ### Description Counts the number of child views immediately under a given UI element. ### Method POST ### Endpoint /ui_object/get_child_count ### Request Body - **oid** (integer) - Required - The object ID of the parent UI element. ### Response #### Success Response (200) - **child_count** (integer) - The number of direct child views. ### Response Example ```json { "child_count": 5 } ``` ``` ```APIDOC ## POST /ui_object/get_class_name ### Description Retrieves the class name of a UI element. ### Method POST ### Endpoint /ui_object/get_class_name ### Request Body - **oid** (integer) - Required - The object ID of the UI element. ### Response #### Success Response (200) - **class_name** (string) - The class name of the UI element. ### Response Example ```json { "class_name": "android.widget.TextView" } ``` ``` ```APIDOC ## POST /ui_object/get_content_description ### Description Reads the content description property of a UI element. ### Method POST ### Endpoint /ui_object/get_content_description ### Request Body - **oid** (integer) - Required - The object ID of the UI element. ### Response #### Success Response (200) - **content_description** (string) - The content description of the UI element. ### Response Example ```json { "content_description": "Close button" } ``` ``` -------------------------------- ### UiAutomatorHelper ObjectStore Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for managing objects within the UiAutomatorHelper ObjectStore. ```APIDOC ## UiAutomatorHelper ObjectStore Methods ### Description Manages a store of objects for UI automation. ### Methods - `clear()` - `list()` - `remove()` ``` -------------------------------- ### View Class Methods and Properties Source: http://dtmilano.github.io/AndroidViewClient Detailed information about the View class, including methods for accessing properties, manipulating views, and interacting with the UI hierarchy. ```APIDOC ## View Class ### Description Represents a UI element in the Android view hierarchy. Provides methods to access its properties, children, and perform actions like touching. ### Methods - **add()**: Adds the view to the hierarchy. - **factory()**: Creates a view object. - **getBounds()**: Returns the bounds of the view. - **getCenter()**: Returns the center coordinates of the view. - **getChildren()**: Returns a list of the view's children. - **getClass()**: Returns the class name of the view. - **getContentDescription()**: Returns the content description of the view. - **getCoords()**: Returns the coordinates of the view. - **getHeight()**: Returns the height of the view. - **getId()**: Returns the ID of the view. - **getParent()**: Returns the parent view. - **getPositionAndSize()**: Returns the position and size of the view. - **getTag()**: Returns the tag of the view. - **getText()**: Returns the text of the view. - **getUniqueId()**: Returns the unique ID of the view. - **getVisibility()**: Returns the visibility state of the view. - **getWidth()**: Returns the width of the view. - **getX()**: Returns the X coordinate of the view. - **getXY()**: Returns the X and Y coordinates of the view. - **getY()**: Returns the Y coordinate of the view. - **isFocused()**: Checks if the view is currently focused. - **longTouch()**: Performs a long touch action on the view. - **obtain_selector()**: Obtains a selector for the view. - **touch()**: Performs a touch action on the view. - **writeImageToFile(filePath)**: Writes an image of the view to a file. ### Properties - **build**: Property related to building the view. - **children**: Property representing the children of the view. - **currentFocus**: Property for the currently focused view. - **device**: Property representing the associated device. - **forceviewserveruse**: Property to force the use of ViewServer. - **heightProperty**: Property for the view's height. - **idProperty**: Property for the view's ID. - **isFocusedProperty**: Property indicating if the view is focused. - **leftProperty**: Property for the view's left position. - **map**: Property for mapping view properties. - **parent**: Property for the parent view. - **tagProperty**: Property for the view's tag. - **target**: Property for the target of the view. - **textProperty**: Property for the view's text. - **topProperty**: Property for the view's top position. - **uiAutomatorHelper**: Helper for UiAutomator interactions. - **uiScrollable**: Property for scrollable behavior. - **useUiAutomator**: Property to enable UiAutomator. - **version**: Property for the view's version. - **widthProperty**: Property for the view's width. - **windowId**: Property for the view's window ID. ``` -------------------------------- ### Device Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for the Device class, including factory and qualifier checks. ```APIDOC ## Device Methods ### Description Provides methods for device management and information retrieval. ### Methods - `factory()` - `has_qualifier()` ``` -------------------------------- ### Key Press and Gestures Source: http://dtmilano.github.io/AndroidViewClient APIs for simulating key presses and performing swipe gestures. ```APIDOC ## POST /press_key_code ### Description Simulates pressing a specific key code. ### Method POST ### Endpoint /press_key_code ### Request Body - **key_code** (integer) - Required - The key code to press. - **meta_state** (integer) - Optional - The meta state (e.g., shift, control). ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /swipe ### Description Performs a swipe gesture on the screen. This endpoint can use GET or POST depending on the arguments passed. ### Method GET or POST ### Endpoint /swipe ### Request Body - **kwargs** (object) - Optional - Parameters defining the swipe gesture (e.g., startX, startY, endX, endY). ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /ui_object/perform_two_pointer_gesture ### Description Generates a two-pointer gesture with arbitrary starting and ending points for a specific UI element. ### Method POST ### Endpoint /ui_object/perform_two_pointer_gesture ### Request Body - **oid** (integer) - Required - The object ID of the UI element. - **startPoint1** (Tuple[int, int]) - Required - The starting coordinates for the first pointer. - **startPoint2** (Tuple[int, int]) - Required - The starting coordinates for the second pointer. - **endPoint1** (Tuple[int, int]) - Required - The ending coordinates for the first pointer. - **endPoint2** (Tuple[int, int]) - Required - The ending coordinates for the second pointer. - **steps** (integer) - Required - The number of steps for the gesture. ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /ui_object/pinch_in ### Description Performs a pinch-in gesture on a UI element. ### Method POST ### Endpoint /ui_object/pinch_in ### Request Body - **oid** (integer) - Required - The object ID of the UI element. - **percentage** (integer) - Required - The percentage of the object's diagonal length for the pinch gesture. - **steps** (integer) - Optional - The number of steps for the gesture (default: 50). ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /ui_object/pinch_out ### Description Performs a pinch-out gesture on a UI element. ### Method POST ### Endpoint /ui_object/pinch_out ### Request Body - **oid** (integer) - Required - The object ID of the UI element. - **percentage** (integer) - Required - The percentage of the object's diagonal length for the pinch gesture. - **steps** (integer) - Optional - The number of steps for the gesture (default: 50). ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. ### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### UiAutomatorHelper Until Methods Source: http://dtmilano.github.io/AndroidViewClient Utility methods for waiting for specific conditions within UiAutomatorHelper. ```APIDOC ## UiAutomatorHelper Until Methods ### Description Provides conditions to be used with wait methods. ### Methods - `find_object()` - `find_objects()` - `new_window()` ``` -------------------------------- ### POST /pinch Source: http://dtmilano.github.io/AndroidViewClient Performs a two-pointer pinch gesture on a specific UI object. ```APIDOC ## POST /pinch ### Description Performs a two-pointer gesture, where each pointer moves diagonally opposite across the other, from the center out towards the edges of the UiObject. ### Method POST ### Endpoint /pinch ### Parameters #### Request Body - **oid** (int) - Required - The object ID - **percentage** (float) - Required - Percentage of the object’s diagonal length for the pinch gesture - **steps** (int) - Required - The number of steps for the gesture ``` -------------------------------- ### ViewClient Methods Source: http://dtmilano.github.io/AndroidViewClient Core methods of the ViewClient class for finding, interacting with, and traversing UI elements. ```APIDOC ## ViewClient Methods ### Description The main class for interacting with the Android UI. It provides methods for finding views by various attributes, performing actions, and traversing the view hierarchy. ### Methods - **adb**: Access to ADB commands. - **assertServiceResponse()**: Asserts the service response. - **build**: Property related to building the ViewClient. - **click(view)**: Clicks on a given view. - **connectToDeviceOrExit(serial=None)**: Connects to the device or exits if connection fails. - **device**: Property representing the connected device. - **display**: Property representing the device's display. - **distance(view1, view2)**: Calculates the distance between two views. - **distanceTo(view, x, y)**: Calculates the distance from a view to a point. - **dump()**: Dumps the current view hierarchy. - **findViewById(id)**: Finds a view by its ID. - **findViewByIdOrRaise(id)**: Finds a view by its ID or raises an exception if not found. - **findViewByTag(tag)**: Finds a view by its tag. - **findViewByTagOrRaise(tag)**: Finds a view by its tag or raises an exception if not found. - **findViewWithAttribute(attribute, value)**: Finds a view with a specific attribute and value. - **findViewWithAttributeOrRaise(attribute, value)**: Finds a view with a specific attribute and value or raises an exception. - **findViewWithAttributeThatMatches(attribute, regex)**: Finds a view where an attribute matches a regex. - **findViewWithContentDescription(description)**: Finds a view by its content description. - **findViewWithContentDescriptionOrRaise(description)**: Finds a view by its content description or raises an exception. - **findViewWithTextOrRaise(text)**: Finds a view by its text or raises an exception. - **findViewsContainingPoint(x, y)**: Finds all views containing the given point. - **findViewsWithAttribute(attribute)**: Finds all views with a specific attribute. - **findViewsWithAttributeThatMatches(attribute, regex)**: Finds all views where an attribute matches a regex. - **forceViewServerUse**: Property to force ViewServer usage. - **getRoot()**: Gets the root view of the hierarchy. - **getSdkVersion()**: Gets the Android SDK version. - **getViewIds()**: Gets a list of all view IDs. - **getViewsById()**: Gets a dictionary of views keyed by their IDs. - **hammingDistance(str1, str2)**: Calculates the Hamming distance between two strings. - **ignoreUiAutomatorKilled**: Property to ignore UiAutomator killed exceptions. - **imageDirectory**: Directory to save images. - **isKeyboardShown()**: Checks if the keyboard is currently shown. - **levenshteinDistance(str1, str2)**: Calculates the Levenshtein distance between two strings. - **list()**: Lists available views. - **osName**: The name of the operating system. - **pressKeyCode(keyCode, metaState=0)**: Presses a key code. - **ro**: Property for read-only access. - **root**: Property for the root view. - **serialno**: The serial number of the device. - **serviceResponse()**: Gets the response from the ViewServer service. - **setViews(views)**: Sets the current list of views. - **setViewsFromUiAutomatorDump(dump)**: Sets views based on a UiAutomator dump. - **sleep(seconds)**: Pauses execution for a specified duration. - **traverse()**: Traverses the view hierarchy. - **traverseShowClassIdAndText()**: Traverses and shows class, ID, and text. - **traverseShowClassIdTextAndBounds()**: Traverses and shows class, ID, text, and bounds. - **traverseShowClassIdTextAndCenter()**: Traverses and shows class, ID, text, and center coordinates. - **traverseShowClassIdTextAndContentDescription()**: Traverses and shows class, ID, text, and content description. - **traverseShowClassIdTextAndTag()**: Traverses and shows class, ID, text, and tag. - **traverseShowClassIdTextAndUniqueId()**: Traverses and shows class, ID, text, and unique ID. - **traverseShowClassIdTextContentDescriptionAndScreenshot()**: Traverses and shows class, ID, text, content description, and takes a screenshot. - **traverseShowClassIdTextPositionAndSize()**: Traverses and shows class, ID, text, position, and size. - **traverseTakeScreenshot()**: Traverses the hierarchy and takes screenshots. - **uiAutomatorHelper**: Helper for UiAutomator interactions. - **uiDevice**: Property for the UiDevice object. - **viewsById**: Dictionary of views keyed by ID. - **windows**: Property representing the device's windows. - **writeImageToFile(view, filePath)**: Writes an image of a view to a file. - **writeViewImageToFileInDir(view, directory)**: Writes an image of a view to a specified directory. ### Constants - **TRAVERSE_CIT()**: Constant for traversal. - **TRAVERSE_CITB()**: Constant for traversal. - **TRAVERSE_CITC()**: Constant for traversal. - **TRAVERSE_CITCD()**: Constant for traversal. - **TRAVERSE_CITCDS()**: Constant for traversal. - **TRAVERSE_CITG()**: Constant for traversal. - **TRAVERSE_CITPS()**: Constant for traversal. - **TRAVERSE_CITUI()**: Constant for traversal. - **TRAVERSE_S()**: Constant for traversal. ``` -------------------------------- ### WifiManager Methods Source: http://dtmilano.github.io/AndroidViewClient Methods for managing Wi-Fi state on the device. ```APIDOC ## WifiManager Methods ### Description Provides methods for checking the Wi-Fi state of the device. ### Methods - `getWifiState()` ``` -------------------------------- ### UI State Management Source: http://dtmilano.github.io/AndroidViewClient Methods for managing UI state and properties. ```APIDOC ## GET /isKeyboardShown ### Description Checks if the device keyboard is currently displayed. ### Method GET ### Endpoint /isKeyboardShown ### Response #### Success Response (200) - **is_shown** (boolean) - True if the keyboard is shown, False otherwise. ### Response Example ```json { "is_shown": true } ``` ``` ```APIDOC ## GET /ignoreUiAutomatorKilled ### Description Gets the current setting for ignoring the 'Killed' message from UiAutomator. ### Method GET ### Endpoint /ignoreUiAutomatorKilled ### Response #### Success Response (200) - **ignore_killed** (boolean) - True if the 'Killed' message is ignored, False otherwise. ### Response Example ```json { "ignore_killed": true } ``` ## PUT /ignoreUiAutomatorKilled ### Description Sets whether to ignore the 'Killed' message from UiAutomator. ### Method PUT ### Endpoint /ignoreUiAutomatorKilled ### Parameters #### Request Body - **ignore_killed** (boolean) - Required - Set to True to ignore the 'Killed' message, False otherwise. ### Request Example ```json { "ignore_killed": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## GET /imageDirectory ### Description Gets the directory used to store screenshot images. ### Method GET ### Endpoint /imageDirectory ### Response #### Success Response (200) - **directory** (string) - The path to the image directory. ### Response Example ```json { "directory": "/sdcard/screenshots" } ``` ## PUT /imageDirectory ### Description Sets the directory used to store screenshot images. ### Method PUT ### Endpoint /imageDirectory ### Parameters #### Request Body - **directory** (string) - Required - The path for the screenshot image directory. ### Request Example ```json { "directory": "/sdcard/screenshots" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## GET /osName ### Description Gets the operating system name. ### Method GET ### Endpoint /osName ### Response #### Success Response (200) - **os_name** (string) - The name of the operating system. ### Response Example ```json { "os_name": "Darwin" } ``` ``` ```APIDOC ## GET /ro ### Description Retrieves the device's read-only properties. ### Method GET ### Endpoint /ro ### Response #### Success Response (200) - **properties** (dict) - A dictionary containing read-only properties like secure and debuggable. ### Response Example ```json { "properties": { "secure": true, "debuggable": false } } ``` ``` ```APIDOC ## GET /root ### Description Retrieves the root node of the view hierarchy. ### Method GET ### Endpoint /root ### Response #### Success Response (200) - **root_node** (dict) - The root node object. ### Response Example ```json { "root_node": { "id": "ROOT", "children": [] } } ``` ``` ```APIDOC ## GET /serialno ### Description Retrieves the serial number of the device. ### Method GET ### Endpoint /serialno ### Response #### Success Response (200) - **serial_number** (string) - The serial number of the device. ### Response Example ```json { "serial_number": "emulator-5554" } ``` ``` ```APIDOC ## POST /serviceResponse ### Description Checks the response received from the ViewServer. ### Method POST ### Endpoint /serviceResponse ### Parameters #### Request Body - **response** (str) - Required - The response string received from the ViewServer. ### Request Example ```json { "response": "RESPONSE_OK" } ``` ### Response #### Success Response (200) - **is_valid** (boolean) - True if the response is valid, False otherwise. ### Response Example ```json { "is_valid": true } ``` ``` ```APIDOC ## POST /setViews ### Description Sets the internal views map with the received value, splitting it into lines. ### Method POST ### Endpoint /setViews ### Parameters #### Request Body - **received** (str) - Required - The string received from the View Server. - **windowId** (str) - Optional - The ID of the window to set views for. ### Request Example ```json { "received": "view1\nview2\nview3", "windowId": "com.example.app" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. ### Response Example ```json { "status": "success" } ``` ``` ```APIDOC ## POST /setViewsFromUiAutomatorDump ### Description Sets the internal views map by parsing the received XML from UI Automator. ### Method POST ### Endpoint /setViewsFromUiAutomatorDump ### Parameters #### Request Body - **received** (str) - Required - The XML string received from UI Automator. ### Request Example ```json { "received": "Hello" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. ### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Utility Methods Source: http://dtmilano.github.io/AndroidViewClient Utility functions for sleeping and traversing the view hierarchy. ```APIDOC ## POST /sleep ### Description Sleeps for the specified number of seconds. ### Method POST ### Endpoint /sleep ### Parameters #### Request Body - **secs** (float) - Optional - The number of seconds to sleep. Defaults to 1.0. ### Request Example ```json { "secs": 2.5 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates that the sleep operation completed. ### Response Example ```json { "status": "slept" } ``` ``` ```APIDOC ## POST /traverse ### Description Traverses the View tree and prints its nodes. Transformations can be specified. ### Method POST ### Endpoint /traverse ### Parameters #### Request Body - **root** (dict) - Optional - The root node from where the traverse starts. Defaults to 'ROOT'. - **indent** (str) - Optional - The indentation string to use for printing nodes. Defaults to an empty string. - **transform** (str) - Optional - The name of a method to use to transform the node before printing. - **stream** (str) - Optional - The output stream to use. Defaults to standard output. ### Request Example ```json { "root": {"id": "ROOT"}, "indent": " ", "transform": "_traverseShowClassIdTextAndBounds" } ``` ### Response #### Success Response (200) - **output** (string) - The traversed and formatted view hierarchy. ### Response Example ```json { "output": "ROOT\n - View1\n - View1.1" } ``` ``` ```APIDOC ## POST /traverseShowClassIdAndText ### Description Shows the View class, id, and text if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdAndText ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. - **extraInfo** (str) - Optional - The name of a View method to add extra info. - **noExtraInfo** (str) - Optional - A string indicating not to add extra info. - **extraAction** (str) - Optional - The name of a method to invoke for every view. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK"}, "extraInfo": "getContentDescription" } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK" } ``` ``` ```APIDOC ## POST /traverseShowClassIdTextAndBounds ### Description Shows the View class, id, text, and bounds if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdTextAndBounds ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK", "bounds": [10, 20, 50, 60]} } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view with bounds. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK bounds=[10, 20, 50, 60]" } ``` ``` ```APIDOC ## POST /traverseShowClassIdTextAndCenter ### Description Shows the View class, id, text, and center coordinates if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdTextAndCenter ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK", "center": [30, 40]} } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view with center coordinates. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK center=(30, 40)" } ``` ``` ```APIDOC ## POST /traverseShowClassIdTextAndContentDescription ### Description Shows the View class, id, text, and content description if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdTextAndContentDescription ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK", "contentDescription": "Submit button"} } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view with content description. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK contentDescription=Submit button" } ``` ``` ```APIDOC ## POST /traverseShowClassIdTextAndTag ### Description Shows the View class, id, text, and tag if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdTextAndTag ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK", "tag": "submit"} } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view with tag. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK tag=submit" } ``` ``` ```APIDOC ## POST /traverseShowClassIdTextAndUniqueId ### Description Shows the View class, id, text, and unique id if available. Can be used as a transform function for `traverse`. ### Method POST ### Endpoint /traverseShowClassIdTextAndUniqueId ### Parameters #### Request Body - **view** (dict) - Required - The View object to process. ### Request Example ```json { "view": {"class": "Button", "id": "btn1", "text": "OK", "uniqueId": "12345"} } ``` ### Response #### Success Response (200) - **formatted_view** (string) - The formatted string representing the view with unique id. ### Response Example ```json { "formatted_view": "Button id=btn1 text=OK uniqueId=12345" } ``` ``` -------------------------------- ### POST /click Source: http://dtmilano.github.io/AndroidViewClient Performs a click action on a UI object. ```APIDOC ## POST /click ### Description Clicks on this object. ### Method POST ### Endpoint /click ### Parameters #### Request Body - **oid** (int) - Required - The object ID ```