mangoautomation 1.0.57__tar.gz → 1.0.59__tar.gz

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 mangoautomation might be problematic. Click here for more details.

Files changed (65) hide show
  1. {mangoautomation-1.0.57/mangoautomation.egg-info → mangoautomation-1.0.59}/PKG-INFO +3 -11
  2. mangoautomation-1.0.57/mangoautomation/exceptions/_error_msg.py → mangoautomation-1.0.59/mangoautomation/exceptions/error_msg.py +1 -1
  3. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/models/__init__.py +2 -1
  4. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/models/_ui_model.py +14 -7
  5. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/_async_element.py +29 -28
  6. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/_base_data.py +5 -3
  7. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/_sync_element.py +28 -27
  8. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/__init__.py +2 -2
  9. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_application.py +9 -9
  10. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_assertion.py +4 -4
  11. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_element.py +16 -16
  12. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_equipment.py +7 -7
  13. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_new_android.py +1 -1
  14. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_page.py +12 -12
  15. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/__init__.py +3 -4
  16. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_assertion.py +5 -5
  17. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_browser.py +6 -6
  18. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_element.py +30 -21
  19. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_input_device.py +10 -6
  20. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_new_browser.py +4 -2
  21. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_page.py +2 -1
  22. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/__init__.py +3 -4
  23. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_assertion.py +4 -4
  24. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_browser.py +7 -6
  25. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_element.py +30 -18
  26. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_input_device.py +7 -6
  27. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_new_browser.py +4 -2
  28. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_page.py +1 -1
  29. {mangoautomation-1.0.57 → mangoautomation-1.0.59/mangoautomation.egg-info}/PKG-INFO +3 -11
  30. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation.egg-info/SOURCES.txt +2 -1
  31. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation.egg-info/requires.txt +1 -1
  32. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/setup.py +2 -2
  33. mangoautomation-1.0.59/tests/__init__.py +10 -0
  34. mangoautomation-1.0.59/tests/get_ope.py +12 -0
  35. mangoautomation-1.0.57/tests/__init__.py → mangoautomation-1.0.59/tests/test_ui_and.py +1 -1
  36. mangoautomation-1.0.57/tests/test_ui_and.py +0 -29
  37. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/LICENSE +0 -0
  38. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/MANIFEST.in +0 -0
  39. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/README.md +0 -0
  40. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/__init__.py +0 -0
  41. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/enums/__init__.py +0 -0
  42. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/enums/_base_enum.py +0 -0
  43. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/enums/_ui_enum.py +0 -0
  44. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/exceptions/__init__.py +0 -0
  45. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/exceptions/_exceptions.py +0 -0
  46. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/tools/__init__.py +0 -0
  47. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/tools/_mate.py +0 -0
  48. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/tools/_uiautodev.py +0 -0
  49. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/__init__.py +0 -0
  50. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/_driver_object.py +0 -0
  51. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/android/_customization.py +0 -0
  52. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/ios/__init__.py +0 -0
  53. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/__init__.py +0 -0
  54. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/assertion.py +0 -0
  55. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/customization.py +0 -0
  56. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/element.py +0 -0
  57. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/input_device.py +0 -0
  58. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/pc/new_windows.py +0 -0
  59. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/__init__.py +0 -0
  60. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/async_web/_customization.py +0 -0
  61. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation/uidrive/web/sync_web/_customization.py +0 -0
  62. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation.egg-info/dependency_links.txt +0 -0
  63. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/mangoautomation.egg-info/top_level.txt +0 -0
  64. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/setup.cfg +0 -0
  65. {mangoautomation-1.0.57 → mangoautomation-1.0.59}/tests/test_ui_web.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: mangoautomation
3
- Version: 1.0.57
3
+ Version: 1.0.59
4
4
  Summary: 测试工具
5
5
  Home-page: https://gitee.com/mao-peng/testkit
6
6
  Author: 毛鹏
@@ -15,17 +15,9 @@ Requires-Dist: pydantic>=2.9.2
15
15
  Requires-Dist: playwright==1.43.0
16
16
  Requires-Dist: uiautomation>=2.0.20
17
17
  Requires-Dist: uiautomator2>=3.2.5
18
- Requires-Dist: mangotools>=1.1.32
18
+ Requires-Dist: mangotools>=1.1.42
19
19
  Requires-Dist: adbutils~=2.8.9
20
20
  Requires-Dist: uiautodev>=0.9.0
21
- Dynamic: author
22
- Dynamic: author-email
23
- Dynamic: classifier
24
- Dynamic: description
25
- Dynamic: home-page
26
- Dynamic: license-file
27
- Dynamic: requires-dist
28
- Dynamic: summary
29
21
 
30
22
  # testkit
31
23
 
@@ -19,7 +19,7 @@ ERROR_MSG_0012 = (4012, '操作失败,请检查输入的值是否有空字符
19
19
  ERROR_MSG_0013 = (
20
20
  313, '打开url时超时,分为2个问题:1.启用的浏览器过多,应当减少浏览器并发个数;2.自行查看为啥60秒还未打开:{}')
21
21
  ERROR_MSG_0014 = (4014, '')
22
- ERROR_MSG_0015 = (4015, '的类型错误,请联系管理员进行排查问题')
22
+ ERROR_MSG_0015 = (4015, '没有操作的类型,请联系管理员进行排查问题')
23
23
  ERROR_MSG_0016 = (4016, '')
24
24
  ERROR_MSG_0017 = (4017, '断言失败: {}')
25
25
  ERROR_MSG_0018 = (4018, '')
@@ -4,10 +4,11 @@
4
4
  # @Author : 毛鹏
5
5
  import sys
6
6
 
7
- from ..models._ui_model import ElementModel, ElementResultModel
7
+ from ..models._ui_model import ElementModel, ElementResultModel, ElementListResultModel
8
8
 
9
9
 
10
10
  __all__ = [
11
11
  'ElementModel',
12
12
  'ElementResultModel',
13
+ 'ElementListResultModel'
13
14
  ]
@@ -17,12 +17,16 @@ class EnvironmentConfigModel(BaseModel):
17
17
  mysql_config: MysqlConingModel | None = None
18
18
 
19
19
 
20
+ class ElementListModel(BaseModel):
21
+ exp: int | None
22
+ loc: str | None
23
+
24
+
20
25
  class ElementModel(BaseModel):
21
26
  id: int
22
27
  type: int
23
28
  name: str | None
24
- loc: str | None
25
- exp: int | None
29
+ elements: list[ElementListModel] = []
26
30
  sleep: int | None
27
31
  sub: int | None
28
32
  is_iframe: int | None
@@ -34,11 +38,16 @@ class ElementModel(BaseModel):
34
38
  value: str | None = None
35
39
 
36
40
 
41
+ class ElementListResultModel(BaseModel):
42
+ loc: str | None = None
43
+ exp: int | None = None
44
+ ele_quantity: int = 0
45
+ element_text: str | None = None
46
+
47
+
37
48
  class ElementResultModel(BaseModel):
38
49
  id: int
39
50
  name: str | None = None
40
- loc: str | None = None
41
- exp: int | None = None
42
51
  sleep: int | None = None
43
52
  sub: int | None = None
44
53
 
@@ -51,9 +60,7 @@ class ElementResultModel(BaseModel):
51
60
  key: str | None = None
52
61
  value: str | None = None
53
62
 
54
- ele_quantity: int = 0
55
- element_text: str | None = None
56
-
63
+ elements: list[ElementListResultModel] = []
57
64
  status: int = 0
58
65
  error_message: str | None = None
59
66
  picture_path: str | None = None
@@ -5,6 +5,7 @@
5
5
  # @Author : 毛鹏
6
6
  import asyncio
7
7
  import os
8
+ import random
8
9
  import traceback
9
10
  from typing import Optional
10
11
 
@@ -15,8 +16,8 @@ from mangotools.decorator import async_retry
15
16
  from mangotools.enums import StatusEnum
16
17
  from ..enums import ElementOperationEnum, DriveTypeEnum
17
18
  from ..exceptions import MangoAutomationError
18
- from ..exceptions._error_msg import *
19
- from ..models import ElementResultModel, ElementModel
19
+ from ..exceptions.error_msg import *
20
+ from ..models import ElementResultModel, ElementModel, ElementListResultModel
20
21
  from ..uidrive.android import AndroidDriver
21
22
  from ..uidrive.web.async_web import AsyncWebDevice, AsyncWebAssertion
22
23
 
@@ -47,8 +48,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
47
48
  self.element_result_model = ElementResultModel(
48
49
  id=self.element_model.id,
49
50
  name=self.element_model.name,
50
- loc=self.element_model.loc,
51
- exp=self.element_model.exp,
52
51
  sub=self.element_model.sub,
53
52
  sleep=self.element_model.sleep,
54
53
 
@@ -62,6 +61,7 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
62
61
  status=StatusEnum.FAIL.value,
63
62
  )
64
63
  try:
64
+ await self.init_element()
65
65
  await self.__main()
66
66
  if self.element_model.sleep:
67
67
  await asyncio.sleep(self.element_model.sleep)
@@ -90,16 +90,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
90
90
 
91
91
  @async_retry()
92
92
  async def __main(self):
93
- try:
94
- self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
95
- self.element_result_model.loc = self.element_model.loc
96
- self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
97
- self.element_result_model.sleep = self.element_model.sleep
98
- self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
99
- self.element_result_model.sub = self.element_model.sub
100
- except MangoAutomationError as error:
101
- self.base_data.log.error(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
102
- raise MangoAutomationError(error.code, error.msg)
103
93
  self.base_data.verify_equipment(self.drive_type)
104
94
  if self.element_model.type == ElementOperationEnum.OPE.value:
105
95
  await self.__ope()
@@ -112,6 +102,20 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
112
102
  else:
113
103
  raise MangoAutomationError(*ERROR_MSG_0015)
114
104
 
105
+ async def init_element(self):
106
+ try:
107
+ for i in self.element_model.elements:
108
+ i.loc = self.base_data.test_data.replace(i.loc)
109
+ self.element_result_model.elements.append(ElementListResultModel(exp=i.exp, loc=i.loc))
110
+ self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
111
+ self.element_result_model.sleep = self.element_model.sleep
112
+ self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
113
+ self.element_result_model.sub = self.element_model.sub
114
+
115
+ except MangoAutomationError as error:
116
+ self.base_data.log.error(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
117
+ raise MangoAutomationError(error.code, error.msg)
118
+
115
119
  async def __ope(self):
116
120
  method_name = getattr(self.element_model, 'ope_key', None)
117
121
  if not method_name:
@@ -197,31 +201,28 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
197
201
  value = self.element_data.get('value')
198
202
  self.base_data.test_data.set_cache(key, self.base_data.test_data.replace(value))
199
203
 
200
- async def __ope_value(self,is_ass: bool = False):
204
+ async def __ope_value(self, is_ass: bool = False):
201
205
  try:
202
206
  ope_key = 'actual' if is_ass else 'locating'
203
207
  for i in self.element_model.ope_value:
204
- if i.f == ope_key and self.element_model.loc:
208
+ if i.f == ope_key and self.element_model.elements:
209
+ random_element = random.randint(0, len(self.element_model.elements) - 1)
205
210
  find_params = {
206
211
  'name': self.element_model.name,
207
212
  '_type': self.element_model.type,
208
- 'exp': self.element_model.exp,
209
- 'loc': self.element_model.loc,
213
+ 'exp': self.element_model.elements[random_element].exp,
214
+ 'loc': self.element_model.elements[random_element].loc,
210
215
  'sub': self.element_model.sub
211
216
  }
212
217
  if self.drive_type == DriveTypeEnum.WEB.value:
213
- loc, self.element_result_model.ele_quantity, \
214
- self.element_result_model.element_text \
215
- = await self.web_find_ele(**find_params, is_iframe=self.element_model.is_iframe)
218
+ loc, ele_quantity, element_text = await self.web_find_ele(
219
+ **find_params, is_iframe=self.element_model.is_iframe)
216
220
  elif self.drive_type == DriveTypeEnum.ANDROID.value:
217
- loc, self.element_result_model.ele_quantity, \
218
- self.element_result_model.element_text \
219
- = self.a_find_ele(**find_params)
221
+ loc, ele_quantity, element_text = self.a_find_ele(**find_params)
220
222
  else:
221
- loc, self.element_result_model.ele_quantity, \
222
- self.element_result_model.element_text \
223
- = None, 0, None
224
-
223
+ loc, ele_quantity, element_text = None, 0, None
224
+ self.element_result_model.elements[random_element].ele_quantity = ele_quantity
225
+ self.element_result_model.elements[random_element].element_text = element_text
225
226
  if is_ass:
226
227
  if callable(getattr(AsyncWebAssertion, self.element_model.ope_key, None)):
227
228
  i.v = loc
@@ -7,11 +7,13 @@ from typing import Optional
7
7
  from unittest.mock import MagicMock
8
8
 
9
9
  import sys
10
+ from playwright.async_api import Page as ap, BrowserContext as ac
11
+ from playwright.sync_api import Page as p, BrowserContext as c
10
12
  from uiautomator2 import Device
11
13
 
12
14
  from mangoautomation.enums import DriveTypeEnum
13
15
  from mangoautomation.exceptions import MangoAutomationError
14
- from mangoautomation.exceptions._error_msg import ERROR_MSG_0010, ERROR_MSG_0007
16
+ from mangoautomation.exceptions.error_msg import ERROR_MSG_0010, ERROR_MSG_0007
15
17
  from mangotools.data_processor import DataProcessor
16
18
  from mangotools.database import MysqlConnect
17
19
  from mangotools.enums import StatusEnum
@@ -38,8 +40,8 @@ class BaseData:
38
40
 
39
41
  self.url: Optional[str | None] = None
40
42
  self.is_open_url = False
41
- self.page = None
42
- self.context = None
43
+ self.page: Optional[p | ap | None] = None
44
+ self.context: Optional[c | ac | None] = None
43
45
 
44
46
  self.package_name: Optional[str | None] = None
45
47
  self.android: Optional[Device | None] = None
@@ -4,6 +4,7 @@
4
4
  # @Time : 2025-04-12 15:55
5
5
  # @Author : 毛鹏
6
6
  import os
7
+ import random
7
8
  import traceback
8
9
  from typing import Optional
9
10
 
@@ -15,8 +16,8 @@ from mangotools.decorator import sync_retry
15
16
  from mangotools.enums import StatusEnum
16
17
  from ..enums import ElementOperationEnum, DriveTypeEnum
17
18
  from ..exceptions import MangoAutomationError
18
- from ..exceptions._error_msg import *
19
- from ..models import ElementResultModel, ElementModel
19
+ from ..exceptions.error_msg import *
20
+ from ..models import ElementResultModel, ElementModel, ElementListResultModel
20
21
  from ..uidrive.android import AndroidDriver
21
22
  from ..uidrive.web.sync_web import SyncWebDevice, SyncWebAssertion
22
23
 
@@ -47,8 +48,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
47
48
  self.element_result_model = ElementResultModel(
48
49
  id=self.element_model.id,
49
50
  name=self.element_model.name,
50
- loc=self.element_model.loc,
51
- exp=self.element_model.exp,
52
51
  sub=self.element_model.sub,
53
52
  sleep=self.element_model.sleep,
54
53
 
@@ -62,6 +61,7 @@ class SyncElement(SyncWebDevice, AndroidDriver):
62
61
  status=StatusEnum.FAIL.value,
63
62
  )
64
63
  try:
64
+ self.init_element()
65
65
  self.__main()
66
66
  if self.element_model.sleep:
67
67
  time.sleep(self.element_model.sleep)
@@ -90,16 +90,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
90
90
 
91
91
  @sync_retry()
92
92
  def __main(self):
93
- try:
94
- self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
95
- self.element_result_model.loc = self.element_model.loc
96
- self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
97
- self.element_result_model.sleep = self.element_model.sleep
98
- self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
99
- self.element_result_model.sub = self.element_model.sub
100
- except MangoAutomationError as error:
101
- self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
102
- raise MangoAutomationError(error.code, error.msg)
103
93
  self.base_data.verify_equipment(self.drive_type)
104
94
  if self.element_model.type == ElementOperationEnum.OPE.value:
105
95
  self.__ope()
@@ -112,6 +102,20 @@ class SyncElement(SyncWebDevice, AndroidDriver):
112
102
  else:
113
103
  raise MangoAutomationError(*ERROR_MSG_0015)
114
104
 
105
+ def init_element(self):
106
+ try:
107
+ for i in self.element_model.elements:
108
+ i.loc = self.base_data.test_data.replace(i.loc)
109
+ self.element_result_model.elements.append(ElementListResultModel(exp=i.exp, loc=i.loc))
110
+ self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
111
+ self.element_result_model.sleep = self.element_model.sleep
112
+ self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
113
+ self.element_result_model.sub = self.element_model.sub
114
+
115
+ except MangoAutomationError as error:
116
+ self.base_data.log.error(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
117
+ raise MangoAutomationError(error.code, error.msg)
118
+
115
119
  def __ope(self):
116
120
  method_name = getattr(self.element_model, 'ope_key', None)
117
121
  if not method_name:
@@ -201,27 +205,24 @@ class SyncElement(SyncWebDevice, AndroidDriver):
201
205
  try:
202
206
  ope_key = 'actual' if is_ass else 'locating'
203
207
  for i in self.element_model.ope_value:
204
- if i.f == ope_key and self.element_model.loc:
208
+ if i.f == ope_key and self.element_model.elements:
209
+ random_element = random.randint(0, len(self.element_model.elements) - 1)
205
210
  find_params = {
206
211
  'name': self.element_model.name,
207
212
  '_type': self.element_model.type,
208
- 'exp': self.element_model.exp,
209
- 'loc': self.element_model.loc,
213
+ 'exp': self.element_model.elements[random_element].exp,
214
+ 'loc': self.element_model.elements[random_element].loc,
210
215
  'sub': self.element_model.sub
211
216
  }
212
217
  if self.drive_type == DriveTypeEnum.WEB.value:
213
- loc, self.element_result_model.ele_quantity, \
214
- self.element_result_model.element_text \
215
- = self.web_find_ele(**find_params, is_iframe=self.element_model.is_iframe)
218
+ loc, ele_quantity, element_text = self.web_find_ele(**find_params,
219
+ is_iframe=self.element_model.is_iframe)
216
220
  elif self.drive_type == DriveTypeEnum.ANDROID.value:
217
- loc, self.element_result_model.ele_quantity, \
218
- self.element_result_model.element_text \
219
- = self.a_find_ele(**find_params)
221
+ loc, ele_quantity, element_text = self.a_find_ele(**find_params)
220
222
  else:
221
- loc, self.element_result_model.ele_quantity, \
222
- self.element_result_model.element_text \
223
- = None, 0, None
224
-
223
+ loc, ele_quantity, element_text = None, 0, None
224
+ self.element_result_model.elements[random_element].ele_quantity = ele_quantity
225
+ self.element_result_model.elements[random_element].element_text = element_text
225
226
  if is_ass:
226
227
  if callable(getattr(SyncWebAssertion, self.element_model.ope_key, None)):
227
228
  i.v = loc
@@ -17,7 +17,7 @@ from ..android._equipment import AndroidEquipment
17
17
  from ..android._page import AndroidPage
18
18
  from ...enums import ElementExpEnum
19
19
  from ...exceptions import MangoAutomationError
20
- from ...exceptions._error_msg import *
20
+ from ...exceptions.error_msg import *
21
21
 
22
22
  __all__ = [
23
23
  'AndroidApplication',
@@ -75,7 +75,7 @@ class AndroidDriver(AndroidPage,
75
75
  return Mango.s_e(AndroidAssertion(self.base_data), ope_key, ope_value)
76
76
  else:
77
77
  self.base_data.log.debug(f'开始断言-2,方法:{ope_key},断言值:{ope_value}')
78
- return MangoAssertion(self.base_data.mysql_connect) \
78
+ return MangoAssertion(self.base_data.mysql_connect, self.base_data.test_data) \
79
79
  .ass(ope_key, ope_value.get('actual'), ope_value.get('expect'))
80
80
  except AssertionError as error:
81
81
  self.base_data.log.error(f'安卓自动化失败-1,类型:{type(error)},失败详情:{error}')
@@ -8,7 +8,7 @@ import time
8
8
  from mangotools.decorator import sync_method_callback
9
9
  from mangotools.models import MethodModel
10
10
  from ...exceptions import MangoAutomationError
11
- from ...exceptions._error_msg import ERROR_MSG_0046
11
+ from ...exceptions.error_msg import ERROR_MSG_0046
12
12
  from ...tools import Meta
13
13
  from ...uidrive._base_data import BaseData
14
14
 
@@ -23,7 +23,7 @@ class AndroidApplication(metaclass=Meta):
23
23
  return any(package_name in str(i) for i in self.base_data.android.shell("pm list packages"))
24
24
 
25
25
  @sync_method_callback('android', '应用操作', 0,
26
- [MethodModel(f='package_name', p='请输入应用名称', d=True)])
26
+ [MethodModel(n='包名', f='package_name', p='请输入应用名称', d=True)])
27
27
  def a_start_app(self, package_name: str):
28
28
  """启动应用"""
29
29
  if not package_name:
@@ -33,8 +33,8 @@ class AndroidApplication(metaclass=Meta):
33
33
  self.base_data.android.app_start(package_name)
34
34
  time.sleep(4)
35
35
 
36
- @sync_method_callback('android', '应用操作', 1,[
37
- MethodModel(f='package_name', p='请输入应用名称', d=True)])
36
+ @sync_method_callback('android', '应用操作', 1, [
37
+ MethodModel(n='包名', f='package_name', p='请输入应用名称', d=True)])
38
38
  def a_close_app(self, package_name: str):
39
39
  """关闭应用"""
40
40
  if not package_name:
@@ -44,8 +44,8 @@ class AndroidApplication(metaclass=Meta):
44
44
 
45
45
  self.base_data.android.app_stop(package_name)
46
46
 
47
- @sync_method_callback('android', '应用操作', 2,[
48
- MethodModel(f='package_name', p='请输入应用名称', d=True)])
47
+ @sync_method_callback('android', '应用操作', 2, [
48
+ MethodModel(n='包名', f='package_name', p='请输入应用名称', d=True)])
49
49
  def a_clear_app(self, package_name: str):
50
50
  """清除app数据"""
51
51
  if not package_name:
@@ -55,13 +55,13 @@ class AndroidApplication(metaclass=Meta):
55
55
 
56
56
  self.base_data.android.app_clear(package_name)
57
57
 
58
- @sync_method_callback('android', '应用操作',3 )
58
+ @sync_method_callback('android', '应用操作', 3)
59
59
  def a_app_stop_all(self):
60
60
  """停止所有app"""
61
61
  self.base_data.android.app_stop_all()
62
62
 
63
- @sync_method_callback('android', '应用操作',4, [
64
- MethodModel(f='package_name', p='请输入应用名称列表', d=True)])
63
+ @sync_method_callback('android', '应用操作', 4, [
64
+ MethodModel(n='包名List', f='package_name', p='请输入应用名称列表', d=True)])
65
65
  def a_app_stop_appoint(self, package_name_list: list):
66
66
  """停止除指定app外所有app"""
67
67
  for i in package_name_list:
@@ -26,7 +26,7 @@ class AndroidAssertion(metaclass=Meta):
26
26
 
27
27
  @sync_method_callback('ass_android', '元素断言', 2, [
28
28
  MethodModel(f='actual'),
29
- MethodModel(f='expect', p='请输入预期内容', d=True)])
29
+ MethodModel(n='预期值', f='expect', p='请输入预期内容', d=True)])
30
30
  def a_assert_ele_count(self, actual: UiObject, expect):
31
31
  """元素计数"""
32
32
  assert int(actual.count) == int(expect), f'实际={actual.count}, 预期={expect}'
@@ -34,7 +34,7 @@ class AndroidAssertion(metaclass=Meta):
34
34
 
35
35
  @sync_method_callback('ass_android', '元素断言', 3, [
36
36
  MethodModel(f='actual'),
37
- MethodModel(f='expect', p='请输入预期文本', d=True)])
37
+ MethodModel(n='预期值', f='expect', p='请输入预期文本', d=True)])
38
38
  def a_assert_ele_text(self, actual: UiObject, expect: str):
39
39
  """元素文本内容"""
40
40
  assert actual.get_text() == expect, f"实际='{actual.get_text()}', 预期='{expect}'"
@@ -70,7 +70,7 @@ class AndroidAssertion(metaclass=Meta):
70
70
  return f"实际={actual.info['visible']}, 预期=元素不可见"
71
71
 
72
72
  @sync_method_callback('ass_android', '元素断言', 8, [
73
- MethodModel(f='expect', p='请输入弹窗标题文本', d=False)])
73
+ MethodModel(n='预期值', f='expect', p='请输入弹窗标题文本', d=False)])
74
74
  def a_assert_dialog_exists(self, expect: str):
75
75
  """弹窗存在"""
76
76
  dialog = self.base_data.android(text=expect) if expect else self.base_data.android(
@@ -80,7 +80,7 @@ class AndroidAssertion(metaclass=Meta):
80
80
 
81
81
  @sync_method_callback('ass_android', '元素断言', 9, [
82
82
  MethodModel(f='actual'),
83
- MethodModel(f='expect', p='请输入断言目标文本', d=True)])
83
+ MethodModel(n='预期值', f='expect', p='请输入断言目标文本', d=True)])
84
84
  def a_assert_ele_in_list(self, actual: UiObject, expect: str):
85
85
  """列表滑动后目标元素存在"""
86
86
  if not actual.exists:
@@ -10,7 +10,7 @@ from uiautomator2 import UiObject
10
10
  from uiautomator2.xpath import XPathSelector
11
11
 
12
12
  from ...exceptions import MangoAutomationError
13
- from ...exceptions._error_msg import ERROR_MSG_0043, ERROR_MSG_0044
13
+ from ...exceptions.error_msg import ERROR_MSG_0043, ERROR_MSG_0044
14
14
  from ...tools import Meta
15
15
  from ...uidrive._base_data import BaseData
16
16
  from mangotools.decorator import sync_method_callback
@@ -36,7 +36,7 @@ class AndroidElement(metaclass=Meta):
36
36
  locating.click()
37
37
 
38
38
  @sync_method_callback('android', '元素操作', 2, [
39
- MethodModel(f='locating'), MethodModel(f='text', p='请输入内容', d=True)])
39
+ MethodModel(n='输入文本', f='locating'), MethodModel(f='text', p='请输入内容', d=True)])
40
40
  def a_input(self, locating: UiObject, text):
41
41
  """单击输入"""
42
42
  locating.click()
@@ -45,29 +45,29 @@ class AndroidElement(metaclass=Meta):
45
45
  self.base_data.android.send_keys(text)
46
46
 
47
47
  @sync_method_callback('android', '元素操作', 3, [
48
- MethodModel(f='locating'), MethodModel(f='text', p='请输入内容', d=True)])
48
+ MethodModel(f='locating'), MethodModel(n='设置文本', f='text', p='请输入内容', d=True)])
49
49
  def a_set_text(self, locating: UiObject, text):
50
50
  """设置文本"""
51
51
  locating.set_text(text)
52
52
 
53
53
  @sync_method_callback('android', '元素操作', 4, [
54
54
  MethodModel(f='locating'),
55
- MethodModel(f='x', p='请输入x坐标', d=True),
56
- MethodModel(f='y', p='请输入y坐标', d=True)])
55
+ MethodModel(n='x坐标', f='x', p='请输入x坐标', d=True),
56
+ MethodModel(n='y坐标', f='y', p='请输入y坐标', d=True)])
57
57
  def a_click_coord(self, x, y):
58
58
  """坐标单击"""
59
59
  self.base_data.android.click(x, y)
60
60
 
61
61
  @sync_method_callback('android', '元素操作', 5, [
62
- MethodModel(f='x', p='请输入x坐标', d=True),
63
- MethodModel(f='y', p='请输入y坐标', d=True)])
62
+ MethodModel(n='x坐标', f='x', p='请输入x坐标', d=True),
63
+ MethodModel(n='y坐标', f='y', p='请输入y坐标', d=True)])
64
64
  def a_double_click_coord(self, x, y):
65
65
  """坐标双击"""
66
66
  self.base_data.android.double_click(x, y)
67
67
 
68
68
  @sync_method_callback('android', '元素操作', 6, [
69
69
  MethodModel(f='locating'),
70
- MethodModel(f='time_', p='请输入长按坐标时间', d=True)])
70
+ MethodModel(n='长按时间', f='time_', p='请输入长按时间', d=True)])
71
71
  def a_long_click(self, locating: UiObject, time_):
72
72
  """长按元素"""
73
73
  locating.long_click(duration=float(time_))
@@ -78,7 +78,7 @@ class AndroidElement(metaclass=Meta):
78
78
  locating.clear_text()
79
79
 
80
80
  @sync_method_callback('android', '元素操作', 8, [
81
- MethodModel(f='locating'), MethodModel(f='set_cache_key', p='请输入元素文本存储的key', d=True)])
81
+ MethodModel(f='locating'), MethodModel(n='缓存的key', f='set_cache_key', p='请输入元素文本存储的key', d=True)])
82
82
  def a_get_text(self, locating: UiObject, set_cache_key=None):
83
83
  """获取元素文本"""
84
84
  value = locating.get_text()
@@ -88,7 +88,7 @@ class AndroidElement(metaclass=Meta):
88
88
 
89
89
  @sync_method_callback('android', '元素操作', 9, [
90
90
  MethodModel(f='locating'),
91
- MethodModel(f='file_name', p='请输入元素截图存储的名称,后续可以通过名称获取', d=True)])
91
+ MethodModel(n='截图名称', f='file_name', p='请输入元素截图存储的名称,后续可以通过名称获取', d=True)])
92
92
  def a_element_screenshot(self, locating: UiObject, file_name: str):
93
93
  """元素截图"""
94
94
  im = locating.screenshot()
@@ -109,14 +109,14 @@ class AndroidElement(metaclass=Meta):
109
109
  locating.pinch_out()
110
110
 
111
111
  @sync_method_callback('android', '元素操作', 12, [
112
- MethodModel(f='locating'), MethodModel(f='time_', p='请输入等待元素出现的时间', d=True)])
112
+ MethodModel(f='locating'), MethodModel(n='等待时间', f='time_', p='请输入等待元素出现的时间', d=True)])
113
113
  def a_wait(self, locating: UiObject, time_):
114
114
  """等待元素出现"""
115
115
  if not locating.wait(timeout=float(time_)):
116
116
  raise MangoAutomationError(*ERROR_MSG_0043)
117
117
 
118
118
  @sync_method_callback('android', '元素操作', 13, [
119
- MethodModel(f='locating'), MethodModel(f='time_', p='请输入等待元素消失的时间', d=True)])
119
+ MethodModel(f='locating'), MethodModel(n='等待时间', f='time_', p='请输入等待元素消失的时间', d=True)])
120
120
  def a_wait_gone(self, locating: UiObject, time_: str):
121
121
  """等待元素消失"""
122
122
  if not locating.wait_gone(timeout=float(time_)):
@@ -130,8 +130,8 @@ class AndroidElement(metaclass=Meta):
130
130
 
131
131
  @sync_method_callback('android', '元素操作', 15, [
132
132
  MethodModel(f='locating'),
133
- MethodModel(f='x', p='请输入x坐标', d=True),
134
- MethodModel(f='y', p='请输入y坐标', d=True)])
133
+ MethodModel(n='x坐标', f='x', p='请输入x坐标', d=True),
134
+ MethodModel(n='y坐标', f='y', p='请输入y坐标', d=True)])
135
135
  def a_drag_to_coord(self, locating: UiObject, x, y):
136
136
  """拖动元素到坐标上"""
137
137
  locating.drag_to(x, y)
@@ -158,8 +158,8 @@ class AndroidElement(metaclass=Meta):
158
158
 
159
159
  @sync_method_callback('android', '元素操作', 20, [
160
160
  MethodModel(f='locating'),
161
- MethodModel(f='x_key', p='请输入x坐标', d=True),
162
- MethodModel(f='y_key', p='请输入y坐标', d=True)])
161
+ MethodModel(n='x坐标', f='x_key', p='请输入x坐标', d=True),
162
+ MethodModel(n='y坐标', f='y_key', p='请输入y坐标', d=True)])
163
163
  def a_get_center(self, locating: UiObject, x_key, y_key):
164
164
  """提取元素坐标"""
165
165
  x, y = locating.center()
@@ -18,7 +18,7 @@ class AndroidEquipment(metaclass=Meta):
18
18
  self.base_data = base_data
19
19
 
20
20
  @sync_method_callback('android', '设备操作', 1, [
21
- MethodModel(f='_time', p='请输入等待时间', d=True)])
21
+ MethodModel(n='等待时间', f='_time', p='请输入等待时间', d=True)])
22
22
  def a_sleep(self, time_: int):
23
23
  """强制等待"""
24
24
  sleep(time_)
@@ -47,15 +47,15 @@ class AndroidEquipment(metaclass=Meta):
47
47
  return w, h
48
48
 
49
49
  @sync_method_callback('android', '设备操作', 6, [
50
- MethodModel(f='feli_path', p='请输入计算机文件路径', d=True),
51
- MethodModel(f='catalogue', p='请输入设备目录', d=True)])
52
- def a_push(self, feli_path, catalogue):
50
+ MethodModel(n='文件路径', f='file_path', p='请输入计算机文件路径', d=True),
51
+ MethodModel(n='手机目录', f='catalogue', p='请输入设备目录', d=True)])
52
+ def a_push(self, file_path, catalogue):
53
53
  """推送一个文件到设备"""
54
- self.base_data.android.push(feli_path, catalogue)
54
+ self.base_data.android.push(file_path, catalogue)
55
55
 
56
56
  @sync_method_callback('android', '设备操作', 7, [
57
- MethodModel(f='feli_path', p='请输入设备文件路径', d=True),
58
- MethodModel(f='catalogue', p='请输入计算机目录', d=True)])
57
+ MethodModel(n='文件路径', f='feli_path', p='请输入设备文件路径', d=True),
58
+ MethodModel(n='手机目录', f='catalogue', p='请输入计算机目录', d=True)])
59
59
  def a_pull(self, feli_path, catalogue):
60
60
  """提取文件"""
61
61
  self.base_data.android.pull(feli_path, catalogue)
@@ -11,7 +11,7 @@ from adbutils import AdbTimeout
11
11
  from uiautomator2 import ConnectError
12
12
 
13
13
  from ...exceptions import MangoAutomationError
14
- from ...exceptions._error_msg import ERROR_MSG_0042, ERROR_MSG_0045, ERROR_MSG_0040
14
+ from ...exceptions.error_msg import ERROR_MSG_0042, ERROR_MSG_0045, ERROR_MSG_0040
15
15
 
16
16
  """
17
17
  python -m uiautomator2 init