mangoautomation 1.0.33__tar.gz → 1.0.35__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.
- {mangoautomation-1.0.33/mangoautomation.egg-info → mangoautomation-1.0.35}/PKG-INFO +2 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/exceptions/_error_msg.py +2 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/_async_element.py +49 -59
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/_sync_element.py +49 -59
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_browser.py +13 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_element.py +8 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_browser.py +12 -1
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_element.py +10 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35/mangoautomation.egg-info}/PKG-INFO +2 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation.egg-info/requires.txt +1 -1
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/setup.py +2 -2
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/LICENSE +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/MANIFEST.in +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/README.md +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/enums/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/enums/_base_enum.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/enums/_ui_enum.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/exceptions/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/exceptions/_exceptions.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/models/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/models/_ui_model.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/tools/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/tools/_mate.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/_base_data.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/_driver_object.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_application.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_assertion.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_customization.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_element.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_equipment.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_new_android.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_page.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/assertion.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/customization.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/element.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/input_device.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/new_windows.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_assertion.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_customization.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_input_device.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_new_browser.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_page.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_assertion.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_customization.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_input_device.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_new_browser.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_page.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation.egg-info/SOURCES.txt +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation.egg-info/dependency_links.txt +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation.egg-info/top_level.txt +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/setup.cfg +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/tests/__init__.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/tests/test_ui_and.py +0 -0
- {mangoautomation-1.0.33 → mangoautomation-1.0.35}/tests/test_ui_web.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mangoautomation
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.35
|
|
4
4
|
Summary: 测试工具
|
|
5
5
|
Home-page: https://gitee.com/mao-peng/testkit
|
|
6
6
|
Author: 毛鹏
|
|
@@ -12,7 +12,7 @@ Requires-Dist: pydantic==2.9.2
|
|
|
12
12
|
Requires-Dist: playwright==1.43.0
|
|
13
13
|
Requires-Dist: uiautomation==2.0.20
|
|
14
14
|
Requires-Dist: uiautomator2==3.2.5
|
|
15
|
-
Requires-Dist: mangotools==1.0.
|
|
15
|
+
Requires-Dist: mangotools==1.0.22
|
|
16
16
|
Requires-Dist: adbutils~=2.8.9
|
|
17
17
|
|
|
18
18
|
# testkit
|
|
@@ -10,10 +10,10 @@ ERROR_MSG_0003 = (4003, '')
|
|
|
10
10
|
ERROR_MSG_0004 = (4004, '')
|
|
11
11
|
ERROR_MSG_0005 = (4018, '断言失败,断言输入值是:空字符串、null或不满足函数接受类型')
|
|
12
12
|
ERROR_MSG_0006 = (4006, '')
|
|
13
|
-
ERROR_MSG_0007 = (4007, '')
|
|
13
|
+
ERROR_MSG_0007 = (4007, '安卓设备被关闭,请检查设备')
|
|
14
14
|
ERROR_MSG_0008 = (4008, '浏览器类型不正确,请联系管理员检查')
|
|
15
15
|
ERROR_MSG_0009 = (4009, '浏览器路径不正确,请手动设置一个正确的浏览器路径,现在的路径:{}')
|
|
16
|
-
ERROR_MSG_0010 = (4010, '
|
|
16
|
+
ERROR_MSG_0010 = (4010, '浏览器被关闭,请不要手动关闭浏览器')
|
|
17
17
|
ERROR_MSG_0011 = (4011, '操作元素【{}】超时,请检查元素可见但是是否可操作或调整定位方式')
|
|
18
18
|
ERROR_MSG_0012 = (4012, '操作失败,请检查输入的值是否有空字符串,null或不满足传参的值')
|
|
19
19
|
ERROR_MSG_0013 = (
|
|
@@ -7,7 +7,7 @@ import asyncio
|
|
|
7
7
|
import os
|
|
8
8
|
import traceback
|
|
9
9
|
|
|
10
|
-
from playwright._impl._errors import TargetClosedError, Error
|
|
10
|
+
from playwright._impl._errors import TargetClosedError, Error
|
|
11
11
|
|
|
12
12
|
from mangotools.assertion import PublicAssertion
|
|
13
13
|
from mangotools.decorator import async_retry
|
|
@@ -57,15 +57,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
57
57
|
self.base_data.log.debug(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
|
|
58
58
|
raise Exception('不存在的设备类型')
|
|
59
59
|
|
|
60
|
-
async def clean_data(self):
|
|
61
|
-
try:
|
|
62
|
-
self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
|
|
63
|
-
self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
|
|
64
|
-
self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
|
|
65
|
-
except MangoAutomationError as error:
|
|
66
|
-
self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
|
|
67
|
-
raise MangoAutomationError(error.code, error.msg)
|
|
68
|
-
|
|
69
60
|
async def element_main(self) -> ElementResultModel:
|
|
70
61
|
try:
|
|
71
62
|
await self.__main()
|
|
@@ -73,12 +64,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
73
64
|
await asyncio.sleep(self.element_model.sleep)
|
|
74
65
|
self.element_result_model.status = StatusEnum.SUCCESS.value
|
|
75
66
|
self.element_result_model.error_message = None
|
|
76
|
-
except TargetClosedError as error:
|
|
77
|
-
self.base_data.setup()
|
|
78
|
-
self.base_data.log.debug(
|
|
79
|
-
f'浏览器关闭异常,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
80
|
-
self.element_result_model.status = StatusEnum.FAIL.value
|
|
81
|
-
self.element_result_model.error_message = '浏览器被关闭,请不要认关闭浏览器,非认为管理请联系管理员解决!'
|
|
82
67
|
except MangoAutomationError as error:
|
|
83
68
|
await self.__error(error.msg)
|
|
84
69
|
self.base_data.log.debug(f'已知异常,类型:{type(error)},失败详情:{error}')
|
|
@@ -97,17 +82,37 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
97
82
|
|
|
98
83
|
@async_retry()
|
|
99
84
|
async def __main(self):
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
85
|
+
try:
|
|
86
|
+
self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
|
|
87
|
+
self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
|
|
88
|
+
self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
|
|
89
|
+
except MangoAutomationError as error:
|
|
90
|
+
self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
|
|
91
|
+
raise MangoAutomationError(error.code, error.msg)
|
|
92
|
+
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
93
|
+
if not self.base_data.page and self.base_data.context:
|
|
94
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
95
|
+
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
96
|
+
if not self.base_data.android:
|
|
97
|
+
raise MangoAutomationError(*ERROR_MSG_0007)
|
|
109
98
|
else:
|
|
110
|
-
|
|
99
|
+
pass
|
|
100
|
+
try:
|
|
101
|
+
if self.element_model.type == ElementOperationEnum.OPE.value:
|
|
102
|
+
await self.__ope()
|
|
103
|
+
elif self.element_model.type == ElementOperationEnum.ASS.value:
|
|
104
|
+
await self.__ass()
|
|
105
|
+
elif self.element_model.type == ElementOperationEnum.SQL.value:
|
|
106
|
+
await self.__sql()
|
|
107
|
+
elif self.element_model.type == ElementOperationEnum.CUSTOM.value:
|
|
108
|
+
await self.__custom()
|
|
109
|
+
else:
|
|
110
|
+
raise MangoAutomationError(*ERROR_MSG_0015)
|
|
111
|
+
except TargetClosedError as error:
|
|
112
|
+
self.base_data.setup()
|
|
113
|
+
self.base_data.log.debug(
|
|
114
|
+
f'浏览器关闭异常,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
115
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
111
116
|
|
|
112
117
|
async def __ope(self):
|
|
113
118
|
method_name = getattr(self.element_model, 'ope_key', None)
|
|
@@ -122,7 +127,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
122
127
|
raise MangoAutomationError(*ERROR_MSG_0048)
|
|
123
128
|
if self.element_model.ope_value is None:
|
|
124
129
|
raise MangoAutomationError(*ERROR_MSG_0054)
|
|
125
|
-
|
|
126
130
|
await self.__ope_value()
|
|
127
131
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
128
132
|
await self.web_action_element(
|
|
@@ -208,18 +212,15 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
208
212
|
'sub': self.element_model.sub
|
|
209
213
|
}
|
|
210
214
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
211
|
-
loc, \
|
|
212
|
-
self.element_result_model.ele_quantity, \
|
|
215
|
+
loc, self.element_result_model.ele_quantity, \
|
|
213
216
|
self.element_result_model.element_text \
|
|
214
217
|
= await self.web_find_ele(**find_params, is_iframe=self.element_model.is_iframe)
|
|
215
218
|
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
216
|
-
loc, \
|
|
217
|
-
self.element_result_model.ele_quantity, \
|
|
219
|
+
loc, self.element_result_model.ele_quantity, \
|
|
218
220
|
self.element_result_model.element_text \
|
|
219
221
|
= self.a_find_ele(**find_params)
|
|
220
222
|
else:
|
|
221
|
-
loc, \
|
|
222
|
-
self.element_result_model.ele_quantity, \
|
|
223
|
+
loc, self.element_result_model.ele_quantity, \
|
|
223
224
|
self.element_result_model.element_text \
|
|
224
225
|
= None, 0, None
|
|
225
226
|
|
|
@@ -241,22 +242,22 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
241
242
|
raise MangoAutomationError(*ERROR_MSG_0027)
|
|
242
243
|
|
|
243
244
|
async def __error(self, msg: str):
|
|
244
|
-
self.element_result_model.status = StatusEnum.FAIL.value
|
|
245
|
-
self.element_result_model.error_message = msg
|
|
246
|
-
self.base_data.log.debug(
|
|
247
|
-
f"""
|
|
248
|
-
元素操作失败----->
|
|
249
|
-
元 素 对 象:{self.element_model.model_dump() if self.element_model else self.element_model}
|
|
250
|
-
元素测试结果:{
|
|
251
|
-
self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
|
|
252
|
-
"""
|
|
253
|
-
)
|
|
254
|
-
file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
|
|
255
|
-
file_path = os.path.join(self.base_data.screenshot_path, file_name)
|
|
256
|
-
self.element_result_model.picture_path = file_path
|
|
257
|
-
self.element_result_model.picture_name = file_name
|
|
258
245
|
try:
|
|
246
|
+
self.element_result_model.status = StatusEnum.FAIL.value
|
|
247
|
+
self.element_result_model.error_message = msg
|
|
248
|
+
self.base_data.log.debug(
|
|
249
|
+
f"""
|
|
250
|
+
元素操作失败----->
|
|
251
|
+
元 素 对 象:{self.element_model.model_dump() if self.element_model else self.element_model}
|
|
252
|
+
元素测试结果:{
|
|
253
|
+
self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
|
|
254
|
+
"""
|
|
255
|
+
)
|
|
256
|
+
file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
|
|
257
|
+
file_path = os.path.join(self.base_data.screenshot_path, file_name)
|
|
259
258
|
await self.__error_screenshot(file_path)
|
|
259
|
+
self.element_result_model.picture_path = file_path
|
|
260
|
+
self.element_result_model.picture_name = file_name
|
|
260
261
|
except MangoAutomationError as error:
|
|
261
262
|
self.element_result_model.error_message += f'执行过程中发生失败,准备截图时截图失败,失败原因:{error.msg}'
|
|
262
263
|
except Exception as error:
|
|
@@ -265,18 +266,7 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
|
|
|
265
266
|
|
|
266
267
|
async def __error_screenshot(self, file_path):
|
|
267
268
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
268
|
-
|
|
269
|
-
await self.w_screenshot(file_path)
|
|
270
|
-
except (TargetClosedError, TimeoutError) as error:
|
|
271
|
-
self.base_data.log.debug(
|
|
272
|
-
f'截图出现异常失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
273
|
-
self.base_data.setup()
|
|
274
|
-
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
275
|
-
except AttributeError as error:
|
|
276
|
-
self.base_data.log.debug(
|
|
277
|
-
f'截图出现异常失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
278
|
-
self.base_data.setup()
|
|
279
|
-
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
269
|
+
await self.w_screenshot(file_path)
|
|
280
270
|
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
281
271
|
self.a_screenshot(file_path)
|
|
282
272
|
else:
|
|
@@ -7,7 +7,7 @@ import os
|
|
|
7
7
|
import traceback
|
|
8
8
|
|
|
9
9
|
import time
|
|
10
|
-
from playwright._impl._errors import TargetClosedError, Error
|
|
10
|
+
from playwright._impl._errors import TargetClosedError, Error
|
|
11
11
|
|
|
12
12
|
from mangotools.assertion import PublicAssertion
|
|
13
13
|
from mangotools.decorator import sync_retry
|
|
@@ -57,15 +57,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
57
57
|
self.base_data.log.error(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
|
|
58
58
|
raise Exception('不存在的设备类型')
|
|
59
59
|
|
|
60
|
-
def clean_data(self):
|
|
61
|
-
try:
|
|
62
|
-
self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
|
|
63
|
-
self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
|
|
64
|
-
self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
|
|
65
|
-
except MangoAutomationError as error:
|
|
66
|
-
self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
|
|
67
|
-
raise MangoAutomationError(error.code, error.msg)
|
|
68
|
-
|
|
69
60
|
def element_main(self) -> ElementResultModel:
|
|
70
61
|
try:
|
|
71
62
|
self.__main()
|
|
@@ -73,12 +64,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
73
64
|
time.sleep(self.element_model.sleep)
|
|
74
65
|
self.element_result_model.status = StatusEnum.SUCCESS.value
|
|
75
66
|
self.element_result_model.error_message = None
|
|
76
|
-
except TargetClosedError as error:
|
|
77
|
-
self.base_data.setup()
|
|
78
|
-
self.base_data.log.debug(
|
|
79
|
-
f'浏览器关闭异常,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
80
|
-
self.element_result_model.status = StatusEnum.FAIL.value
|
|
81
|
-
self.element_result_model.error_message = '浏览器被关闭,请不要认关闭浏览器,非认为管理请联系管理员解决!'
|
|
82
67
|
except MangoAutomationError as error:
|
|
83
68
|
self.__error(error.msg)
|
|
84
69
|
self.base_data.log.debug(f'已知异常,类型:{type(error)},失败详情:{error}')
|
|
@@ -97,17 +82,37 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
97
82
|
|
|
98
83
|
@sync_retry()
|
|
99
84
|
def __main(self):
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
self.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
self.
|
|
85
|
+
try:
|
|
86
|
+
self.element_model.loc = self.base_data.test_data.replace(self.element_model.loc)
|
|
87
|
+
self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
|
|
88
|
+
self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
|
|
89
|
+
except MangoAutomationError as error:
|
|
90
|
+
self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
|
|
91
|
+
raise MangoAutomationError(error.code, error.msg)
|
|
92
|
+
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
93
|
+
if not self.base_data.page and self.base_data.context:
|
|
94
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
95
|
+
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
96
|
+
if not self.base_data.android:
|
|
97
|
+
raise MangoAutomationError(*ERROR_MSG_0007)
|
|
109
98
|
else:
|
|
110
|
-
|
|
99
|
+
pass
|
|
100
|
+
try:
|
|
101
|
+
if self.element_model.type == ElementOperationEnum.OPE.value:
|
|
102
|
+
self.__ope()
|
|
103
|
+
elif self.element_model.type == ElementOperationEnum.ASS.value:
|
|
104
|
+
self.__ass()
|
|
105
|
+
elif self.element_model.type == ElementOperationEnum.SQL.value:
|
|
106
|
+
self.__sql()
|
|
107
|
+
elif self.element_model.type == ElementOperationEnum.CUSTOM.value:
|
|
108
|
+
self.__custom()
|
|
109
|
+
else:
|
|
110
|
+
raise MangoAutomationError(*ERROR_MSG_0015)
|
|
111
|
+
except TargetClosedError as error:
|
|
112
|
+
self.base_data.setup()
|
|
113
|
+
self.base_data.log.debug(
|
|
114
|
+
f'浏览器关闭异常,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
115
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
111
116
|
|
|
112
117
|
def __ope(self):
|
|
113
118
|
method_name = getattr(self.element_model, 'ope_key', None)
|
|
@@ -122,7 +127,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
122
127
|
raise MangoAutomationError(*ERROR_MSG_0048)
|
|
123
128
|
if self.element_model.ope_value is None:
|
|
124
129
|
raise MangoAutomationError(*ERROR_MSG_0054)
|
|
125
|
-
|
|
126
130
|
self.__ope_value()
|
|
127
131
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
128
132
|
self.web_action_element(
|
|
@@ -208,18 +212,15 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
208
212
|
'sub': self.element_model.sub
|
|
209
213
|
}
|
|
210
214
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
211
|
-
loc, \
|
|
212
|
-
self.element_result_model.ele_quantity, \
|
|
215
|
+
loc, self.element_result_model.ele_quantity, \
|
|
213
216
|
self.element_result_model.element_text \
|
|
214
217
|
= self.web_find_ele(**find_params, is_iframe=self.element_model.is_iframe)
|
|
215
218
|
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
216
|
-
loc, \
|
|
217
|
-
self.element_result_model.ele_quantity, \
|
|
219
|
+
loc, self.element_result_model.ele_quantity, \
|
|
218
220
|
self.element_result_model.element_text \
|
|
219
221
|
= self.a_find_ele(**find_params)
|
|
220
222
|
else:
|
|
221
|
-
loc, \
|
|
222
|
-
self.element_result_model.ele_quantity, \
|
|
223
|
+
loc, self.element_result_model.ele_quantity, \
|
|
223
224
|
self.element_result_model.element_text \
|
|
224
225
|
= None, 0, None
|
|
225
226
|
|
|
@@ -241,22 +242,22 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
241
242
|
raise MangoAutomationError(*ERROR_MSG_0027)
|
|
242
243
|
|
|
243
244
|
def __error(self, msg: str):
|
|
244
|
-
self.element_result_model.status = StatusEnum.FAIL.value
|
|
245
|
-
self.element_result_model.error_message = msg
|
|
246
|
-
self.base_data.log.debug(
|
|
247
|
-
f"""
|
|
248
|
-
元素操作失败----->
|
|
249
|
-
元 素 对 象:{self.element_model.model_dump() if self.element_model else self.element_model}
|
|
250
|
-
元素测试结果:{
|
|
251
|
-
self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
|
|
252
|
-
"""
|
|
253
|
-
)
|
|
254
|
-
file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
|
|
255
|
-
file_path = os.path.join(self.base_data.screenshot_path, file_name)
|
|
256
|
-
self.element_result_model.picture_path = file_path
|
|
257
|
-
self.element_result_model.picture_name = file_name
|
|
258
245
|
try:
|
|
246
|
+
self.element_result_model.status = StatusEnum.FAIL.value
|
|
247
|
+
self.element_result_model.error_message = msg
|
|
248
|
+
self.base_data.log.debug(
|
|
249
|
+
f"""
|
|
250
|
+
元素操作失败----->
|
|
251
|
+
元 素 对 象:{self.element_model.model_dump() if self.element_model else self.element_model}
|
|
252
|
+
元素测试结果:{
|
|
253
|
+
self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
|
|
254
|
+
"""
|
|
255
|
+
)
|
|
256
|
+
file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
|
|
257
|
+
file_path = os.path.join(self.base_data.screenshot_path, file_name)
|
|
259
258
|
self.__error_screenshot(file_path)
|
|
259
|
+
self.element_result_model.picture_path = file_path
|
|
260
|
+
self.element_result_model.picture_name = file_name
|
|
260
261
|
except MangoAutomationError as error:
|
|
261
262
|
self.element_result_model.error_message += f'执行过程中发生失败,准备截图时截图失败,失败原因:{error.msg}'
|
|
262
263
|
except Exception as error:
|
|
@@ -265,18 +266,7 @@ class SyncElement(SyncWebDevice, AndroidDriver):
|
|
|
265
266
|
|
|
266
267
|
def __error_screenshot(self, file_path):
|
|
267
268
|
if self.drive_type == DriveTypeEnum.WEB.value:
|
|
268
|
-
|
|
269
|
-
self.w_screenshot(file_path)
|
|
270
|
-
except (TargetClosedError, TimeoutError) as error:
|
|
271
|
-
self.base_data.log.debug(
|
|
272
|
-
f'截图出现异常失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
273
|
-
self.base_data.setup()
|
|
274
|
-
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
275
|
-
except AttributeError as error:
|
|
276
|
-
self.base_data.log.debug(
|
|
277
|
-
f'截图出现异常失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
278
|
-
self.base_data.setup()
|
|
279
|
-
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
269
|
+
self.w_screenshot(file_path)
|
|
280
270
|
elif self.drive_type == DriveTypeEnum.ANDROID.value:
|
|
281
271
|
self.a_screenshot(file_path)
|
|
282
272
|
else:
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_browser.py
RENAMED
|
@@ -12,10 +12,10 @@ from playwright._impl._errors import TimeoutError, Error, TargetClosedError
|
|
|
12
12
|
|
|
13
13
|
from mangotools.decorator import async_method_callback
|
|
14
14
|
from mangotools.models import MethodModel
|
|
15
|
+
from ..._base_data import BaseData
|
|
15
16
|
from ....exceptions import MangoAutomationError
|
|
16
17
|
from ....exceptions._error_msg import ERROR_MSG_0049, ERROR_MSG_0013, ERROR_MSG_0058, ERROR_MSG_0059, ERROR_MSG_0010
|
|
17
18
|
from ....tools import Meta
|
|
18
|
-
from ..._base_data import BaseData
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class AsyncWebBrowser(metaclass=Meta):
|
|
@@ -55,7 +55,18 @@ class AsyncWebBrowser(metaclass=Meta):
|
|
|
55
55
|
MethodModel(f='path', p='请输入截图保存路径', d=True)])
|
|
56
56
|
async def w_screenshot(self, path: str):
|
|
57
57
|
"""整个页面截图"""
|
|
58
|
-
|
|
58
|
+
try:
|
|
59
|
+
await self.base_data.page.screenshot(path=path, full_page=True)
|
|
60
|
+
except (TargetClosedError, TimeoutError) as error:
|
|
61
|
+
self.base_data.log.debug(
|
|
62
|
+
f'截图出现异常失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
63
|
+
self.base_data.setup()
|
|
64
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
65
|
+
except AttributeError as error:
|
|
66
|
+
self.base_data.log.debug(
|
|
67
|
+
f'截图出现异常失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
68
|
+
self.base_data.setup()
|
|
69
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
59
70
|
|
|
60
71
|
@async_method_callback('web', '浏览器操作', 3)
|
|
61
72
|
async def w_alert(self):
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_element.py
RENAMED
|
@@ -60,6 +60,14 @@ class AsyncWebElement(metaclass=Meta):
|
|
|
60
60
|
self.base_data.test_data.set_cache(key=set_cache_key, value=value)
|
|
61
61
|
return value
|
|
62
62
|
|
|
63
|
+
@async_method_callback('web', '元素操作', 5, [
|
|
64
|
+
MethodModel(f='locating'),
|
|
65
|
+
MethodModel(f='input_value', p='请输入输入内容', d=True)])
|
|
66
|
+
async def w_clear_input(self, locating: Locator, input_value: str):
|
|
67
|
+
"""元素清空再输入"""
|
|
68
|
+
await locating.clear()
|
|
69
|
+
await locating.fill(str(input_value))
|
|
70
|
+
|
|
63
71
|
@async_method_callback('web', '元素操作', 6, [MethodModel(f='locating')])
|
|
64
72
|
async def w_many_click(self, locating: Locator):
|
|
65
73
|
"""多元素循环单击"""
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_browser.py
RENAMED
|
@@ -54,7 +54,18 @@ class SyncWebBrowser(metaclass=Meta):
|
|
|
54
54
|
@sync_method_callback('web', '浏览器操作', 2, [MethodModel(f='path', p='请输入截图保存路径', d=True)])
|
|
55
55
|
def w_screenshot(self, path: str):
|
|
56
56
|
"""整个页面截图"""
|
|
57
|
-
|
|
57
|
+
try:
|
|
58
|
+
self.base_data.page.screenshot(path=path, full_page=True)
|
|
59
|
+
except (TargetClosedError, TimeoutError) as error:
|
|
60
|
+
self.base_data.log.debug(
|
|
61
|
+
f'截图出现异常失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
62
|
+
self.base_data.setup()
|
|
63
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
64
|
+
except AttributeError as error:
|
|
65
|
+
self.base_data.log.debug(
|
|
66
|
+
f'截图出现异常失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
67
|
+
self.base_data.setup()
|
|
68
|
+
raise MangoAutomationError(*ERROR_MSG_0010)
|
|
58
69
|
|
|
59
70
|
@sync_method_callback('web', '浏览器操作', 3)
|
|
60
71
|
def w_alert(self):
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_element.py
RENAMED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import os
|
|
6
6
|
|
|
7
7
|
import time
|
|
8
|
-
from mangotools.decorator import sync_method_callback
|
|
9
|
-
from mangotools.models import MethodModel
|
|
10
8
|
from playwright.sync_api import Locator, Error
|
|
11
9
|
|
|
10
|
+
from mangotools.decorator import sync_method_callback
|
|
11
|
+
from mangotools.models import MethodModel
|
|
12
12
|
from ....exceptions import MangoAutomationError
|
|
13
13
|
from ....exceptions._error_msg import ERROR_MSG_0024, ERROR_MSG_0056
|
|
14
14
|
from ....tools import Meta
|
|
@@ -59,6 +59,14 @@ class SyncWebElement(metaclass=Meta):
|
|
|
59
59
|
self.base_data.test_data.set_cache(key=set_cache_key, value=value)
|
|
60
60
|
return value
|
|
61
61
|
|
|
62
|
+
@sync_method_callback('web', '元素操作', 5, [
|
|
63
|
+
MethodModel(f='locating'),
|
|
64
|
+
MethodModel(f='input_value', p='请输入输入内容', d=True)])
|
|
65
|
+
def w_clear_input(self, locating: Locator, input_value: str):
|
|
66
|
+
"""元素清空再输入"""
|
|
67
|
+
locating.clear()
|
|
68
|
+
locating.fill(str(input_value))
|
|
69
|
+
|
|
62
70
|
@sync_method_callback('web', '元素操作', 6, [MethodModel(f='locating')])
|
|
63
71
|
def w_many_click(self, locating: Locator):
|
|
64
72
|
"""多元素循环单击"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mangoautomation
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.35
|
|
4
4
|
Summary: 测试工具
|
|
5
5
|
Home-page: https://gitee.com/mao-peng/testkit
|
|
6
6
|
Author: 毛鹏
|
|
@@ -12,7 +12,7 @@ Requires-Dist: pydantic==2.9.2
|
|
|
12
12
|
Requires-Dist: playwright==1.43.0
|
|
13
13
|
Requires-Dist: uiautomation==2.0.20
|
|
14
14
|
Requires-Dist: uiautomator2==3.2.5
|
|
15
|
-
Requires-Dist: mangotools==1.0.
|
|
15
|
+
Requires-Dist: mangotools==1.0.22
|
|
16
16
|
Requires-Dist: adbutils~=2.8.9
|
|
17
17
|
|
|
18
18
|
# testkit
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from setuptools import setup, find_packages
|
|
2
2
|
|
|
3
|
-
__version__ = '1.0.
|
|
3
|
+
__version__ = '1.0.35'
|
|
4
4
|
|
|
5
5
|
with open("README.md", "r", encoding='utf-8') as fh:
|
|
6
6
|
long_description = fh.read()
|
|
@@ -21,7 +21,7 @@ setup(
|
|
|
21
21
|
'playwright==1.43.0',
|
|
22
22
|
'uiautomation==2.0.20',
|
|
23
23
|
'uiautomator2==3.2.5',
|
|
24
|
-
'mangotools==1.0.
|
|
24
|
+
'mangotools==1.0.22',
|
|
25
25
|
'adbutils~=2.8.9',
|
|
26
26
|
|
|
27
27
|
],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/__init__.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_application.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_assertion.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_customization.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_element.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_equipment.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/android/_new_android.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/customization.py
RENAMED
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/pc/input_device.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/async_web/_page.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/__init__.py
RENAMED
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_assertion.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation/uidrive/web/sync_web/_page.py
RENAMED
|
File without changes
|
|
File without changes
|
{mangoautomation-1.0.33 → mangoautomation-1.0.35}/mangoautomation.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|