uiautodev 0.3.7__py3-none-any.whl → 0.4.0__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.

Potentially problematic release.


This version of uiautodev might be problematic. Click here for more details.

uiautodev/__init__.py CHANGED
@@ -4,9 +4,5 @@
4
4
  """Created on Mon Mar 04 2024 14:28:53 by codeskyblue
5
5
  """
6
6
 
7
- from importlib.metadata import PackageNotFoundError, version
8
-
9
- try:
10
- __version__ = version("uiautodev")
11
- except PackageNotFoundError:
12
- __version__ = "0.0.0"
7
+ # version is auto managed by poetry
8
+ __version__ = "0.4.0"
@@ -105,6 +105,31 @@ def home(driver: BaseDriver):
105
105
  driver.home()
106
106
 
107
107
 
108
+ @register(Command.BACK)
109
+ def back(driver: BaseDriver):
110
+ driver.back()
111
+
112
+
113
+ @register(Command.APP_SWITCH)
114
+ def app_switch(driver: BaseDriver):
115
+ driver.app_switch()
116
+
117
+
118
+ @register(Command.VOLUME_UP)
119
+ def volume_up(driver: BaseDriver):
120
+ driver.volume_up()
121
+
122
+
123
+ @register(Command.VOLUME_DOWN)
124
+ def volume_down(driver: BaseDriver):
125
+ driver.volume_down()
126
+
127
+
128
+ @register(Command.VOLUME_MUTE)
129
+ def volume_mute(driver: BaseDriver):
130
+ driver.volume_mute()
131
+
132
+
108
133
  @register(Command.DUMP)
109
134
  def dump(driver: BaseDriver) -> DumpResponse:
110
135
  source, _ = driver.dump_hierarchy()
@@ -32,6 +32,13 @@ class Command(str, enum.Enum):
32
32
 
33
33
  LIST = "list"
34
34
 
35
+ # 0.4.0
36
+ BACK = "back"
37
+ APP_SWITCH = "appSwitch"
38
+ VOLUME_UP = "volumeUp"
39
+ VOLUME_DOWN = "volumeDown"
40
+ VOLUME_MUTE = "volumeMute"
41
+
35
42
 
36
43
  class TapRequest(BaseModel):
37
44
  x: Union[int, float]
@@ -144,6 +144,21 @@ class AndroidDriver(BaseDriver):
144
144
 
145
145
  def wake_up(self):
146
146
  self.adb_device.keyevent("WAKEUP")
147
+
148
+ def back(self):
149
+ self.adb_device.keyevent("BACK")
150
+
151
+ def app_switch(self):
152
+ self.adb_device.keyevent("APP_SWITCH")
153
+
154
+ def volume_up(self):
155
+ self.adb_device.keyevent("VOLUME_UP")
156
+
157
+ def volume_down(self):
158
+ self.adb_device.keyevent("VOLUME_DOWN")
159
+
160
+ def volume_mute(self):
161
+ self.adb_device.keyevent("VOLUME_MUTE")
147
162
 
148
163
 
149
164
  def parse_xml(xml_data: str, wsize: WindowSize, display_id: Optional[int] = None) -> Node:
@@ -70,6 +70,26 @@ class BaseDriver(abc.ABC):
70
70
  def home(self):
71
71
  """ press home button """
72
72
  raise NotImplementedError()
73
+
74
+ def back(self):
75
+ """ press back button """
76
+ raise NotImplementedError()
77
+
78
+ def app_switch(self):
79
+ """ switch app """
80
+ raise NotImplementedError()
81
+
82
+ def volume_up(self):
83
+ """ volume up """
84
+ raise NotImplementedError()
85
+
86
+ def volume_down(self):
87
+ """ volume down """
88
+ raise NotImplementedError()
89
+
90
+ def volume_mute(self):
91
+ """ volume mute """
92
+ raise NotImplementedError()
73
93
 
74
94
  def wake_up(self):
75
95
  """ wake up the device """
uiautodev/driver/ios.py CHANGED
@@ -13,13 +13,14 @@ from functools import partial
13
13
  from typing import List, Optional, Tuple
14
14
  from xml.etree import ElementTree
15
15
 
16
+ import wdapy
16
17
  from PIL import Image
17
18
 
18
19
  from uiautodev.command_types import CurrentAppResponse
19
20
  from uiautodev.driver.base_driver import BaseDriver
20
21
  from uiautodev.exceptions import IOSDriverException
21
22
  from uiautodev.model import Node, WindowSize
22
- from uiautodev.utils.usbmux import MuxDevice, select_device
23
+ from uiautodev.utils.usbmux import select_device
23
24
 
24
25
 
25
26
  class IOSDriver(BaseDriver):
@@ -27,6 +28,7 @@ class IOSDriver(BaseDriver):
27
28
  """ serial is the udid of the ios device """
28
29
  super().__init__(serial)
29
30
  self.device = select_device(serial)
31
+ self.wda = wdapy.AppiumUSBClient(self.device.serial)
30
32
 
31
33
  def _request(self, method: str, path: str, payload: Optional[dict] = None) -> bytes:
32
34
  conn = self.device.make_http_connection(port=8100)
@@ -56,29 +58,36 @@ class IOSDriver(BaseDriver):
56
58
  return self._request_json("GET", "/status")
57
59
 
58
60
  def screenshot(self, id: int = 0) -> Image.Image:
59
- png_base64 = self._request_json_value("GET", "/screenshot")
60
- png_data = base64.b64decode(png_base64)
61
- return Image.open(io.BytesIO(png_data))
61
+ return self.wda.screenshot()
62
62
 
63
63
  def window_size(self):
64
- return self._request_json_value("GET", "/window/size")
64
+ return self.wda.window_size()
65
65
 
66
66
  def dump_hierarchy(self) -> Tuple[str, Node]:
67
67
  """returns xml string and hierarchy object"""
68
- xml_data = self._request_json_value("GET", "/source")
68
+ t = self.wda.sourcetree()
69
+ xml_data = t.value
69
70
  root = ElementTree.fromstring(xml_data)
70
71
  return xml_data, parse_xml_element(root, WindowSize(width=1, height=1))
71
72
 
72
73
  def tap(self, x: int, y: int):
73
- self._request("POST", f"/wda/tap/0", {"x": x, "y": y})
74
+ self.wda.tap(x, y)
74
75
 
75
76
  def app_current(self) -> CurrentAppResponse:
76
- # {'processArguments': {'env': {}, 'args': []}, 'name': '', 'pid': 32, 'bundleId': 'com.apple.springboard'}
77
- value = self._request_json_value("GET", "/wda/activeAppInfo")
78
- return CurrentAppResponse(package=value["bundleId"], pid=value["pid"])
77
+ info = self.wda.app_current()
78
+ return CurrentAppResponse(package=info.bundle_id, pid=info.pid)
79
79
 
80
80
  def home(self):
81
- self._request("POST", "/wda/homescreen")
81
+ self.wda.homescreen()
82
+
83
+ def app_switch(self):
84
+ raise NotImplementedError()
85
+
86
+ def volume_up(self):
87
+ self.wda.volume_up()
88
+
89
+ def volume_down(self):
90
+ self.wda.volume_down()
82
91
 
83
92
 
84
93
  def parse_xml_element(element, wsize: WindowSize, indexes: List[int]=[0]) -> Node:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiautodev
3
- Version: 0.3.7
3
+ Version: 0.4.0
4
4
  Summary: Mobile UI Automation, include UI hierarchy inspector, script recorder
5
5
  Home-page: https://uiauto.dev
6
6
  License: MIT
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Provides-Extra: appium
18
- Requires-Dist: adbutils (>=2.6.0,<3.0.0)
18
+ Requires-Dist: adbutils (>=2.7.0,<3.0.0)
19
19
  Requires-Dist: appium-python-client (>=4.0.0,<5.0.0) ; extra == "appium"
20
20
  Requires-Dist: click (>=8.1.7,<9.0.0)
21
21
  Requires-Dist: construct
@@ -29,6 +29,7 @@ Requires-Dist: pydantic (>=2.6,<3.0)
29
29
  Requires-Dist: pygments (>=2)
30
30
  Requires-Dist: uiautomator2 (>=2)
31
31
  Requires-Dist: uvicorn[standard]
32
+ Requires-Dist: wdapy (>=0.2.2,<0.3.0)
32
33
  Description-Content-Type: text/markdown
33
34
 
34
35
  # uiautodev
@@ -1,16 +1,16 @@
1
- uiautodev/__init__.py,sha256=UBIzJoRjsFADqlrH5juQL4DSd0i3-rLhUtydeEluVEU,267
1
+ uiautodev/__init__.py,sha256=qyg24JoYZ2bIaFcBNFyeZA8faOTV87Gk978H-l29GWE,164
2
2
  uiautodev/__main__.py,sha256=0WZHyHW-M7FG5RexANNoIB5pkCX8xwQbTnmaOA9Y1kg,176
3
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
- uiautodev/command_proxy.py,sha256=eexXUwd4kt1gE3ab8QbSyUXd6zlghv6ize3NfvzeboE,4562
8
- uiautodev/command_types.py,sha256=d2s0GPLHCwr8QRMsPS8yrbr5irLUZLYBxLP4IifjSr8,1587
7
+ uiautodev/command_proxy.py,sha256=87n1s27xoslKKJ0jkfGWHuUhsJsCANAYx6v_plgKDW0,5007
8
+ uiautodev/command_types.py,sha256=Kf_55jrUr2nxrrZorg4urlruKx0cnsuXQBEzKeUXpJA,1736
9
9
  uiautodev/common.py,sha256=t1jmG7S0LVXAigtg86J3vM2XXf1xYPfDV_HwSwyl3OI,552
10
- uiautodev/driver/android.py,sha256=9ciL3YYdBtzAae70xdT9mJV-w0tLyBgKtjH552JFy4g,6827
10
+ uiautodev/driver/android.py,sha256=xtMAPWHrc53MbZyRj1d9mqaqaL1eyVI6ORv3BEd0Epg,7207
11
11
  uiautodev/driver/appium.py,sha256=U3TGpOXmu3tEa3E1ttTFoXehOfFyjavJQ3XA4CtqeBE,5308
12
- uiautodev/driver/base_driver.py,sha256=8CJrvulNzSZWrfBs8OBv2lTymsw-b3OyxOT8RxtkIyU,2048
13
- uiautodev/driver/ios.py,sha256=ymZKk2pKHPhKXX0Y-WLHwATHDLiXjnP0KeiByxU4Rpc,4353
12
+ uiautodev/driver/base_driver.py,sha256=f-C8vfE1F6EgDTUeBsv7UBTynmqhYq5BNMi4wawUIvM,2517
13
+ uiautodev/driver/ios.py,sha256=U0zozuYs-hCqKCb9O5-Vyuku08gkgQuoUF4-xVWkg1U,4238
14
14
  uiautodev/driver/mock.py,sha256=0VtxBkZRMbHiQGHjqm8Ih2Ld6baXiVxX8yUTwWJQlnE,2422
15
15
  uiautodev/driver/udt/appium-uiautomator2-v5.12.4-light.apk,sha256=cKUVKpqEiGRXODeqpwzVWllyjdSLyowFm94a6jDTvhI,3675062
16
16
  uiautodev/driver/udt/udt.py,sha256=p6opbUtYxEGTINIX83F6m2CtzB42iSSBYRv1SjXCEFg,8351
@@ -23,8 +23,8 @@ uiautodev/static/demo.html,sha256=qC7qUZP5Af9T3V5EuFGbovzv8mArwiGMWsX_vcs_Bt0,12
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.7.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
27
- uiautodev-0.3.7.dist-info/METADATA,sha256=hl7kzKFTPjjb26cNcJPhnDJyb0VZleZiIViVA7G5qTo,2366
28
- uiautodev-0.3.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- uiautodev-0.3.7.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
30
- uiautodev-0.3.7.dist-info/RECORD,,
26
+ uiautodev-0.4.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
27
+ uiautodev-0.4.0.dist-info/METADATA,sha256=tY-frsy05wnBaJfTOmISViH1v20e7xq8xPnw6LmtzYE,2404
28
+ uiautodev-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
+ uiautodev-0.4.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
30
+ uiautodev-0.4.0.dist-info/RECORD,,