codecraft-php/php-uiautomator
Composer 安装命令:
composer require codecraft-php/php-uiautomator
包简介
A PHP library for Android UI automation, built on top of xvq/php-adb and ReactPHP.
README 文档
README
A PHP library for Android UI automation, built on top of xvq/php-adb and ReactPHP.
Description
PHP UiAutomator allows automating interactions with Android applications via ADB (Android Debug Bridge). It provides a simple API to find UI elements and perform actions like clicking, entering text, etc.
Installation
Make sure you have Composer installed, then run:
composer require codecraft-php/php-uiautomator
Prerequisites
- PHP 8.0 or higher
- ADB installed and configured
- An Android device connected in USB debugging mode
Basic Usage
<?php require "vendor/autoload.php"; use CodeCraft\PhpUiAutomator\UiAutomator; use Xvq\PhpAdb\AdbClient; // Initialize ADB client $adbClient = new AdbClient(); $device = $adbClient->device(); // Create UiAutomator instance $uiautomator = new UiAutomator($device); // Disable redump for better performance (optional) $uiautomator->setRedump(false); // Find an element by its resource-id and click it $element = $uiautomator->findByResourceId("com.example.app:id/button"); $element->click(); // Enter text in an editable field $textField = $uiautomator->findByClass("android.widget.EditText"); $textField->setText("Hello World");
API
UiAutomator Class
__construct(Device $device): Initializes with an ADB device.setRedump(bool $dump): Enables/disables UI hierarchy redumping (default true).
Element Finding Methods
find(string $attribute, string $value): Find an element by generic attribute.findByClass(string $value): Find by class (e.g., "android.widget.Button").findByResourceId(string $value): Find by resource-id.findByText(string $value): Find by visible text.findByContentDesc(string $value): Find by content description.findAll(string $attribute, string $value): Find all matching elements (returns an array).
UiElement Class
Represents a found UI element.
Action Methods
click(): Clicks the element.doubleClick(): Double-clicks the element.longClick(int $duration = 1): Long press (in seconds).setText(string $text): Enters text (only for editable elements).
Properties
$info: UiElementInfo instance containing element information.
UiElementInfo Class
Provides information about the element.
Methods
toArray(): Returns all information as an array.getIndex(),getText(),getResourceId(), etc.: Individual accessors.isEditable(): Checks if the element is editable (based on class).
Exceptions
UiAutomatorException: General UiAutomator errors.UiElementNotFoundException: Element not found.UiElementNotEditableException: Attempt to input on a non-editable element.
Complete Example
<?php require "vendor/autoload.php"; use CodeCraft\PhpUiAutomator\UiAutomator; use Xvq\PhpAdb\AdbClient; $adbClient = new AdbClient(); $device = $adbClient->device(); $uiautomator = new UiAutomator($device); // Open an application $uiautomator->findByText("Open App")->click(); // Enter text in a search field $searchBox = $uiautomator->findByResourceId("com.app:id/search"); $searchBox->setText("search query"); // Click the search button $searchButton = $uiautomator->findByText("Search"); $searchButton->click();
License
MIT
codecraft-php/php-uiautomator 适用场景与选型建议
codecraft-php/php-uiautomator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 codecraft-php/php-uiautomator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codecraft-php/php-uiautomator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-06