uiautodev 0.3.4__py3-none-any.whl → 0.3.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uiautodev/app.py +1 -1
- uiautodev/common.py +1 -1
- uiautodev/driver/android.py +15 -17
- uiautodev/router/device.py +7 -0
- {uiautodev-0.3.4.dist-info → uiautodev-0.3.6.dist-info}/METADATA +2 -2
- {uiautodev-0.3.4.dist-info → uiautodev-0.3.6.dist-info}/RECORD +9 -9
- {uiautodev-0.3.4.dist-info → uiautodev-0.3.6.dist-info}/LICENSE +0 -0
- {uiautodev-0.3.4.dist-info → uiautodev-0.3.6.dist-info}/WHEEL +0 -0
- {uiautodev-0.3.4.dist-info → uiautodev-0.3.6.dist-info}/entry_points.txt +0 -0
uiautodev/app.py
CHANGED
uiautodev/common.py
CHANGED
|
@@ -12,7 +12,7 @@ def is_chinese_language() -> bool:
|
|
|
12
12
|
language_code, _ = locale.getdefaultlocale()
|
|
13
13
|
|
|
14
14
|
# Check if the language code starts with 'zh' (Chinese)
|
|
15
|
-
if language_code.startswith('zh'):
|
|
15
|
+
if language_code and language_code.startswith('zh'):
|
|
16
16
|
return True
|
|
17
17
|
else:
|
|
18
18
|
return False
|
uiautodev/driver/android.py
CHANGED
|
@@ -13,7 +13,6 @@ from typing import List, Tuple
|
|
|
13
13
|
from xml.etree import ElementTree
|
|
14
14
|
|
|
15
15
|
import adbutils
|
|
16
|
-
import requests
|
|
17
16
|
import uiautomator2 as u2
|
|
18
17
|
from PIL import Image
|
|
19
18
|
|
|
@@ -29,7 +28,7 @@ logger = logging.getLogger(__name__)
|
|
|
29
28
|
class AndroidDriver(BaseDriver):
|
|
30
29
|
def __init__(self, serial: str):
|
|
31
30
|
super().__init__(serial)
|
|
32
|
-
self.
|
|
31
|
+
self.adb_device = adbutils.device(serial)
|
|
33
32
|
self._try_dump_list = [
|
|
34
33
|
self._get_u2_hierarchy,
|
|
35
34
|
self._get_appium_hierarchy,
|
|
@@ -38,7 +37,7 @@ class AndroidDriver(BaseDriver):
|
|
|
38
37
|
|
|
39
38
|
@cached_property
|
|
40
39
|
def udt(self) -> UDT:
|
|
41
|
-
return UDT(self.
|
|
40
|
+
return UDT(self.adb_device)
|
|
42
41
|
|
|
43
42
|
@cached_property
|
|
44
43
|
def ud(self) -> u2.Device:
|
|
@@ -46,8 +45,7 @@ class AndroidDriver(BaseDriver):
|
|
|
46
45
|
|
|
47
46
|
def screenshot(self, id: int) -> Image.Image:
|
|
48
47
|
try:
|
|
49
|
-
|
|
50
|
-
return img.convert("RGB")
|
|
48
|
+
return self.adb_device.screenshot() # display_id is not OK now
|
|
51
49
|
except adbutils.AdbError as e:
|
|
52
50
|
logger.warning("screenshot error: %s", str(e))
|
|
53
51
|
if id > 0:
|
|
@@ -56,7 +54,7 @@ class AndroidDriver(BaseDriver):
|
|
|
56
54
|
|
|
57
55
|
def shell(self, command: str) -> ShellResponse:
|
|
58
56
|
try:
|
|
59
|
-
ret = self.
|
|
57
|
+
ret = self.adb_device.shell2(command, rstrip=True, timeout=20)
|
|
60
58
|
if ret.returncode == 0:
|
|
61
59
|
return ShellResponse(output=ret.output, error=None)
|
|
62
60
|
else:
|
|
@@ -68,7 +66,7 @@ class AndroidDriver(BaseDriver):
|
|
|
68
66
|
|
|
69
67
|
def dump_hierarchy(self) -> Tuple[str, Node]:
|
|
70
68
|
"""returns xml string and hierarchy object"""
|
|
71
|
-
wsize = self.
|
|
69
|
+
wsize = self.adb_device.window_size()
|
|
72
70
|
logger.debug("window size: %s", wsize)
|
|
73
71
|
start = time.time()
|
|
74
72
|
xml_data = self._dump_hierarchy_raw()
|
|
@@ -125,7 +123,7 @@ class AndroidDriver(BaseDriver):
|
|
|
125
123
|
# c.close()
|
|
126
124
|
|
|
127
125
|
def _get_appium_hierarchy(self) -> str:
|
|
128
|
-
c = self.
|
|
126
|
+
c = self.adb_device.create_connection(adbutils.Network.TCP, 6790)
|
|
129
127
|
try:
|
|
130
128
|
content = fetch_through_socket(c, "/wd/hub/session/0/source", timeout=10)
|
|
131
129
|
return json.loads(content)["value"]
|
|
@@ -140,34 +138,34 @@ class AndroidDriver(BaseDriver):
|
|
|
140
138
|
return self.udt.dump_hierarchy()
|
|
141
139
|
|
|
142
140
|
def tap(self, x: int, y: int):
|
|
143
|
-
self.
|
|
141
|
+
self.adb_device.click(x, y)
|
|
144
142
|
|
|
145
143
|
def window_size(self) -> Tuple[int, int]:
|
|
146
|
-
w, h = self.
|
|
144
|
+
w, h = self.adb_device.window_size()
|
|
147
145
|
return (w, h)
|
|
148
146
|
|
|
149
147
|
def app_install(self, app_path: str):
|
|
150
|
-
self.
|
|
148
|
+
self.adb_device.install(app_path)
|
|
151
149
|
|
|
152
150
|
def app_current(self) -> CurrentAppResponse:
|
|
153
|
-
info = self.
|
|
151
|
+
info = self.adb_device.app_current()
|
|
154
152
|
return CurrentAppResponse(
|
|
155
153
|
package=info.package, activity=info.activity, pid=info.pid
|
|
156
154
|
)
|
|
157
155
|
|
|
158
156
|
def app_launch(self, package: str):
|
|
159
|
-
if self.
|
|
157
|
+
if self.adb_device.package_info(package) is None:
|
|
160
158
|
raise AndroidDriverException(f"App not installed: {package}")
|
|
161
|
-
self.
|
|
159
|
+
self.adb_device.app_start(package)
|
|
162
160
|
|
|
163
161
|
def app_terminate(self, package: str):
|
|
164
|
-
self.
|
|
162
|
+
self.adb_device.app_stop(package)
|
|
165
163
|
|
|
166
164
|
def home(self):
|
|
167
|
-
self.
|
|
165
|
+
self.adb_device.keyevent("HOME")
|
|
168
166
|
|
|
169
167
|
def wake_up(self):
|
|
170
|
-
self.
|
|
168
|
+
self.adb_device.keyevent("WAKEUP")
|
|
171
169
|
|
|
172
170
|
|
|
173
171
|
def parse_xml(xml_data: str, wsize: WindowSize) -> Node:
|
uiautodev/router/device.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import io
|
|
8
|
+
import logging
|
|
8
9
|
from typing import Any, List
|
|
9
10
|
|
|
10
11
|
from fastapi import APIRouter, Response
|
|
@@ -16,6 +17,8 @@ from uiautodev.model import DeviceInfo, Node, ShellResponse
|
|
|
16
17
|
from uiautodev.provider import BaseProvider
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
19
22
|
class AndroidShellPayload(BaseModel):
|
|
20
23
|
command: str
|
|
21
24
|
|
|
@@ -31,6 +34,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
|
|
|
31
34
|
except NotImplementedError as e:
|
|
32
35
|
return Response(content="list_devices not implemented", media_type="text/plain", status_code=501)
|
|
33
36
|
except Exception as e:
|
|
37
|
+
logger.exception("list_devices failed")
|
|
34
38
|
return Response(content=str(e), media_type="text/plain", status_code=500)
|
|
35
39
|
|
|
36
40
|
@router.post("/{serial}/shell")
|
|
@@ -42,6 +46,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
|
|
|
42
46
|
except NotImplementedError as e:
|
|
43
47
|
return Response(content="shell not implemented", media_type="text/plain", status_code=501)
|
|
44
48
|
except Exception as e:
|
|
49
|
+
logger.exception("shell failed")
|
|
45
50
|
return ShellResponse(output="", error=str(e))
|
|
46
51
|
|
|
47
52
|
@router.get(
|
|
@@ -59,6 +64,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
|
|
|
59
64
|
image_bytes = buf.getvalue()
|
|
60
65
|
return Response(content=image_bytes, media_type="image/jpeg")
|
|
61
66
|
except Exception as e:
|
|
67
|
+
logger.exception("screenshot failed")
|
|
62
68
|
return Response(content=str(e), media_type="text/plain", status_code=500)
|
|
63
69
|
|
|
64
70
|
@router.get("/{serial}/hierarchy")
|
|
@@ -69,6 +75,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
|
|
|
69
75
|
xml_data, hierarchy = driver.dump_hierarchy()
|
|
70
76
|
return hierarchy
|
|
71
77
|
except Exception as e:
|
|
78
|
+
logger.exception("dump_hierarchy failed")
|
|
72
79
|
return Response(content=str(e), media_type="text/plain", status_code=500)
|
|
73
80
|
|
|
74
81
|
@router.post('/{serial}/command/tap')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: uiautodev
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: Mobile UI Automation, include UI hierarchy inspector, script recorder
|
|
5
5
|
Home-page: https://uiauto.dev
|
|
6
6
|
License: MIT
|
|
@@ -27,7 +27,7 @@ Requires-Dist: pillow
|
|
|
27
27
|
Requires-Dist: poetry (>=1.8.2,<2.0.0)
|
|
28
28
|
Requires-Dist: pygments (>=2)
|
|
29
29
|
Requires-Dist: uiautomator2 (>=2)
|
|
30
|
-
Requires-Dist: uvicorn
|
|
30
|
+
Requires-Dist: uvicorn[standard]
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
# uiautodev
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
uiautodev/__init__.py,sha256=UBIzJoRjsFADqlrH5juQL4DSd0i3-rLhUtydeEluVEU,267
|
|
2
2
|
uiautodev/__main__.py,sha256=0WZHyHW-M7FG5RexANNoIB5pkCX8xwQbTnmaOA9Y1kg,176
|
|
3
|
-
uiautodev/app.py,sha256=
|
|
3
|
+
uiautodev/app.py,sha256=R7AV5uuh4VLkrF9Kl_JJWUiPQnuIeJ02CN1W7tNGPKE,2498
|
|
4
4
|
uiautodev/appium_proxy.py,sha256=yMzPnIDo50hYSaq0g5bXUpgRrFa_849wNa2o7ZpxGNY,1773
|
|
5
5
|
uiautodev/case.py,sha256=Jk2_5X2F-XIPnGuYTCqOVQiwwchwOhF7uKK5oKv5shg,3919
|
|
6
6
|
uiautodev/cli.py,sha256=VBs5wDfmdBIyQQ8Nda0ACe84RRIAd8KRttrjAxm9YJc,6234
|
|
7
7
|
uiautodev/command_proxy.py,sha256=eexXUwd4kt1gE3ab8QbSyUXd6zlghv6ize3NfvzeboE,4562
|
|
8
8
|
uiautodev/command_types.py,sha256=d2s0GPLHCwr8QRMsPS8yrbr5irLUZLYBxLP4IifjSr8,1587
|
|
9
|
-
uiautodev/common.py,sha256=
|
|
10
|
-
uiautodev/driver/android.py,sha256=
|
|
9
|
+
uiautodev/common.py,sha256=t1jmG7S0LVXAigtg86J3vM2XXf1xYPfDV_HwSwyl3OI,552
|
|
10
|
+
uiautodev/driver/android.py,sha256=TIAF2-ytP-eT6_lqd9gHW-XAXiT5J2OTFSFPqC4SY-U,7064
|
|
11
11
|
uiautodev/driver/appium.py,sha256=U3TGpOXmu3tEa3E1ttTFoXehOfFyjavJQ3XA4CtqeBE,5308
|
|
12
12
|
uiautodev/driver/base_driver.py,sha256=8CJrvulNzSZWrfBs8OBv2lTymsw-b3OyxOT8RxtkIyU,2048
|
|
13
13
|
uiautodev/driver/ios.py,sha256=ymZKk2pKHPhKXX0Y-WLHwATHDLiXjnP0KeiByxU4Rpc,4353
|
|
@@ -17,14 +17,14 @@ uiautodev/driver/udt/udt.py,sha256=p6opbUtYxEGTINIX83F6m2CtzB42iSSBYRv1SjXCEFg,8
|
|
|
17
17
|
uiautodev/exceptions.py,sha256=TuRD5SWQk5N2_KjrcDuXG_p84LBhLa2QEEXyFNFm0yQ,465
|
|
18
18
|
uiautodev/model.py,sha256=0dD0PY8vBfgA9_GsEnNqM3TcNvNL_PUpTrHUc_BADKs,717
|
|
19
19
|
uiautodev/provider.py,sha256=HDD_Jj-cJVfBceunzCYU9zJvGVya7Jd35GG9h85BY-0,2370
|
|
20
|
-
uiautodev/router/device.py,sha256=
|
|
20
|
+
uiautodev/router/device.py,sha256=ZeXaYqeGcyH-_ehXfLsGAjGmW9gcL8KCoOs78c3ePNI,4116
|
|
21
21
|
uiautodev/router/xml.py,sha256=MKVLhjMBqE4qbEraQxvdrVp_OBnylEL9Wti5lnmBDk4,891
|
|
22
22
|
uiautodev/static/demo.html,sha256=qC7qUZP5Af9T3V5EuFGbovzv8mArwiGMWsX_vcs_Bt0,1240
|
|
23
23
|
uiautodev/utils/common.py,sha256=HuXJvipkg1QQg6vCD7OxH6JQtqbSVbXNzI1X2OVcEcU,4785
|
|
24
24
|
uiautodev/utils/exceptions.py,sha256=lL_G_E41KWvfXnl32-E4Vgr3_HyTboxq_EwzdQMuvK4,637
|
|
25
25
|
uiautodev/utils/usbmux.py,sha256=LYupLDn7U4KFKhYQJrmIroS-3040gqZQVDRDB_FNDJM,17386
|
|
26
|
-
uiautodev-0.3.
|
|
27
|
-
uiautodev-0.3.
|
|
28
|
-
uiautodev-0.3.
|
|
29
|
-
uiautodev-0.3.
|
|
30
|
-
uiautodev-0.3.
|
|
26
|
+
uiautodev-0.3.6.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
|
|
27
|
+
uiautodev-0.3.6.dist-info/METADATA,sha256=cAOeWNUJDHfstTu6a3jUhCNN1cKpkWzA6CaDbk7PO9Y,2329
|
|
28
|
+
uiautodev-0.3.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
29
|
+
uiautodev-0.3.6.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
|
|
30
|
+
uiautodev-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|