mangoautomation 1.1.22__py3-none-any.whl → 1.1.24__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 mangoautomation might be problematic. Click here for more details.
- mangoautomation/enums/__init__.py +0 -1
- mangoautomation/exceptions/__init__.py +0 -2
- mangoautomation/exceptions/error_msg.py +3 -3
- mangoautomation/mangos/__init__.py +14 -0
- mangoautomation/mangos/__pycache__/__init__.cpython-310.pyc +0 -0
- mangoautomation/mangos/mangos.cp310-win_amd64.pyd +0 -0
- mangoautomation/mangos/mangos.cp312-win_amd64.pyd +0 -0
- mangoautomation/mangos/mangos.cpython-310-darwin.so +0 -0
- mangoautomation/mangos/mangos.cpython-310-x86_64-linux-gnu.so +0 -0
- mangoautomation/mangos/mangos.cpython-312-darwin.so +0 -0
- mangoautomation/mangos/mangos.cpython-312-x86_64-linux-gnu.so +0 -0
- mangoautomation/models/__init__.py +0 -1
- mangoautomation/models/_ui_model.py +1 -0
- mangoautomation/tools/__init__.py +0 -1
- mangoautomation/tools/_uiautodev.py +1 -1
- mangoautomation/uidrives/__init__.py +2 -3
- mangoautomation/uidrives/_async_element.py +74 -48
- mangoautomation/uidrives/_base_data.py +16 -4
- mangoautomation/uidrives/_driver_object.py +7 -40
- mangoautomation/uidrives/_sync_element.py +75 -46
- mangoautomation/uidrives/android/__init__.py +2 -16
- mangoautomation/uidrives/pc/__init__.py +1 -2
- mangoautomation/uidrives/pc/element.py +1 -2
- mangoautomation/uidrives/pc/input_device.py +1 -2
- mangoautomation/uidrives/web/__init__.py +5 -0
- mangoautomation/uidrives/web/{async_web/__init__.py → _async_web.py} +82 -81
- mangoautomation/uidrives/web/{sync_web/__init__.py → _sync_web.py} +80 -74
- mangoautomation-1.1.24.dist-info/METADATA +42 -0
- mangoautomation-1.1.24.dist-info/RECORD +48 -0
- {mangoautomation-1.1.22.dist-info → mangoautomation-1.1.24.dist-info}/WHEEL +1 -1
- tests/__init__.py +0 -10
- tests/demo1.py +94 -0
- tests/get_ope.py +12 -3
- tests/test_ai_element.py +36 -0
- tests/test_ui_web.py +7 -3
- mangoautomation/uidrives/android/_application.py +0 -70
- mangoautomation/uidrives/android/_assertion.py +0 -90
- mangoautomation/uidrives/android/_customization.py +0 -15
- mangoautomation/uidrives/android/_element.py +0 -169
- mangoautomation/uidrives/android/_equipment.py +0 -151
- mangoautomation/uidrives/android/_new_android.py +0 -54
- mangoautomation/uidrives/android/_page.py +0 -116
- mangoautomation/uidrives/web/async_web/_assertion.py +0 -303
- mangoautomation/uidrives/web/async_web/_browser.py +0 -112
- mangoautomation/uidrives/web/async_web/_customization.py +0 -14
- mangoautomation/uidrives/web/async_web/_element.py +0 -250
- mangoautomation/uidrives/web/async_web/_input_device.py +0 -82
- mangoautomation/uidrives/web/async_web/_new_browser.py +0 -153
- mangoautomation/uidrives/web/async_web/_page.py +0 -63
- mangoautomation/uidrives/web/sync_web/_assertion.py +0 -304
- mangoautomation/uidrives/web/sync_web/_browser.py +0 -112
- mangoautomation/uidrives/web/sync_web/_customization.py +0 -14
- mangoautomation/uidrives/web/sync_web/_element.py +0 -250
- mangoautomation/uidrives/web/sync_web/_input_device.py +0 -80
- mangoautomation/uidrives/web/sync_web/_new_browser.py +0 -153
- mangoautomation/uidrives/web/sync_web/_page.py +0 -61
- mangoautomation-1.1.22.dist-info/METADATA +0 -34
- mangoautomation-1.1.22.dist-info/RECORD +0 -59
- {mangoautomation-1.1.22.dist-info → mangoautomation-1.1.24.dist-info/licenses}/LICENSE +0 -0
- {mangoautomation-1.1.22.dist-info → mangoautomation-1.1.24.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
from ...tools import Meta
|
|
2
|
-
from ...uidrives._base_data import BaseData
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
class WinElement(metaclass=Meta):
|
|
6
5
|
"""元素操作"""
|
|
7
6
|
|
|
8
|
-
def __init__(self, base_data
|
|
7
|
+
def __init__(self, base_data):
|
|
9
8
|
self.base_data = base_data
|
|
10
9
|
|
|
11
10
|
def click(self, control):
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
# @Time : 2024-11-30 23:44
|
|
5
5
|
# @Author : 毛鹏
|
|
6
6
|
from ...tools import Meta
|
|
7
|
-
from ...uidrives._base_data import BaseData
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class WinDeviceInput(metaclass=Meta):
|
|
11
10
|
"""输入设备操作"""
|
|
12
11
|
|
|
13
|
-
def __init__(self, base_data
|
|
12
|
+
def __init__(self, base_data):
|
|
14
13
|
self.base_data = base_data
|
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
# @Description:
|
|
4
4
|
# @Time : 2023/5/16 14:50
|
|
5
5
|
# @Author : 毛鹏
|
|
6
|
+
from ._async_web import AsyncWebDevice, AsyncWebCustomization, AsyncWebAssertion
|
|
7
|
+
from ._sync_web import SyncWebDevice, SyncWebCustomization, SyncWebAssertion
|
|
8
|
+
|
|
9
|
+
__all__ = ['AsyncWebDevice', 'AsyncWebCustomization', 'AsyncWebAssertion', 'SyncWebDevice', 'SyncWebCustomization',
|
|
10
|
+
'SyncWebAssertion']
|
|
@@ -8,30 +8,16 @@ import traceback
|
|
|
8
8
|
|
|
9
9
|
from playwright.async_api import Locator, Error, TimeoutError
|
|
10
10
|
|
|
11
|
+
from mangoautomation.mangos import AsyncWebAssertion, AsyncWebBrowser, AsyncWebCustomization, AsyncWebElement, \
|
|
12
|
+
AsyncWebDeviceInput, AsyncWebPage, ElementMain
|
|
11
13
|
from mangotools.assertion import MangoAssertion
|
|
12
14
|
from mangotools.enums import StatusEnum
|
|
13
15
|
from mangotools.mangos import Mango
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from ....uidrives._base_data import BaseData
|
|
18
|
-
from ....uidrives.web.async_web._assertion import AsyncWebAssertion
|
|
19
|
-
from ....uidrives.web.async_web._browser import AsyncWebBrowser
|
|
20
|
-
from ....uidrives.web.async_web._customization import AsyncWebCustomization
|
|
21
|
-
from ....uidrives.web.async_web._element import AsyncWebElement
|
|
22
|
-
from ....uidrives.web.async_web._input_device import AsyncWebDeviceInput
|
|
23
|
-
from ....uidrives.web.async_web._page import AsyncWebPage
|
|
16
|
+
from ...enums import ElementExpEnum
|
|
17
|
+
from ...exceptions import MangoAutomationError
|
|
18
|
+
from ...exceptions.error_msg import *
|
|
24
19
|
|
|
25
20
|
re = re
|
|
26
|
-
__all__ = [
|
|
27
|
-
'AsyncWebPage',
|
|
28
|
-
'AsyncWebElement',
|
|
29
|
-
'AsyncWebDeviceInput',
|
|
30
|
-
'AsyncWebCustomization',
|
|
31
|
-
'AsyncWebBrowser',
|
|
32
|
-
'AsyncWebAssertion',
|
|
33
|
-
'AsyncWebDevice',
|
|
34
|
-
]
|
|
35
21
|
|
|
36
22
|
|
|
37
23
|
class AsyncWebDevice(AsyncWebBrowser,
|
|
@@ -40,7 +26,7 @@ class AsyncWebDevice(AsyncWebBrowser,
|
|
|
40
26
|
AsyncWebDeviceInput,
|
|
41
27
|
AsyncWebCustomization):
|
|
42
28
|
|
|
43
|
-
def __init__(self, base_data
|
|
29
|
+
def __init__(self, base_data):
|
|
44
30
|
super().__init__(base_data)
|
|
45
31
|
|
|
46
32
|
async def open_url(self, is_open: bool = False):
|
|
@@ -50,9 +36,9 @@ class AsyncWebDevice(AsyncWebBrowser,
|
|
|
50
36
|
self.base_data.is_open_url = True
|
|
51
37
|
|
|
52
38
|
async def web_action_element(self, name, ope_key, ope_value, ):
|
|
53
|
-
self.base_data.log.debug(f'
|
|
39
|
+
self.base_data.log.debug(f'操作元素{name}:,key:{ope_key},value:{ope_value}')
|
|
54
40
|
try:
|
|
55
|
-
await
|
|
41
|
+
await ElementMain.a_element(self, ope_key, ope_value)
|
|
56
42
|
except TimeoutError as error:
|
|
57
43
|
self.base_data.log.debug(f'WEB自动化操作失败-1,类型:{type(error)},失败详情:{error}')
|
|
58
44
|
raise MangoAutomationError(*ERROR_MSG_0011, value=(name,))
|
|
@@ -69,7 +55,6 @@ class AsyncWebDevice(AsyncWebBrowser,
|
|
|
69
55
|
try:
|
|
70
56
|
if is_method:
|
|
71
57
|
if ope_value.get('actual', None) is None:
|
|
72
|
-
traceback.print_exc()
|
|
73
58
|
raise MangoAutomationError(*ERROR_MSG_0031, value=(name,))
|
|
74
59
|
self.base_data.log.debug(f'开始断言-1,方法:{ope_key},断言值:{ope_value}')
|
|
75
60
|
return await Mango.a_e(AsyncWebAssertion(self.base_data), ope_key, ope_value)
|
|
@@ -86,80 +71,96 @@ class AsyncWebDevice(AsyncWebBrowser,
|
|
|
86
71
|
except ValueError as error:
|
|
87
72
|
self.base_data.log.error(f'WEB自动化断言失败-3,类型:{type(error)},失败详情:{error}')
|
|
88
73
|
raise MangoAutomationError(*ERROR_MSG_0005)
|
|
89
|
-
|
|
90
74
|
except Error as error:
|
|
91
75
|
self.base_data.log.error(f'WEB自动化断言失败-4,类型:{type(error)},失败详情:{error}')
|
|
92
76
|
raise MangoAutomationError(*ERROR_MSG_0052, value=(name,), )
|
|
93
77
|
|
|
94
|
-
async def
|
|
78
|
+
async def web_find_element(self, name, _type, exp, loc, sub, is_iframe) \
|
|
95
79
|
-> tuple[Locator, int, str] | tuple[list[Locator], int, str]:
|
|
96
80
|
self.base_data.log.debug(
|
|
97
|
-
f'
|
|
81
|
+
f'查找元素-1,名称:{name},_type:{_type},exp:{exp},loc:{loc},sub:{sub},is_iframe:{is_iframe}')
|
|
98
82
|
if is_iframe != StatusEnum.SUCCESS.value:
|
|
99
83
|
locator: Locator = await self.__find_ele(self.base_data.page, exp, loc)
|
|
100
84
|
try:
|
|
101
|
-
|
|
102
|
-
loc = locator.nth(sub - 1) if sub else locator
|
|
103
|
-
try:
|
|
104
|
-
text = await self.w_get_text(loc)
|
|
105
|
-
except Exception:
|
|
106
|
-
text = None
|
|
107
|
-
return loc, count, text
|
|
85
|
+
return await self.__element_info(locator, sub)
|
|
108
86
|
except Error as error:
|
|
109
87
|
self.base_data.log.debug(
|
|
110
88
|
f'WEB自动化查找元素失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
111
89
|
raise MangoAutomationError(*ERROR_MSG_0041, value=(name, loc))
|
|
112
90
|
else:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
91
|
+
return await self.__is_iframe(_type, exp, loc, sub)
|
|
92
|
+
|
|
93
|
+
async def __element_info(self, locator: Locator, sub) -> tuple[Locator, int, str]:
|
|
94
|
+
count = await locator.count()
|
|
95
|
+
if count < 1:
|
|
96
|
+
raise MangoAutomationError(*ERROR_MSG_0053)
|
|
97
|
+
if sub is not None:
|
|
98
|
+
loc_result = locator.nth(sub - 1) if sub else locator
|
|
99
|
+
else:
|
|
100
|
+
loc_result = locator.nth(0)
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
text = await self.w_get_text(loc_result)
|
|
104
|
+
except Exception:
|
|
105
|
+
text = None
|
|
106
|
+
return loc_result, count, text
|
|
107
|
+
|
|
108
|
+
async def ai_element_info(self, locator: Locator) -> tuple[Locator, int, str]:
|
|
109
|
+
count = await locator.count()
|
|
110
|
+
if count < 1:
|
|
111
|
+
raise MangoAutomationError(*ERROR_MSG_0053)
|
|
112
|
+
try:
|
|
113
|
+
text = await self.w_get_text(locator.nth(0))
|
|
114
|
+
except Exception:
|
|
115
|
+
text = None
|
|
116
|
+
return locator.nth(0), count, text
|
|
117
|
+
|
|
118
|
+
async def __is_iframe(self, _type, exp, loc, sub):
|
|
119
|
+
ele_list: list[Locator] = []
|
|
120
|
+
for i in self.base_data.page.frames:
|
|
121
|
+
locator: Locator = await self.__find_ele(i, exp, loc)
|
|
122
|
+
try:
|
|
123
|
+
count = await locator.count()
|
|
124
|
+
except Error as error:
|
|
125
|
+
self.base_data.log.debug(
|
|
126
|
+
f'WEB自动化查找元素失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
127
|
+
raise MangoAutomationError(*ERROR_MSG_0041, )
|
|
128
|
+
if count > 0:
|
|
129
|
+
for nth in range(0, count):
|
|
130
|
+
ele_list.append(locator.nth(nth))
|
|
131
|
+
else:
|
|
128
132
|
raise MangoAutomationError(*ERROR_MSG_0023)
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
try:
|
|
134
|
+
count = len(ele_list)
|
|
135
|
+
loc = ele_list[sub - 1] if sub else ele_list[0]
|
|
131
136
|
try:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return loc, count, text
|
|
139
|
-
except IndexError:
|
|
140
|
-
raise MangoAutomationError(*ERROR_MSG_0025, value=(len(ele_list),))
|
|
137
|
+
text = await self.w_get_text(loc)
|
|
138
|
+
except Exception:
|
|
139
|
+
text = None
|
|
140
|
+
return loc, count, text
|
|
141
|
+
except IndexError:
|
|
142
|
+
raise MangoAutomationError(*ERROR_MSG_0025, value=(len(ele_list),))
|
|
141
143
|
|
|
142
144
|
async def __find_ele(self, page, exp, loc) -> Locator:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
if exp == ElementExpEnum.LOCATOR.value:
|
|
146
|
+
try:
|
|
147
|
+
return eval(f"await page.{loc}")
|
|
148
|
+
except SyntaxError:
|
|
145
149
|
try:
|
|
146
|
-
return eval(f"
|
|
147
|
-
except SyntaxError:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return page.get_by_placeholder(loc)
|
|
164
|
-
case _:
|
|
165
|
-
raise MangoAutomationError(*ERROR_MSG_0020)
|
|
150
|
+
return eval(f"page.{loc}")
|
|
151
|
+
except SyntaxError as error:
|
|
152
|
+
self.base_data.log.error(f'WEB自动化查找元素失败-3,类型:{type(error)},失败详情:{error}')
|
|
153
|
+
raise MangoAutomationError(*ERROR_MSG_0022)
|
|
154
|
+
except NameError as error:
|
|
155
|
+
self.base_data.log.error(f'WEB自动化查找元素失败-4,类型:{type(error)},失败详情:{error}')
|
|
156
|
+
raise MangoAutomationError(*ERROR_MSG_0060)
|
|
157
|
+
elif exp == ElementExpEnum.XPATH.value:
|
|
158
|
+
return page.locator(f'xpath={loc}')
|
|
159
|
+
elif exp == ElementExpEnum.CSS.value:
|
|
160
|
+
return page.locator(loc)
|
|
161
|
+
elif exp == ElementExpEnum.TEXT.value:
|
|
162
|
+
return page.get_by_text(loc, exact=True)
|
|
163
|
+
elif exp == ElementExpEnum.PLACEHOLDER.value:
|
|
164
|
+
return page.get_by_placeholder(loc)
|
|
165
|
+
else:
|
|
166
|
+
raise MangoAutomationError(*ERROR_MSG_0020)
|
|
@@ -8,30 +8,16 @@ import traceback
|
|
|
8
8
|
|
|
9
9
|
from playwright.sync_api import Locator, TimeoutError, Error
|
|
10
10
|
|
|
11
|
+
from mangoautomation.mangos import SyncWebAssertion, SyncWebBrowser, SyncWebCustomization, SyncWebElement, \
|
|
12
|
+
SyncWebDeviceInput, SyncWebPage, ElementMain
|
|
11
13
|
from mangotools.assertion import MangoAssertion
|
|
12
14
|
from mangotools.enums import StatusEnum
|
|
13
15
|
from mangotools.mangos import Mango
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from ....uidrives._base_data import BaseData
|
|
18
|
-
from ....uidrives.web.sync_web._assertion import SyncWebAssertion
|
|
19
|
-
from ....uidrives.web.sync_web._browser import SyncWebBrowser
|
|
20
|
-
from ....uidrives.web.sync_web._customization import SyncWebCustomization
|
|
21
|
-
from ....uidrives.web.sync_web._element import SyncWebElement
|
|
22
|
-
from ....uidrives.web.sync_web._input_device import SyncWebDeviceInput
|
|
23
|
-
from ....uidrives.web.sync_web._page import SyncWebPage
|
|
16
|
+
from ...enums import ElementExpEnum
|
|
17
|
+
from ...exceptions import MangoAutomationError
|
|
18
|
+
from ...exceptions.error_msg import *
|
|
24
19
|
|
|
25
20
|
re = re
|
|
26
|
-
__all__ = [
|
|
27
|
-
'SyncWebAssertion',
|
|
28
|
-
'SyncWebBrowser',
|
|
29
|
-
'SyncWebCustomization',
|
|
30
|
-
'SyncWebDeviceInput',
|
|
31
|
-
'SyncWebElement',
|
|
32
|
-
'SyncWebPage',
|
|
33
|
-
'SyncWebDevice',
|
|
34
|
-
]
|
|
35
21
|
|
|
36
22
|
|
|
37
23
|
class SyncWebDevice(SyncWebBrowser,
|
|
@@ -40,7 +26,7 @@ class SyncWebDevice(SyncWebBrowser,
|
|
|
40
26
|
SyncWebDeviceInput,
|
|
41
27
|
SyncWebCustomization):
|
|
42
28
|
|
|
43
|
-
def __init__(self, base_data
|
|
29
|
+
def __init__(self, base_data):
|
|
44
30
|
super().__init__(base_data)
|
|
45
31
|
|
|
46
32
|
def open_url(self, is_open: bool = False):
|
|
@@ -52,7 +38,7 @@ class SyncWebDevice(SyncWebBrowser,
|
|
|
52
38
|
def web_action_element(self, name, ope_key, ope_value, ):
|
|
53
39
|
self.base_data.log.debug(f'操作元素,名称:{name},key:{ope_key},value:{ope_value}')
|
|
54
40
|
try:
|
|
55
|
-
|
|
41
|
+
ElementMain.s_element(self, ope_key, ope_value)
|
|
56
42
|
except TimeoutError as error:
|
|
57
43
|
self.base_data.log.debug(f'WEB自动化操作失败-1,类型:{type(error)},失败详情:{error}')
|
|
58
44
|
raise MangoAutomationError(*ERROR_MSG_0011, value=(name,))
|
|
@@ -89,72 +75,92 @@ class SyncWebDevice(SyncWebBrowser,
|
|
|
89
75
|
self.base_data.log.error(f'WEB自动化断言失败-4,类型:{type(error)},失败详情:{error}')
|
|
90
76
|
raise MangoAutomationError(*ERROR_MSG_0052, value=(name,), )
|
|
91
77
|
|
|
92
|
-
def
|
|
78
|
+
def web_find_element(self, name, _type, exp, loc, sub, is_iframe) \
|
|
93
79
|
-> tuple[Locator, int, str] | tuple[list[Locator], int, str]:
|
|
94
80
|
self.base_data.log.debug(
|
|
95
81
|
f'查找元素,名称:{name},_type:{_type},exp:{exp},loc:{loc},sub:{sub},is_iframe:{is_iframe}')
|
|
96
82
|
if is_iframe != StatusEnum.SUCCESS.value:
|
|
97
83
|
locator: Locator = self.__find_ele(self.base_data.page, exp, loc)
|
|
98
84
|
try:
|
|
99
|
-
|
|
100
|
-
loc = locator.nth(sub - 1) if sub else locator
|
|
101
|
-
try:
|
|
102
|
-
text = self.w_get_text(loc)
|
|
103
|
-
except Exception:
|
|
104
|
-
text = None
|
|
105
|
-
return loc, count, text
|
|
85
|
+
return self.__element_info(locator, sub)
|
|
106
86
|
except Error as error:
|
|
107
87
|
self.base_data.log.debug(
|
|
108
88
|
f'WEB自动化查找元素失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
109
89
|
raise MangoAutomationError(*ERROR_MSG_0041, )
|
|
110
90
|
else:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for nth in range(0, count):
|
|
122
|
-
ele_list.append(locator.nth(nth))
|
|
123
|
-
else:
|
|
124
|
-
raise MangoAutomationError(*ERROR_MSG_0023)
|
|
91
|
+
return self.__is_iframe(_type, exp, loc, sub)
|
|
92
|
+
|
|
93
|
+
def __element_info(self, locator: Locator, sub) -> tuple[Locator, int, str]:
|
|
94
|
+
count = locator.count()
|
|
95
|
+
if count < 1:
|
|
96
|
+
raise MangoAutomationError(*ERROR_MSG_0053)
|
|
97
|
+
if sub is not None:
|
|
98
|
+
loc_result = locator.nth(sub - 1) if sub else locator
|
|
99
|
+
else:
|
|
100
|
+
loc_result = locator.nth(0)
|
|
125
101
|
|
|
102
|
+
try:
|
|
103
|
+
text = self.w_get_text(loc_result)
|
|
104
|
+
except Exception:
|
|
105
|
+
text = None
|
|
106
|
+
return loc_result, count, text
|
|
107
|
+
|
|
108
|
+
def ai_element_info(self, locator: Locator) -> tuple[Locator, int, str]:
|
|
109
|
+
count = locator.count()
|
|
110
|
+
if count < 1:
|
|
111
|
+
raise MangoAutomationError(*ERROR_MSG_0053)
|
|
112
|
+
try:
|
|
113
|
+
text = self.w_get_text(locator.nth(0))
|
|
114
|
+
except Exception:
|
|
115
|
+
text = None
|
|
116
|
+
return locator.nth(0), count, text
|
|
117
|
+
|
|
118
|
+
def __is_iframe(self, _type, exp, loc, sub):
|
|
119
|
+
ele_list: list[Locator] = []
|
|
120
|
+
for i in self.base_data.page.frames:
|
|
121
|
+
locator: Locator = self.__find_ele(i, exp, loc)
|
|
126
122
|
try:
|
|
127
|
-
count =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
123
|
+
count = locator.count()
|
|
124
|
+
except Error as error:
|
|
125
|
+
self.base_data.log.debug(
|
|
126
|
+
f'WEB自动化查找元素失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
|
|
127
|
+
raise MangoAutomationError(*ERROR_MSG_0041, )
|
|
128
|
+
if count > 0:
|
|
129
|
+
for nth in range(0, count):
|
|
130
|
+
ele_list.append(locator.nth(nth))
|
|
131
|
+
else:
|
|
132
|
+
raise MangoAutomationError(*ERROR_MSG_0023)
|
|
133
|
+
try:
|
|
134
|
+
count = len(ele_list)
|
|
135
|
+
loc = ele_list[sub - 1] if sub else ele_list[0]
|
|
136
|
+
try:
|
|
137
|
+
text = self.w_get_text(loc)
|
|
138
|
+
except Exception:
|
|
139
|
+
text = None
|
|
140
|
+
return loc, count, text
|
|
141
|
+
except IndexError:
|
|
142
|
+
raise MangoAutomationError(*ERROR_MSG_0025, value=(len(ele_list),))
|
|
136
143
|
|
|
137
144
|
def __find_ele(self, page, exp, loc) -> Locator:
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
if exp == ElementExpEnum.LOCATOR.value:
|
|
146
|
+
try:
|
|
147
|
+
return eval(f"page.{loc}")
|
|
148
|
+
except SyntaxError:
|
|
140
149
|
try:
|
|
141
|
-
return eval(f"page.{loc}")
|
|
142
|
-
except SyntaxError:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return page.get_by_placeholder(loc)
|
|
159
|
-
case _:
|
|
160
|
-
raise MangoAutomationError(*ERROR_MSG_0020)
|
|
150
|
+
return eval(f"await page.{loc}")
|
|
151
|
+
except SyntaxError as error:
|
|
152
|
+
self.base_data.log.error(f'WEB自动化查找元素失败-3,类型:{type(error)},失败详情:{error}')
|
|
153
|
+
raise MangoAutomationError(*ERROR_MSG_0022)
|
|
154
|
+
except NameError as error:
|
|
155
|
+
self.base_data.log.error(f'WEB自动化查找元素失败-4,类型:{type(error)},失败详情:{error}')
|
|
156
|
+
raise MangoAutomationError(*ERROR_MSG_0060)
|
|
157
|
+
elif exp == ElementExpEnum.XPATH.value:
|
|
158
|
+
return page.locator(f'xpath={loc}')
|
|
159
|
+
elif exp == ElementExpEnum.CSS.value:
|
|
160
|
+
return page.locator(loc)
|
|
161
|
+
elif exp == ElementExpEnum.TEXT.value:
|
|
162
|
+
return page.get_by_text(loc, exact=True)
|
|
163
|
+
elif exp == ElementExpEnum.PLACEHOLDER.value:
|
|
164
|
+
return page.get_by_placeholder(loc)
|
|
165
|
+
else:
|
|
166
|
+
raise MangoAutomationError(*ERROR_MSG_0020)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mangoautomation
|
|
3
|
+
Version: 1.1.24
|
|
4
|
+
Summary: 测试工具
|
|
5
|
+
Home-page: https://gitee.com/mao-peng/testkit
|
|
6
|
+
Author: 毛鹏
|
|
7
|
+
Author-email: 729164035@qq.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: setuptools==78.1.1
|
|
12
|
+
Requires-Dist: pydantic>=2.9.2
|
|
13
|
+
Requires-Dist: playwright==1.43.0
|
|
14
|
+
Requires-Dist: uiautomation>=2.0.20
|
|
15
|
+
Requires-Dist: uiautomator2>=3.2.5
|
|
16
|
+
Requires-Dist: mangotools>=1.1.42
|
|
17
|
+
Requires-Dist: adbutils~=2.8.9
|
|
18
|
+
Requires-Dist: uiautodev>=0.9.0
|
|
19
|
+
Requires-Dist: beautifulsoup4==4.14.2
|
|
20
|
+
Requires-Dist: openai==2.6.1
|
|
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
|
+
|
|
30
|
+
# testkit
|
|
31
|
+
|
|
32
|
+
#### 介绍
|
|
33
|
+
|
|
34
|
+
测试工具
|
|
35
|
+
|
|
36
|
+
#### 安装教程
|
|
37
|
+
|
|
38
|
+
1. pip install mangokit
|
|
39
|
+
|
|
40
|
+
#### 使用说明
|
|
41
|
+
|
|
42
|
+
1.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
mangoautomation/__init__.py,sha256=JxPNVexFQvkBfh0awPNeHxQGU_gtVgYPwD5rYeuHWEk,125
|
|
2
|
+
mangoautomation/enums/__init__.py,sha256=PnOgNttAXT64elr_Fd1ZthuAddCkm7sh4xwm9Eutm_I,373
|
|
3
|
+
mangoautomation/enums/_base_enum.py,sha256=dpaXsdhWY08BhIzi1B1ksh_p18ZTmhWvTYhbd3n_ONQ,1176
|
|
4
|
+
mangoautomation/enums/_ui_enum.py,sha256=mT_MfQ7TEw-BgHIqH0wXTA_yVWsaWnd3iHSHi9E0pgA,4599
|
|
5
|
+
mangoautomation/exceptions/__init__.py,sha256=2j3ravPuzljR2Mbq8J2JLdXUzII7hzrjdVjmEc_NHJU,211
|
|
6
|
+
mangoautomation/exceptions/_exceptions.py,sha256=BiyST1QPivpfIOuKn1gKhpXOyBv6gfip_KvlQuu8ctw,385
|
|
7
|
+
mangoautomation/exceptions/error_msg.py,sha256=0unQ_tgrRJtVMAOXTzhQJkwO4_7lhMKAMMCfwmzQD58,5517
|
|
8
|
+
mangoautomation/mangos/__init__.py,sha256=gEu8lVHGXm8PDTBZ1XXWNUOAbCtHb37uKQLBRYQR4rs,644
|
|
9
|
+
mangoautomation/mangos/mangos.cp310-win_amd64.pyd,sha256=eONlyQI0MFBVi1Y5hmujXP8r3TXqDBMTuNvyXHEQPI8,1764352
|
|
10
|
+
mangoautomation/mangos/mangos.cp312-win_amd64.pyd,sha256=uetCI6KIShYKfogcqkaeFi9sEQYIXUBmuBLyMBKjkLM,1893376
|
|
11
|
+
mangoautomation/mangos/mangos.cpython-310-darwin.so,sha256=3BNB431YQZj0N0o4BUQvTcCd7Saq4E4Mgbw94Ikv0eE,3561840
|
|
12
|
+
mangoautomation/mangos/mangos.cpython-310-x86_64-linux-gnu.so,sha256=ZHPxfgMFF16J_NA3ELb2lG4lkq6foJnVAIn2UxC-fSA,10588640
|
|
13
|
+
mangoautomation/mangos/mangos.cpython-312-darwin.so,sha256=hAnmTWgHjDlVpPNQdctf2JU95gJuHpuAT4i9cP-LX3s,3479632
|
|
14
|
+
mangoautomation/mangos/mangos.cpython-312-x86_64-linux-gnu.so,sha256=k84Ey3BY9wz7UzSS5OuZzx32TlwncoEvSfmHWInZMhA,10804456
|
|
15
|
+
mangoautomation/mangos/__pycache__/__init__.cpython-310.pyc,sha256=mlbMT0_xx35rLFukbmGWBgelTH327kE0V5k_bJiOPH8,604
|
|
16
|
+
mangoautomation/models/__init__.py,sha256=wHACwBCrd9HCvmrAkTFUV3qmK9GnOa-FJFiL0kOQjME,309
|
|
17
|
+
mangoautomation/models/_ui_model.py,sha256=nfxh_4TpOLzKKWC7c-IgMLVZY5wkTPfyS_Oh-SvsYsk,1825
|
|
18
|
+
mangoautomation/tools/__init__.py,sha256=c3IXhoodknOukOyM6db2tXIdDRodgmUZorEAkkruQf0,282
|
|
19
|
+
mangoautomation/tools/_mate.py,sha256=9lk_EJnAX_OyXbe5WacyHkkcEr2ScBgasl6eUnlklWA,405
|
|
20
|
+
mangoautomation/tools/_uiautodev.py,sha256=KYYWOQ_sp91LN_zeKAuIvCqjabb2_1-VhgOg1K7cQrw,1372
|
|
21
|
+
mangoautomation/uidrive/__init__.py,sha256=9N2DTDyLcmgxAHctBjZOb8LwdDeKQnwEOWZ9kNcM4Uw,350
|
|
22
|
+
mangoautomation/uidrives/__init__.py,sha256=JEoWqpoDIch8JiQ7WcnuDh3Bjg0Yqo_xfkbqY5iHSa8,617
|
|
23
|
+
mangoautomation/uidrives/_async_element.py,sha256=87BhadK9BJtcv_VzJUM3kX5sdp8b8Kk-abkU9oE3T7M,16206
|
|
24
|
+
mangoautomation/uidrives/_base_data.py,sha256=gp9730Hd8uarRv8xARIddgMWGhaJ_RKDd_gjewwWr04,4436
|
|
25
|
+
mangoautomation/uidrives/_driver_object.py,sha256=o2egGOZfkRVS2PEors8t5TPqTLyRbO1EObH8dY87TUo,1033
|
|
26
|
+
mangoautomation/uidrives/_sync_element.py,sha256=TU2E7AKz0Ku4qXLEtxx-whJPJ4KLYLK_EuKgChpcedM,15906
|
|
27
|
+
mangoautomation/uidrives/android/__init__.py,sha256=i6WjXlNq6oUZ4y79Gih_XzI9tV7du-Jrm9IAuROgSzo,5180
|
|
28
|
+
mangoautomation/uidrives/ios/__init__.py,sha256=SdxI8e5AOoAb8JTaDoMkObezIluJ50nm2b6zeDHv1PI,125
|
|
29
|
+
mangoautomation/uidrives/pc/__init__.py,sha256=Jphhspu-3AHCyDX5ZM_-DWeC9ZerWy2Omb3MOck6CI4,2210
|
|
30
|
+
mangoautomation/uidrives/pc/assertion.py,sha256=mH25hZ2i4T8kA1F2loW_nuPJ-Hb0z1pwILTJqkwwpLA,125
|
|
31
|
+
mangoautomation/uidrives/pc/customization.py,sha256=UkpHWFSYsu_t-GmMRDmii1Bs_Y1eKD34oZfJBFHV2Ng,240
|
|
32
|
+
mangoautomation/uidrives/pc/element.py,sha256=OGbJHbgJPBjRjXqM-NIWUnScn7lIHoBxnrakog_s4l8,465
|
|
33
|
+
mangoautomation/uidrives/pc/input_device.py,sha256=k-v7tRW8NkJxzcezqSIfICGRBqEdsssBeRTmtupVTU8,299
|
|
34
|
+
mangoautomation/uidrives/pc/new_windows.py,sha256=lETHZa7cW8Z0iUShzgVTRxqivkYaOo8WIE58q_8KYfQ,2338
|
|
35
|
+
mangoautomation/uidrives/web/__init__.py,sha256=TJyYt6EUoRfWYrV193RHpopKfixipVUp4TrhB5DoEKA,434
|
|
36
|
+
mangoautomation/uidrives/web/_async_web.py,sha256=Uwta7cIYo-0Qe5RbaIvRSQ-IvOxCNtbH_RcIm1JNxEQ,8204
|
|
37
|
+
mangoautomation/uidrives/web/_sync_web.py,sha256=NCF97mYWQBLsOkcEXHKbAGLYGt4rK7NSjks6PubLe_k,8049
|
|
38
|
+
mangoautomation-1.1.24.dist-info/licenses/LICENSE,sha256=03WP-mgFmo8ofRYDe1HVDQUEUKQZ2q6P6Q-2A4c-46A,1085
|
|
39
|
+
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
tests/demo1.py,sha256=Wcz63WWXe48arwmCh23ejT66ZbJFV2I7J05AOEZ5aq8,3056
|
|
41
|
+
tests/get_ope.py,sha256=2m7gkOiVSIAzTwnoQwp2JaphM5rPClqvwf24x7R3Az4,476
|
|
42
|
+
tests/test_ai_element.py,sha256=k__iifxebvPPfGdRS-yzkEH80fBIlKJcZ-m3N6Xkz6Q,1437
|
|
43
|
+
tests/test_ui_and.py,sha256=A_0pqG6s5Ts02He7P3NwuDSK3g9Q3VP1Sb_P8wq6g0Q,125
|
|
44
|
+
tests/test_ui_web.py,sha256=RBACNYc7XdvENHzg4YElsSQlEmPVa_AyOKWTYTPXM14,2578
|
|
45
|
+
mangoautomation-1.1.24.dist-info/METADATA,sha256=9FYm61XGtonV_-B7Ea-bF_DOFF8wBtw-Qe9kLCCprd8,941
|
|
46
|
+
mangoautomation-1.1.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
mangoautomation-1.1.24.dist-info/top_level.txt,sha256=g-uCmjvEODG8WFbmwbGM0-G0zHntHv8ZsS0PQRaMGtE,22
|
|
48
|
+
mangoautomation-1.1.24.dist-info/RECORD,,
|
tests/__init__.py
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# @Project: 芒果测试平台
|
|
3
|
-
# @Description:
|
|
4
|
-
# @Time : 2024-09-07 23:25
|
|
5
|
-
# @Author : 毛鹏
|
|
6
|
-
import random
|
|
7
|
-
|
|
8
|
-
data_list = [{'exp': 2, 'loc': 'get_by_role("textbox", name="请输入1密码")'},
|
|
9
|
-
{'exp': 0, 'loc': '//input[@type="password"]'}]
|
|
10
|
-
print(random.randint(0, len(data_list) - 1), len(data_list))
|