Skip to content

Commit 85cb241

Browse files
#doc_adb_update
1 parent 9dbc5a9 commit 85cb241

File tree

2 files changed

+210
-22
lines changed

2 files changed

+210
-22
lines changed

docs/adb-commands-support.md

Lines changed: 162 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ result = driver.execute_script("lambda-adb",params)
103103

104104
### ADB Shell Command
105105

106+
LambdaTest allows execution of ADB shell commands during automated test runs.
107+
108+
#### ADB Shell Command - Public
109+
106110
- **adb shell dumpsys** <RealDeviceTag value="Real Device" />
107111

108-
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:
112+
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:
109113

110114
```python
111115
params = {"command": "shell", "text": "dumpsys package <package_info>"}
@@ -119,7 +123,7 @@ result = driver.execute_script("lambda-adb",params)
119123

120124
- **adb shell getprop** <VirtualDeviceTag value="Virtual Device" /> <RealDeviceTag value="Real Device" />
121125

122-
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:
126+
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:
123127

124128
```python
125129
params = {"command": "shell", "text": "getprop"}
@@ -131,27 +135,177 @@ result = driver.execute_script("lambda-adb",params)
131135
result = driver.execute_script("lambda-adb",params)
132136
```
133137

138+
- **adb shell cat /proc/version** <RealDeviceTag value="Real Device" />
134139

135-
- **adb shell ping -c 4 YOUR_URL** <VirtualDeviceTag value="Virtual Device" />
140+
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:
136141

137-
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:
142+
```python
143+
params = {"command": "shell", "text": "cat /proc/version"}
144+
result = driver.execute_script("lambda-adb",params)
145+
```
146+
147+
#### ADB Shell Command - Private
148+
149+
- **adb shell pm** <RealDeviceTag value="Real Device" />
150+
151+
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:
138152

139-
> **Note :** The **-c** is required in this command
140153
```python
141-
params = {"command": "shell", "text": "ping -c 4 google.com"}
154+
params = {"command": "shell", "text": "pm list packages"}
142155
result = driver.execute_script("lambda-adb",params)
143156
```
144157

145-
- **adb shell cat** <RealDeviceTag value="Real Device" />
158+
- **adb shell rm** <RealDeviceTag value="Real Device" />
146159

147-
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:
160+
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:
161+
162+
```python
163+
params = {"command": "shell", "text": "rm /sdcard/Download/tempfile.txt"}
164+
result = driver.execute_script("lambda-adb",params)
165+
```
166+
167+
168+
- **adb shell mkdir** <RealDeviceTag value="Real Device" />
169+
170+
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:
171+
172+
```python
173+
params = {"command": "shell", "text": "mkdir /sdcard/TestResults"}
174+
result = driver.execute_script("lambda-adb",params)
175+
```
176+
177+
- **adb shell screencap** <RealDeviceTag value="Real Device" />
178+
179+
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:
180+
181+
```python
182+
params = {"command": "shell", "text": "screencap /sdcard/screen.png"}
183+
result = driver.execute_script("lambda-adb",params)
184+
```
185+
186+
- **adb shell content** <RealDeviceTag value="Real Device" />
187+
188+
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:
189+
190+
```python
191+
params = {"command": "shell", "text": "content query --uri content://contacts/phones"}
192+
result = driver.execute_script("lambda-adb",params)
193+
```
194+
195+
196+
- **adb shell am** <RealDeviceTag value="Real Device" />
197+
198+
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:
199+
200+
```python
201+
params = {"command": "shell", "text": "am start -n com.example/.MainActivity"}
202+
result = driver.execute_script("lambda-adb",params)
203+
```
204+
- **adb shell dumpsys** <RealDeviceTag value="Real Device" />
205+
206+
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:
207+
208+
```python
209+
params = {"command": "shell", "text": "dumpsys package <package_info>"}
210+
result = driver.execute_script("lambda-adb",params)
211+
```
212+
Example -
213+
```python
214+
params = {"command": "shell", "text": "dumpsys package dumpsys input_method"}
215+
result = driver.execute_script("lambda-adb",params)
216+
```
217+
218+
- **adb shell getprop** <RealDeviceTag value="Real Device" />
219+
220+
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:
221+
222+
```python
223+
params = {"command": "shell", "text": "getprop"}
224+
result = driver.execute_script("lambda-adb",params)
225+
```
226+
227+
228+
- **adb shell setprop** <RealDeviceTag value="Real Device" />
229+
230+
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:
231+
232+
```python
233+
params = {"command": "shell", "text": "setprop debug.test true"}
234+
result = driver.execute_script("lambda-adb",params)
235+
```
236+
- **adb shell cat /proc/version** <RealDeviceTag value="Real Device" />
237+
238+
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:
148239

149240
```python
150241
params = {"command": "shell", "text": "cat /proc/version"}
151242
result = driver.execute_script("lambda-adb",params)
152243
```
244+
245+
- **adb shell ls** <RealDeviceTag value="Real Device" />
246+
247+
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.
248+
249+
#### These are the `ls` commands that can are enabled:
250+
251+
- `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.
252+
253+
- `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.
254+
255+
- `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.
256+
257+
```python
258+
# List files in the Downloads folder
259+
params = {"command": "shell", "text": "ls /sdcard/Download"}
260+
result = driver.execute_script("lambda-adb", params)
261+
# List files in the Pictures folder
262+
params = {"command": "shell", "text": "ls /sdcard/Pictures"}
263+
result = driver.execute_script("lambda-adb", params)
264+
# List files in the Movies folder
265+
params = {"command": "shell", "text": "ls /sdcard/Movies"}
266+
result = driver.execute_script("lambda-adb", params)
267+
```
268+
269+
- **adb shell cat** <RealDeviceTag value="Real Device" />
270+
271+
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.
272+
273+
#### These are the cat commands that can are enabled:
274+
- `cat /sdcard/Download/<filename>` — Outputs the contents of a file in the Downloads folder. Typically used to read logs, reports, or downloaded test artifacts.
275+
276+
- `cat /sdcard/Pictures/<filename>` — Outputs the raw binary data of an image file in the Pictures folder, useful for verifying screenshots or photos.
277+
278+
- `cat /sdcard/Movies/<filename>` — Outputs raw binary content of video files in the Movies folder, helpful for validating recorded or downloaded videos.
279+
280+
```python
281+
params = {"command": "shell", "text": "cat /proc/version"}
282+
result = driver.execute_script("lambda-adb", params)
283+
# Read a log or report from Downloads
284+
params = {"command": "shell", "text": "cat /sdcard/Download/test_log.txt"}
285+
result = driver.execute_script("lambda-adb", params)
286+
# Read an image file (raw binary) from Pictures
287+
params = {"command": "shell", "text": "cat /sdcard/Pictures/screenshot.png"}
288+
result = driver.execute_script("lambda-adb", params)
289+
# Read a video file (raw binary) from Movies
290+
params = {"command": "shell", "text": "cat /sdcard/Movies/test_video.mp4"}
291+
result = driver.execute_script("lambda-adb", params)
292+
```
153293
<img loading="lazy" src={require('../assets/images/appium-app/adb-commands.png').default} alt="Image" width="1444" height="703" className="doc_img img_center"/>
154294

295+
296+
### Additional ADB Shell Commands
297+
298+
- **adb shell ping -c 4 YOUR_URL** <VirtualDeviceTag value="Virtual Device" />
299+
300+
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:
301+
302+
> **Note :** The **-c** is required in this command
303+
```python
304+
params = {"command": "shell", "text": "ping -c 4 google.com"}
305+
result = driver.execute_script("lambda-adb",params)
306+
```
307+
308+
155309
### Enable/Disable Notification
156310

157311
- **enableNotification** <RealDeviceTag value="Real Device" /> <VirtualDeviceTag value="Virtual Device" />

0 commit comments

Comments
 (0)