From 85cb241a331ee5ba7b011e829fa02641c2e52269 Mon Sep 17 00:00:00 2001 From: Deepasnhu-product Date: Mon, 23 Jun 2025 19:56:06 +0530 Subject: [PATCH] #doc_adb_update --- docs/adb-commands-support.md | 170 ++++++++++++++++++++++++++++++++-- docs/realdevices-adb-shell.md | 62 ++++++++++--- 2 files changed, 210 insertions(+), 22 deletions(-) diff --git a/docs/adb-commands-support.md b/docs/adb-commands-support.md index 93ab8e14d..1d3eced8a 100644 --- a/docs/adb-commands-support.md +++ b/docs/adb-commands-support.md @@ -103,9 +103,13 @@ result = driver.execute_script("lambda-adb",params) ### ADB Shell Command +LambdaTest allows execution of ADB shell commands during automated test runs. + +#### ADB Shell Command - Public + - **adb shell dumpsys** - This command is used to obtain detailed information about installed packages on device. When you run this command, it provides a list of information for each package installed on the device. The output includes various details about each package.The following is a Python sample using the adb command: + The `adb shell dumpsys` command is used to obtain detailed information about installed packages on device. When you run this command, it provides a list of information for each package installed on the device. The output includes various details about each package.The following is a Python sample using the adb command: ```python params = {"command": "shell", "text": "dumpsys package "} @@ -119,7 +123,7 @@ result = driver.execute_script("lambda-adb",params) - **adb shell getprop** - This command is used to retrieve system properties from an Android device. When executed, it provides a list of key-value pairs representing various system settings and configurations. These properties include information about the device's build, hardware, and other system-related details. The output can be useful for debugging, development or understanding the device's current state. The following is a Python sample using the adb command: + The command `adb shell getprop` is used to retrieve system properties from an Android device. When executed, it provides a list of key-value pairs representing various system settings and configurations. These properties include information about the device's build, hardware, and other system-related details. The output can be useful for debugging, development or understanding the device's current state. The following is a Python sample using the adb command: ```python params = {"command": "shell", "text": "getprop"} @@ -131,27 +135,177 @@ result = driver.execute_script("lambda-adb",params) result = driver.execute_script("lambda-adb",params) ``` +- **adb shell cat /proc/version** -- **adb shell ping -c 4 YOUR_URL** + The `adb shell cat /proc/version` command outputs detailed information about the Linux kernel version running on the Android device, including the build date and compiler details. This information is essential for debugging compatibility issues and understanding the device’s operating system internals.The following is a Python sample using the adb command: - This command is used to test the network connectivity between the Android device and a specified host, such as `google.com`. When executed it sends four ICMP request packets to the host and wait for responses. The output includes details such as packet transmission time, success rate and round-trip time, which helps diagnose network connectivity and latency issues. The following is a Python sample using the adb command: + ```python + params = {"command": "shell", "text": "cat /proc/version"} + result = driver.execute_script("lambda-adb",params) + ``` + +#### ADB Shell Command - Private + +- **adb shell pm** + + The `adb shell pm` command enables management of Android apps programmatically. It supports installing, uninstalling, clearing data, and querying installed packages. The following is a Python sample using the adb command: - > **Note :** The **-c** is required in this command ```python - params = {"command": "shell", "text": "ping -c 4 google.com"} + params = {"command": "shell", "text": "pm list packages"} result = driver.execute_script("lambda-adb",params) ``` -- **adb shell cat** +- **adb shell rm** - This command provides detailed information about the system’s kernel version and build information. It outputs the Linux kernel version, along with build information such as the GCC version used to compile the kernel. This command is useful when you need to check the underlying kernel version of the Android device, typically for compatibility checks, debugging, or ensuring that a device meets specific requirements for apps or tests. The following is a Python sample using the adb command: + The `adb shell rm` command is used to delete files or directories from the Android device's filesystem directly from your terminal or during automated test execution. It helps in clearing residual data, removing temporary test files, or resetting the test environment by deleting specific logs, APKs, screenshots, or other generated data. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "rm /sdcard/Download/tempfile.txt"} + result = driver.execute_script("lambda-adb",params) + ``` + + +- **adb shell mkdir** + + The `adb shell mkdir` command is used to create new directories on an Android device’s filesystem. It is especially useful when preparing the device environment before automated test runs—ensuring that the required folder structure exists for storing screenshots, logs, or other test-related files. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "mkdir /sdcard/TestResults"} + result = driver.execute_script("lambda-adb",params) + ``` + +- **adb shell screencap** + + The `adb shell screencap` command captures the current screen on a real device and saves it as an image file. It’s useful for debugging UI issues or validating visual test results during automation. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "screencap /sdcard/screen.png"} + result = driver.execute_script("lambda-adb",params) + ``` + +- **adb shell content** + + The `adb shell content` command interacts with Android’s content providers to query, insert, update, or delete shared data like contacts, SMS, or calendar entries. It's commonly used in tests to read data, insert test entries, or reset content to a known state. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "content query --uri content://contacts/phones"} + result = driver.execute_script("lambda-adb",params) + ``` + + +- **adb shell am** + + The `adb shell am command` uses the Activity Manager to control app components on a real device. It’s useful for launching activities, restarting apps, or sending broadcast intents—commonly done during tests to simulate user actions or reset app state. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "am start -n com.example/.MainActivity"} + result = driver.execute_script("lambda-adb",params) + ``` +- **adb shell dumpsys** + + The `adb shell dumpsys` command is used to obtain detailed information about installed packages on device. When you run this command, it provides a list of information for each package installed on the device. The output includes various details about each package.The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "dumpsys package "} + result = driver.execute_script("lambda-adb",params) + ``` + Example - + ```python + params = {"command": "shell", "text": "dumpsys package dumpsys input_method"} + result = driver.execute_script("lambda-adb",params) + ``` + +- **adb shell getprop** + + The `abd shell getprop` command retrieves system-level properties in the form of key-value pairs. These properties include internal runtime details such as device model, manufacturer, OS version, network state, security patch level, and debug flags. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "getprop"} + result = driver.execute_script("lambda-adb",params) + ``` + + +- **adb shell setprop** + + The `adb shell setprop` command sets system properties on a real device, allowing you to modify device behavior. It’s often used to change debug flags, adjust logging levels, or simulate different configurations and network conditions during testing. The following is a Python sample using the adb command: + + ```python + params = {"command": "shell", "text": "setprop debug.test true"} + result = driver.execute_script("lambda-adb",params) + ``` +- **adb shell cat /proc/version** + + The `adb shell cat /proc/version` command outputs detailed information about the Linux kernel version running on the Android device, including the build date and compiler details. This information is essential for debugging compatibility issues and understanding the device’s operating system internals.The following is a Python sample using the adb command: ```python params = {"command": "shell", "text": "cat /proc/version"} result = driver.execute_script("lambda-adb",params) ``` + +- **adb shell ls** + + The `adb shell ls` command lists files and directories within a specified folder on the Android device. It is commonly used during automated tests to verify the presence and contents of files created, modified, or downloaded by the app. This helps ensure test artifacts are correctly generated and stored on the device. + + #### These are the `ls` commands that can are enabled: + + - `ls /sdcard/Download` — Lists all files and directories inside the Downloads folder. Typically used to check if test downloads or app-generated files exist, and to validate proper file creation or cleanup. + + - `ls /sdcard/Pictures` — Lists all files in the Pictures directory, which usually stores photos and screenshots. Useful for confirming screenshots are saved correctly or for accessing images created during tests. + + - `ls /sdcard/Movies` — Lists media files in the Movies folder. Commonly used to validate recorded or downloaded videos and manage video artifacts from test executions. + + ```python + # List files in the Downloads folder + params = {"command": "shell", "text": "ls /sdcard/Download"} + result = driver.execute_script("lambda-adb", params) + # List files in the Pictures folder + params = {"command": "shell", "text": "ls /sdcard/Pictures"} + result = driver.execute_script("lambda-adb", params) + # List files in the Movies folder + params = {"command": "shell", "text": "ls /sdcard/Movies"} + result = driver.execute_script("lambda-adb", params) + ``` + +- **adb shell cat** + + The `adb shell cat` command in Android's shell outputs a file’s contents to the console, allowing quick access to text or binary data on the device. Short for “concatenate,” it’s a common Linux command used to read files. In automation, cat helps inspect logs, reports, images, or videos without manual device access. Text files show readable content, while binary files output raw data that may need special handling. + + #### These are the cat commands that can are enabled: + - `cat /sdcard/Download/` — Outputs the contents of a file in the Downloads folder. Typically used to read logs, reports, or downloaded test artifacts. + + - `cat /sdcard/Pictures/` — Outputs the raw binary data of an image file in the Pictures folder, useful for verifying screenshots or photos. + + - `cat /sdcard/Movies/` — Outputs raw binary content of video files in the Movies folder, helpful for validating recorded or downloaded videos. + + ```python + params = {"command": "shell", "text": "cat /proc/version"} + result = driver.execute_script("lambda-adb", params) + # Read a log or report from Downloads + params = {"command": "shell", "text": "cat /sdcard/Download/test_log.txt"} + result = driver.execute_script("lambda-adb", params) + # Read an image file (raw binary) from Pictures + params = {"command": "shell", "text": "cat /sdcard/Pictures/screenshot.png"} + result = driver.execute_script("lambda-adb", params) + # Read a video file (raw binary) from Movies + params = {"command": "shell", "text": "cat /sdcard/Movies/test_video.mp4"} + result = driver.execute_script("lambda-adb", params) + ``` Image + +### Additional ADB Shell Commands + +- **adb shell ping -c 4 YOUR_URL** + + This command is used to test the network connectivity between the Android device and a specified host, such as `google.com`. When executed it sends four ICMP request packets to the host and wait for responses. The output includes details such as packet transmission time, success rate and round-trip time, which helps diagnose network connectivity and latency issues. The following is a Python sample using the adb command: + + > **Note :** The **-c** is required in this command + ```python + params = {"command": "shell", "text": "ping -c 4 google.com"} + result = driver.execute_script("lambda-adb",params) + ``` + + ### Enable/Disable Notification - **enableNotification** diff --git a/docs/realdevices-adb-shell.md b/docs/realdevices-adb-shell.md index d3ad4c6cf..f07f9c7c6 100644 --- a/docs/realdevices-adb-shell.md +++ b/docs/realdevices-adb-shell.md @@ -67,20 +67,54 @@ The integration of Android Debug Bridge (ADB) shell support within the LambdaTes ## Supported ADB Commands To ensure security and compatibility, we have a list of ADB commands that can be executed within our Real Device Cloud. Please refer to the following list of supported commands: -| **ADB Command** | **Description** | -|--------------------------------------------------|------------------------------------------------------------------| -| am start | Launches an activity specified by an intent. | -| am force-stop | Stops the specified application package. | -| pm clear | Deletes all data associated with a package. | -| input | Sends touch or key events to the device. | -| ls | Lists directory contents on the device. | -| echo | Displays messages on the device. | -| grep | Searches for patterns in files on the device. | -| pwd | Prints the current working directory on the device. | -| dumpsys | Dumps system information from the device. | -| getprop | Retrieves device properties. | -| cat | Helps in compatibility checks, debugging and system diagnostics. | - +### Supported ADB Commands - Public Device + +| Command |Description | +| --------------------------------------| ------------------------------------------------------------------------- | +| `am start` | Launches an activity on the device. Useful for opening apps or specific screens. | +| `am force-stop` | Force-stops an application by its package name. | +| `pm clear` | Clears all data associated with a package (app). | +| `input` | Simulates user input like taps, swipes, or key events. | +| `ls` | Lists files and directories. Commonly used to inspect folders like `/sdcard/Download`. | +| `echo` | Prints text to the terminal. Useful for testing output or scripting. | +| `grep` | Searches for text patterns. Useful for filtering logs or command output. | +| `pwd` | Displays the current working directory. | +| `dumpsys` | Dumps system service information (battery, activity, memory, etc.). | +| `getprop` | Gets system properties. Often used for device diagnostics. | +| `am compat enable` | Enables app compatibility options. | +| `cmd connectivity airplane-mode`| Toggles airplane mode on/off (requires permissions). | +| `setprop debug.firebase.analytics.app`| Enables Firebase Analytics debug mode for a specific app. | +| `log.tag.FA` | Firebase Analytics SDK logs (e.g., event recording, session start). | +| `log.tag.FA-SVC` | Firebase background service logs (e.g., data uploads, scheduled jobs). | +| `wm fixed-to-user-rotation` | Controls screen rotation policy. | +| `setprop` | Sets system properties (admin/debug use cases). | +| `logcat` | Outputs system logs in real-time. Crucial for debugging. | +| `am instrument` | Starts Android test instrumentation (e.g., Espresso/UI tests). | +| `am broadcast` | Sends a broadcast intent. Useful for triggering specific events. | +| `ls /sdcard/Download` | Lists all files and folders located in the device's Download folder. | +| `ls /sdcard/Pictures` | Lists all files and folders located in the device's Pictures folder. | +| `ls /sdcard/Movies` | Lists all files and folders located in the device's Movies folder. | +| `cat /sdcard/Download/` | Displays the content of a specific file inside the Download folder. | +| `cat /sdcard/Pictures/` | Displays the content of a specific file inside the Pictures folder. | +| `cat /sdcard/Movies/` | Displays the content of a specific file inside the Movies folder. | +| `cat /proc/version` | Displays kernel version and build info. | +| `pm list packages` | Lists all installed apps on the device. | + +### Supported ADB Commands - Private Device + +| Command | Description | +| ------------------------------------------------- | ------------------------------------------------------------ | +| `setprop` | Sets custom system properties (e.g., for debugging frameworks). | +| `logcat` | Streams real-time logs from device, including app logs. | +| `am instrument` | Executes instrumented tests. Often used in automated testing pipelines. | +| `am broadcast` | Sends custom broadcast messages for triggering in-app actions. | +| `ls /sdcard/Download` | Lists all files and folders located in the device's Download folder. | +| `ls /sdcard/Pictures` | Lists all files and folders located in the device's Pictures folder. | +| `ls /sdcard/Movies` | Lists all files and folders located in the device's Movies folder. | +| `cat /sdcard/Download/` | Displays the content of a specific file inside the Download folder. | +| `cat /sdcard/Pictures/` | Displays the content of a specific file inside the Pictures folder. | +| `cat /sdcard/Movies/` | Displays the content of a specific file inside the Movies folder. | +| `pm list packages` | Lists installed app packages for inspection or automation logic. | > If the command you require is not listed, please reach out at our window.openLTChatWidget()}>24x7 Chat Support or you could also mail us at support@lambdatest.com.