🎉The Python Client of appium-uiautomator2-server
English | 简体中文
Background
At present, only one project appium-uiautomator2-client that bypasses Appium Server and interacts with appium-uiautomator2-server alone is seen on Github for Python, but it is not compatible The baseUrl of the latest appium-uiautomator2-server v5.x API has not been published on pypi. I tried to contact the author but there was no reply, so I decided to write a maintenance. For the Java version, you can see the sonic-driver-core maintained by our organization.
How to use
- Install uiautomator2 server
You should install
sonic-appium-uiautomator2-server.apkandsonic-appium-uiautomator2-server-test.apkin Here.Alternatively, you can build your own Here
- Launch uiautomator2 server
adb shell am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner
- Forward ports
adb forward tcp:6790 tcp:6790
- Install Depends
pip install -U sonic-uia2-client
- Write your script
from common.models import AndroidSelector
from uia2.driver import AndroidDriver
import os
class TestDriver:
def __init__(self):
self.uia_url = "http://localhost:6790"
self.adb_serial_num = "DAISKnlasido"
self.package_name = "com.android.settings"
def test_demo(self):
# launch App
os.system(
"adb -s {} shell monkey -p {} -c android.intent.category.LAUNCHER 1".format(self.adb_serial_num,
self.package_name))
# connect remote uia2 server
driver = AndroidDriver(self.uia_url)
p = driver.get_page_source()
print(p)
e = driver.find_element(AndroidSelector.XPATH, "//*[@text='设置']")
if e is not None:
print(e.get_text())
e.send_keys("Hello")
Thanks
LICENSE
Metadata
Release files for sonic-uia2-client 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sonic_uia2_client-0.0.9.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sonic_uia2_client-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.1 kB
Release files / sonic_uia2_client-0.0.9.tar.gz
| Download URL | sonic_uia2_client-0.0.9.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8b1ce4dc64d41bd1b7590285b162976f82fb113de8523e73e2b8fd895c28a8a
|
|
BLAKE2b-256 checksum How to use checksums |
a01e8e685772aa2dba51e416bb7033a2e9d921085270e888bb8650725104f173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / sonic_uia2_client-0.0.9-py3-none-any.whl
| Download URL | sonic_uia2_client-0.0.9-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
720b2690d16268d60cb42fe4c7deae2a5e513d319adbdd0252677f9ad8363067
|
|
BLAKE2b-256 checksum How to use checksums |
f3fa2039dd661c6444e47c0c87c922df9423af5ac3a6fee0d9a20e22823c190e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|