https://github.com/raheesahmed/adb-input-field-extractor
This Python script uses the Android Debug Bridge (ADB) to extract information about input fields from the currently displayed screen of a connected Android device.
https://github.com/raheesahmed/adb-input-field-extractor
adb adbutils lxml python3
Last synced: 5 months ago
JSON representation
This Python script uses the Android Debug Bridge (ADB) to extract information about input fields from the currently displayed screen of a connected Android device.
- Host: GitHub
- URL: https://github.com/raheesahmed/adb-input-field-extractor
- Owner: RaheesAhmed
- Created: 2024-02-14T19:53:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-14T20:20:15.000Z (over 1 year ago)
- Last Synced: 2024-12-25T13:41:15.914Z (9 months ago)
- Topics: adb, adbutils, lxml, python3
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# ADB Input Field Extractor
This Python script uses the Android Debug Bridge (ADB) to extract information about input fields from the currently displayed screen of a connected Android device.
## Requirements
- Python 3.x
- [adbutils](https://pypi.org/project/adbutils/)
- [lxml](https://pypi.org/project/lxml/)
- ADB (Android Debug Bridge) installed and added to the system's PATH## Setup
1. **Install Python Dependencies:**
```bash
pip install -r requirments.txt
```**Enable USB Debugging on your Android device:**
1. Go to `Settings` > `About phone` > Tap `Build number` `7 times` to enable Developer
options.
1. Go back to `Settings` > `System` > `Developer options` > `Enable USB debugging`.
Connect your Android device to your computer via USB.## Usage
Run the Script:
```
python main.py
```The script will connect to the first available device, dump the UI hierarchy, parse the XML, and extract information about input fields such as text, resource ID, and bounds.
**The main function in your code performs the following tasks:**
- Connects to the first available Android device.
- Launches the specified application using the provided package name.
- Waits for a few seconds to allow the app to stabilize.
- Dumps the UI hierarchy of the currently displayed screen.
- Parses the XML of the UI hierarchy to extract information about input fields of type
android.widget.EditText.
- Prints the extracted input field data.Output:
The extracted input field information will be printed to the console in the following format:```
[
{
'text': 'example text',
'resource_id': 'com.example:id/inputField',
'bounds': '[0,0][100,100]'
},
...
]
```## Notes
The script currently only extracts information from input fields of type
android.widget.EditText.
Ensure that the screen you want to analyze is displayed on the device before running the
script.
The extraction process might take a few seconds, depending on the complexity of the UI.