mangoautomation 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mangoautomation might be problematic. Click here for more details.
- mangoautomation/__init__.py +5 -0
- mangoautomation/enums/__init__.py +19 -0
- mangoautomation/enums/_base_enum.py +38 -0
- mangoautomation/enums/_ui_enum.py +110 -0
- mangoautomation/exceptions/__init__.py +14 -0
- mangoautomation/exceptions/_error_msg.py +73 -0
- mangoautomation/exceptions/_exceptions.py +14 -0
- mangoautomation/models/__init__.py +15 -0
- mangoautomation/models/_ui_model.py +61 -0
- mangoautomation/tools/__init__.py +13 -0
- mangoautomation/tools/_mate.py +12 -0
- mangoautomation/uidrive/__init__.py +20 -0
- mangoautomation/uidrive/_async_element.py +286 -0
- mangoautomation/uidrive/_base_data.py +103 -0
- mangoautomation/uidrive/_driver_object.py +63 -0
- mangoautomation/uidrive/_sync_element.py +286 -0
- mangoautomation/uidrive/android/__init__.py +127 -0
- mangoautomation/uidrive/android/_application.py +69 -0
- mangoautomation/uidrive/android/_assertion.py +84 -0
- mangoautomation/uidrive/android/_customization.py +15 -0
- mangoautomation/uidrive/android/_element.py +168 -0
- mangoautomation/uidrive/android/_equipment.py +150 -0
- mangoautomation/uidrive/android/_new_android.py +54 -0
- mangoautomation/uidrive/android/_page.py +116 -0
- mangoautomation/uidrive/pc/__init__.py +80 -0
- mangoautomation/uidrive/pc/assertion.py +5 -0
- mangoautomation/uidrive/pc/customization.py +10 -0
- mangoautomation/uidrive/pc/element.py +21 -0
- mangoautomation/uidrive/pc/input_device.py +14 -0
- mangoautomation/uidrive/pc/new_windows.py +79 -0
- mangoautomation/uidrive/web/__init__.py +5 -0
- mangoautomation/uidrive/web/async_web/__init__.py +174 -0
- mangoautomation/uidrive/web/async_web/_assertion.py +290 -0
- mangoautomation/uidrive/web/async_web/_browser.py +97 -0
- mangoautomation/uidrive/web/async_web/_customization.py +14 -0
- mangoautomation/uidrive/web/async_web/_element.py +199 -0
- mangoautomation/uidrive/web/async_web/_input_device.py +83 -0
- mangoautomation/uidrive/web/async_web/_new_browser.py +151 -0
- mangoautomation/uidrive/web/async_web/_page.py +62 -0
- mangoautomation/uidrive/web/sync_web/__init__.py +174 -0
- mangoautomation/uidrive/web/sync_web/_assertion.py +282 -0
- mangoautomation/uidrive/web/sync_web/_browser.py +96 -0
- mangoautomation/uidrive/web/sync_web/_customization.py +14 -0
- mangoautomation/uidrive/web/sync_web/_element.py +198 -0
- mangoautomation/uidrive/web/sync_web/_input_device.py +79 -0
- mangoautomation/uidrive/web/sync_web/_new_browser.py +146 -0
- mangoautomation/uidrive/web/sync_web/_page.py +61 -0
- mangoautomation-1.0.0.dist-info/LICENSE +21 -0
- mangoautomation-1.0.0.dist-info/METADATA +30 -0
- mangoautomation-1.0.0.dist-info/RECORD +55 -0
- mangoautomation-1.0.0.dist-info/WHEEL +5 -0
- mangoautomation-1.0.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +5 -0
- tests/test_ui_and.py +29 -0
- tests/test_ui_web.py +77 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Project: 芒果测试平台
|
|
3
|
+
# @Description:
|
|
4
|
+
# @Time : 2024-05-23 15:04
|
|
5
|
+
# @Author : 毛鹏
|
|
6
|
+
# -*- coding: utf-8 -*-
|
|
7
|
+
# @Project: 芒果测试平台
|
|
8
|
+
# @Description:
|
|
9
|
+
# @Time : 2024-04-24 10:43
|
|
10
|
+
# @Author : 毛鹏
|
|
11
|
+
import ctypes
|
|
12
|
+
import os
|
|
13
|
+
import string
|
|
14
|
+
import threading
|
|
15
|
+
import traceback
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
import time
|
|
19
|
+
from playwright._impl._errors import Error
|
|
20
|
+
from playwright.sync_api import sync_playwright, Page, BrowserContext, Browser, Playwright, Request, Route
|
|
21
|
+
|
|
22
|
+
from ....enums import BrowserTypeEnum
|
|
23
|
+
from ....exceptions import MangoAutomationError
|
|
24
|
+
from ....exceptions._error_msg import ERROR_MSG_0057, ERROR_MSG_0008, ERROR_MSG_0062, ERROR_MSG_0009, ERROR_MSG_0055
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SyncWebNewBrowser:
|
|
29
|
+
|
|
30
|
+
def __init__(self,
|
|
31
|
+
web_type: int,
|
|
32
|
+
web_path: str | None = None,
|
|
33
|
+
web_max=False,
|
|
34
|
+
web_headers=False,
|
|
35
|
+
web_recording=False,
|
|
36
|
+
web_h5=None,
|
|
37
|
+
is_header_intercept=False,
|
|
38
|
+
web_is_default=False,
|
|
39
|
+
videos_path=None
|
|
40
|
+
):
|
|
41
|
+
self.lock = threading.Lock()
|
|
42
|
+
self.web_type = web_type
|
|
43
|
+
self.web_path = web_path
|
|
44
|
+
self.web_max = web_max
|
|
45
|
+
self.web_headers = web_headers
|
|
46
|
+
self.web_recording = web_recording
|
|
47
|
+
self.web_h5 = web_h5
|
|
48
|
+
self.web_is_default = web_is_default
|
|
49
|
+
self.videos_path = videos_path
|
|
50
|
+
self.is_header_intercept = is_header_intercept
|
|
51
|
+
self.browser_path = ['chrome.exe', 'msedge.exe', 'firefox.exe', '苹果', '360se.exe']
|
|
52
|
+
self.browser: Optional[None | Browser] = None
|
|
53
|
+
self.playwright: Optional[None | Playwright] = None
|
|
54
|
+
|
|
55
|
+
def new_web_page(self, count=0) -> tuple[BrowserContext, Page]:
|
|
56
|
+
if self.browser is None:
|
|
57
|
+
with self.lock:
|
|
58
|
+
self.browser = self.new_browser()
|
|
59
|
+
time.sleep(1)
|
|
60
|
+
try:
|
|
61
|
+
context = self.new_context()
|
|
62
|
+
page = self.new_page(context)
|
|
63
|
+
return context, page
|
|
64
|
+
except Exception as error:
|
|
65
|
+
self.browser = None
|
|
66
|
+
traceback.format_exc()
|
|
67
|
+
if count >= 3:
|
|
68
|
+
raise MangoAutomationError(*ERROR_MSG_0057)
|
|
69
|
+
else:
|
|
70
|
+
return self.new_web_page(count=count + 1)
|
|
71
|
+
|
|
72
|
+
def new_browser(self) -> Browser:
|
|
73
|
+
self.playwright = sync_playwright().start()
|
|
74
|
+
if self.web_type == BrowserTypeEnum.CHROMIUM.value or self.web_type == BrowserTypeEnum.EDGE.value:
|
|
75
|
+
browser = self.playwright.chromium
|
|
76
|
+
elif self.web_type == BrowserTypeEnum.FIREFOX.value:
|
|
77
|
+
browser = self.playwright.firefox
|
|
78
|
+
elif self.web_type == BrowserTypeEnum.WEBKIT.value:
|
|
79
|
+
browser = self.playwright.webkit
|
|
80
|
+
else:
|
|
81
|
+
raise MangoAutomationError(*ERROR_MSG_0008)
|
|
82
|
+
if self.web_is_default:
|
|
83
|
+
try:
|
|
84
|
+
return browser.launch()
|
|
85
|
+
except Error:
|
|
86
|
+
raise MangoAutomationError(*ERROR_MSG_0062)
|
|
87
|
+
else:
|
|
88
|
+
try:
|
|
89
|
+
if self.web_max:
|
|
90
|
+
return browser.launch(
|
|
91
|
+
headless=self.web_headers,
|
|
92
|
+
executable_path=self.web_path if self.web_path else self.__search_path(),
|
|
93
|
+
args=['--start-maximized']
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
return browser.launch(
|
|
97
|
+
headless=self.web_headers,
|
|
98
|
+
executable_path=self.web_path if self.web_path else self.__search_path()
|
|
99
|
+
)
|
|
100
|
+
except Error:
|
|
101
|
+
raise MangoAutomationError(*ERROR_MSG_0009, value=(self.web_path,))
|
|
102
|
+
|
|
103
|
+
def new_context(self) -> BrowserContext:
|
|
104
|
+
args_dict = {
|
|
105
|
+
'no_viewport': True,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if self.web_recording and self.videos_path:
|
|
109
|
+
args_dict['record_video_dir'] = self.videos_path
|
|
110
|
+
|
|
111
|
+
if self.web_h5:
|
|
112
|
+
del args_dict['no_viewport']
|
|
113
|
+
args_dict.update(self.playwright.devices[self.web_h5])
|
|
114
|
+
return self.browser.new_context(**args_dict)
|
|
115
|
+
|
|
116
|
+
def new_page(self, context: BrowserContext) -> Page:
|
|
117
|
+
try:
|
|
118
|
+
page = context.new_page()
|
|
119
|
+
if self.is_header_intercept:
|
|
120
|
+
page.route("**/*", self.wen_intercept_request) # 应用拦截函数到页面的所有请求
|
|
121
|
+
return page
|
|
122
|
+
except Error:
|
|
123
|
+
raise MangoAutomationError(*ERROR_MSG_0009, value=(self.web_path,))
|
|
124
|
+
|
|
125
|
+
def close(self):
|
|
126
|
+
if self.browser:
|
|
127
|
+
self.browser.close()
|
|
128
|
+
|
|
129
|
+
def __search_path(self, ):
|
|
130
|
+
drives = []
|
|
131
|
+
for letter in string.ascii_uppercase:
|
|
132
|
+
drive = f"{letter}:\\"
|
|
133
|
+
if ctypes.windll.kernel32.GetDriveTypeW(drive) == 3:
|
|
134
|
+
drives.append(drive)
|
|
135
|
+
for i in drives:
|
|
136
|
+
for root, dirs, files in os.walk(i):
|
|
137
|
+
if self.browser_path[self.web_type] in files:
|
|
138
|
+
return os.path.join(root, self.browser_path[self.web_type])
|
|
139
|
+
|
|
140
|
+
raise MangoAutomationError(*ERROR_MSG_0055)
|
|
141
|
+
|
|
142
|
+
def wen_intercept_request(self, route: Route, request: Request):
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
def wen_recording_api(self, request: Request, project_product: int):
|
|
146
|
+
pass
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Project: 芒果测试平台
|
|
3
|
+
# @Description: # @Time : 2023-04-25 22:33
|
|
4
|
+
# @Author : 毛鹏
|
|
5
|
+
import time
|
|
6
|
+
from playwright.sync_api import Locator
|
|
7
|
+
|
|
8
|
+
from ....tools import Meta
|
|
9
|
+
from ....uidrive._base_data import BaseData
|
|
10
|
+
from mangotools.decorator import sync_method_callback
|
|
11
|
+
from mangotools.models import MethodModel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SyncWebPage(metaclass=Meta):
|
|
15
|
+
"""页面操作"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, base_data: BaseData):
|
|
18
|
+
self.base_data = base_data
|
|
19
|
+
|
|
20
|
+
@sync_method_callback('web', '页面操作', 0, [
|
|
21
|
+
MethodModel(f='individual', p='请输入页签下标,从1开始数', d=True)])
|
|
22
|
+
def w_switch_tabs(self, individual: int):
|
|
23
|
+
"""切换页签"""
|
|
24
|
+
pages = self.base_data.context.pages
|
|
25
|
+
pages[int(individual) + 1].bring_to_front()
|
|
26
|
+
self.base_data.page = pages[int(individual) + 1]
|
|
27
|
+
time.sleep(1)
|
|
28
|
+
|
|
29
|
+
@sync_method_callback('web', '页面操作', 1)
|
|
30
|
+
def w_close_current_tab(self):
|
|
31
|
+
"""关闭当前页签"""
|
|
32
|
+
time.sleep(2)
|
|
33
|
+
pages = self.base_data.context.pages
|
|
34
|
+
pages[-1].close()
|
|
35
|
+
self.base_data.page = pages[0]
|
|
36
|
+
|
|
37
|
+
@sync_method_callback('web', '页面操作', 2, [MethodModel(f='locating')])
|
|
38
|
+
def w_open_new_tab_and_switch(self, locating: Locator):
|
|
39
|
+
"""点击并打开新页签"""
|
|
40
|
+
locating.click()
|
|
41
|
+
time.sleep(2)
|
|
42
|
+
pages = self.base_data.context.pages
|
|
43
|
+
new_page = pages[-1]
|
|
44
|
+
new_page.bring_to_front()
|
|
45
|
+
self.base_data.page = new_page
|
|
46
|
+
time.sleep(1)
|
|
47
|
+
|
|
48
|
+
@sync_method_callback('web', '页面操作', 3)
|
|
49
|
+
def w_refresh(self):
|
|
50
|
+
"""刷新页面"""
|
|
51
|
+
self.base_data.page.reload()
|
|
52
|
+
|
|
53
|
+
@sync_method_callback('web', '页面操作', 4)
|
|
54
|
+
def w_go_back(self):
|
|
55
|
+
"""返回上一页"""
|
|
56
|
+
self.base_data.page.go_back()
|
|
57
|
+
|
|
58
|
+
@sync_method_callback('web', '页面操作', 5)
|
|
59
|
+
def w_go_forward(self):
|
|
60
|
+
"""前进到下一页"""
|
|
61
|
+
self.base_data.page.go_forward()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 maopeng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mangoautomation
|
|
3
|
+
Version: 1.0.0
|
|
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
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: setuptools ==68.2.0
|
|
11
|
+
Requires-Dist: pydantic ==2.9.2
|
|
12
|
+
Requires-Dist: playwright ==1.43.0
|
|
13
|
+
Requires-Dist: uiautomation ==2.0.20
|
|
14
|
+
Requires-Dist: uiautomator2 ==3.2.5
|
|
15
|
+
Requires-Dist: mangotools ==1.0.1
|
|
16
|
+
Requires-Dist: adbutils ~=2.8.9
|
|
17
|
+
|
|
18
|
+
# testkit
|
|
19
|
+
|
|
20
|
+
#### 介绍
|
|
21
|
+
|
|
22
|
+
测试工具
|
|
23
|
+
|
|
24
|
+
#### 安装教程
|
|
25
|
+
|
|
26
|
+
1. pip install mangokit
|
|
27
|
+
|
|
28
|
+
#### 使用说明
|
|
29
|
+
|
|
30
|
+
1.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
mangoautomation/__init__.py,sha256=6nV7fyiPU5G-kWbrpCQUlkJdhJyPQh27qQaSvNvQkzQ,125
|
|
2
|
+
mangoautomation/enums/__init__.py,sha256=xPv6158_Tup3U9rbYtUGgWR8W479-7czLvcRk4DUbLs,534
|
|
3
|
+
mangoautomation/enums/_base_enum.py,sha256=dpaXsdhWY08BhIzi1B1ksh_p18ZTmhWvTYhbd3n_ONQ,1176
|
|
4
|
+
mangoautomation/enums/_ui_enum.py,sha256=rdkejsyc4ogZbyNfZcp1q0V0bDPo14vg0A6or6ShaXA,4494
|
|
5
|
+
mangoautomation/exceptions/__init__.py,sha256=dXtRZSuYg3e_lwYUKYvYjtxTKHITdbi2l9XkHk9DpfY,374
|
|
6
|
+
mangoautomation/exceptions/_error_msg.py,sha256=CIwAJAEeXGr93zKWY75NxjqIhcuux0wn0ZTf6jYwfUs,6339
|
|
7
|
+
mangoautomation/exceptions/_exceptions.py,sha256=s3vF0g4nGA1tPiGdI7Mxv9W7uR3uZ9qUSl-KzYppVEU,371
|
|
8
|
+
mangoautomation/models/__init__.py,sha256=XdqEQNfIw7mcnmv3ZgWPJyFwQvap5Cu2ZMKcIK4wn9M,416
|
|
9
|
+
mangoautomation/models/_ui_model.py,sha256=IGophozQMO-NQjM_DPdlwud484yfWQw1CRwbDWjI3Vs,1446
|
|
10
|
+
mangoautomation/tools/__init__.py,sha256=i0rZF_gS0h1Rd0bMhgDSJp4JbEb3rm33zg-MDEX7KdE,342
|
|
11
|
+
mangoautomation/tools/_mate.py,sha256=9lk_EJnAX_OyXbe5WacyHkkcEr2ScBgasl6eUnlklWA,405
|
|
12
|
+
mangoautomation/uidrive/__init__.py,sha256=Tk_gh4Qg2qnewEGxa-7Id4fkQLY3fvQE4X7JB0BEscY,577
|
|
13
|
+
mangoautomation/uidrive/_async_element.py,sha256=xWh3480JHF-JX8Mf6VGOMXsFiSG2hPUBeZ00yQuSFng,14035
|
|
14
|
+
mangoautomation/uidrive/_base_data.py,sha256=OCg5HXk_2sMgf5A6JTJErKLC8nZfhbzwKBRJHCDMueA,3174
|
|
15
|
+
mangoautomation/uidrive/_driver_object.py,sha256=Re8j6VLHKfwW2VFdi-1XFRuix8tRBLcHYRBLVF6CApE,1962
|
|
16
|
+
mangoautomation/uidrive/_sync_element.py,sha256=PiT4dBhFcQeQ6r5283hCkAe5bXrT_UexjIUPKPAI8Fc,13847
|
|
17
|
+
mangoautomation/uidrive/android/__init__.py,sha256=FSIzfPane33QEj6bXslpd8bF1xGCDwMAHBOrpNzdyE4,5874
|
|
18
|
+
mangoautomation/uidrive/android/_application.py,sha256=frvRyqUlx6__3j4xQdaJ4SOnEnipR3uPCOnWKDrkT7Y,2771
|
|
19
|
+
mangoautomation/uidrive/android/_assertion.py,sha256=xkSBdjSfAbYtidHWWWY7Ko2OYaHi9OcZZOlnqIUT-FM,3611
|
|
20
|
+
mangoautomation/uidrive/android/_customization.py,sha256=pCLMmruozOyCJQZWAYupxxKqpWmZyCYsfSBw3XW7vf0,381
|
|
21
|
+
mangoautomation/uidrive/android/_element.py,sha256=pLtiAfskhlMdemy4KogdiDB_AKlB_j1MvD5M5pIE3eU,6987
|
|
22
|
+
mangoautomation/uidrive/android/_equipment.py,sha256=_ccbZ9aUEeoTK0soBs-j7nSYMBcPIo9Bs186xtBEQNQ,5079
|
|
23
|
+
mangoautomation/uidrive/android/_new_android.py,sha256=UHj2DaNBfgvnJxYIzmUNc3gqTIRXxL_5kxEDQVbzWNw,1637
|
|
24
|
+
mangoautomation/uidrive/android/_page.py,sha256=s_N5KW_4P1OJrPyweVb8iXKkrRcgsdgpoTdgm4PaLCo,4395
|
|
25
|
+
mangoautomation/uidrive/pc/__init__.py,sha256=gp3T9C5bSA78dv1AgWXeB9yQQi6q5Tkd0NedCencGWo,2275
|
|
26
|
+
mangoautomation/uidrive/pc/assertion.py,sha256=mH25hZ2i4T8kA1F2loW_nuPJ-Hb0z1pwILTJqkwwpLA,125
|
|
27
|
+
mangoautomation/uidrive/pc/customization.py,sha256=hHf66ImrVxFlGtONrWSHUDrYjmWFc4ANJ883TIrJFG8,239
|
|
28
|
+
mangoautomation/uidrive/pc/element.py,sha256=LdlWHhvXsaHH6jTp6nNrF81OWPtx81dct4yDBHikQBg,519
|
|
29
|
+
mangoautomation/uidrive/pc/input_device.py,sha256=F6ZqKja3XkJww66x3l9Idha3R19D832J-5TfiKWmUso,353
|
|
30
|
+
mangoautomation/uidrive/pc/new_windows.py,sha256=lETHZa7cW8Z0iUShzgVTRxqivkYaOo8WIE58q_8KYfQ,2338
|
|
31
|
+
mangoautomation/uidrive/web/__init__.py,sha256=MgTklzty_SvX4UemCnqJuViq3cIjUgAjFoEtP-mcDWw,123
|
|
32
|
+
mangoautomation/uidrive/web/async_web/__init__.py,sha256=54LvEPe3zmjLsXYhk8VB07mkZ7YDAuItej4ibkaokqI,8839
|
|
33
|
+
mangoautomation/uidrive/web/async_web/_assertion.py,sha256=8cLYPe3pP6FrcjDZoFOphP7psgoJJMozq0Z_BDGNXCo,11859
|
|
34
|
+
mangoautomation/uidrive/web/async_web/_browser.py,sha256=s7piT1w8UHocwF9OnZkff8rFfuNHRMSjCxOSM4BC5DQ,4327
|
|
35
|
+
mangoautomation/uidrive/web/async_web/_customization.py,sha256=uw6p9uLHLXglgSkH4qjDl1v0iGlaNjvf8LljRH5cAHU,347
|
|
36
|
+
mangoautomation/uidrive/web/async_web/_element.py,sha256=EjV4phYHRDCLJiB6XvGvsEctMgr-TWXortBU-L3LL6M,8369
|
|
37
|
+
mangoautomation/uidrive/web/async_web/_input_device.py,sha256=6WjdFX0ff7Pq-dsyGg7VUNDOXFkVknqqQqnvW2RCS54,3479
|
|
38
|
+
mangoautomation/uidrive/web/async_web/_new_browser.py,sha256=cmamXXguIq-Zfhb_je8t3klX5vAaK4IqgENXi9TmmrA,5604
|
|
39
|
+
mangoautomation/uidrive/web/async_web/_page.py,sha256=TCYf79qQdVBBTTNq2COZFJVcLCgg5Ksu9lMgmQPVInU,2147
|
|
40
|
+
mangoautomation/uidrive/web/sync_web/__init__.py,sha256=vHDYYESVi-6ApllUXOrDopcQod3dBXcPlTSAng8eIGE,8662
|
|
41
|
+
mangoautomation/uidrive/web/sync_web/_assertion.py,sha256=zZ4_4WiBQFSRwAh0P0JANa5z-ozbNTh3bnUqcZBti9s,11424
|
|
42
|
+
mangoautomation/uidrive/web/sync_web/_browser.py,sha256=vQJq-TWEUq0rHWLWglE5wptqy8WQKWy4P3NUr2pzsSA,4187
|
|
43
|
+
mangoautomation/uidrive/web/sync_web/_customization.py,sha256=E_pfI8gKd0O6r4huJIvA6hoW-X9fSDVL4zEUqhHgxwE,355
|
|
44
|
+
mangoautomation/uidrive/web/sync_web/_element.py,sha256=UHQJiH0bmqY7oISk30ePyeUnlTmDM6JS0ESEPg7GKJE,8004
|
|
45
|
+
mangoautomation/uidrive/web/sync_web/_input_device.py,sha256=8t6tJgMb4zgb4Sv02XP3gUU0ZVbApCs3WaILv8Fe1iY,3169
|
|
46
|
+
mangoautomation/uidrive/web/sync_web/_new_browser.py,sha256=RO1e4fQoeBol3w8NIx_oxIfRkGvx3ZbPSARTwMwetVQ,5378
|
|
47
|
+
mangoautomation/uidrive/web/sync_web/_page.py,sha256=MNekcL7o5YXEloeuvi3YrpOZxGhEWfrq-5i4PbtTLFg,2027
|
|
48
|
+
tests/__init__.py,sha256=UhCNFqiVjxdh4CXESNo4oE7qfjpYYVkeHbSE5-7LGDY,125
|
|
49
|
+
tests/test_ui_and.py,sha256=4k0_3bx_k2KbZifeRWGK65sxtdiPUOjkNzZ5oxjrc18,672
|
|
50
|
+
tests/test_ui_web.py,sha256=MFaUN8O5qKOMMgyk2eelhKZsYcSJm0Do6pCgsdBZEH4,2765
|
|
51
|
+
mangoautomation-1.0.0.dist-info/LICENSE,sha256=03WP-mgFmo8ofRYDe1HVDQUEUKQZ2q6P6Q-2A4c-46A,1085
|
|
52
|
+
mangoautomation-1.0.0.dist-info/METADATA,sha256=rWHSMMkVZD9Ktq3THbVV-9a231Hk3Jap9YO20qUdlYI,624
|
|
53
|
+
mangoautomation-1.0.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
54
|
+
mangoautomation-1.0.0.dist-info/top_level.txt,sha256=g-uCmjvEODG8WFbmwbGM0-G0zHntHv8ZsS0PQRaMGtE,22
|
|
55
|
+
mangoautomation-1.0.0.dist-info/RECORD,,
|
tests/__init__.py
ADDED
tests/test_ui_and.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Project: 芒果测试平台
|
|
3
|
+
# @Description:
|
|
4
|
+
# @Time : 2025-05-03 10:02
|
|
5
|
+
# @Author : 毛鹏
|
|
6
|
+
import traceback
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# driver_object = DriverObject()
|
|
11
|
+
# driver_object.set_android('ed789e3b')
|
|
12
|
+
# test_data = DataProcessor()
|
|
13
|
+
# base_data = BaseData(test_data)
|
|
14
|
+
# base_data.android = driver_object.android.new_android()
|
|
15
|
+
# android_driver = AndroidDriver(base_data)
|
|
16
|
+
# android_driver.a_close_app('aaasdsadawdwadwa')
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def a_ass(a, b):
|
|
21
|
+
assert a == b, f'断言A=B失败, a的值:{a}, b的值:{b}'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
a_ass(1, 2)
|
|
26
|
+
except AssertionError as error:
|
|
27
|
+
print(error.args[1])
|
|
28
|
+
print(type(error))
|
|
29
|
+
traceback.print_exc()
|
tests/test_ui_web.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Project: 芒果测试平台
|
|
3
|
+
# @Description:
|
|
4
|
+
# @Time : 2025-04-12 17:31
|
|
5
|
+
# @Author : 毛鹏
|
|
6
|
+
import asyncio
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
from mangoautomation.models import ElementModel
|
|
10
|
+
from mangoautomation.uidrive import AsyncElement, BaseData, DriverObject, SyncElement
|
|
11
|
+
from mangotools.data_processor import DataProcessor
|
|
12
|
+
from mangotools.log_collector import set_log
|
|
13
|
+
|
|
14
|
+
log = set_log('D:\GitCode\mango_automation\logs')
|
|
15
|
+
test_data = DataProcessor()
|
|
16
|
+
element_model_1 = ElementModel(**{
|
|
17
|
+
"id": 9,
|
|
18
|
+
"type": 0,
|
|
19
|
+
"name": "搜索结果",
|
|
20
|
+
"loc": "get_by_role(\"link\", name=\"芒果自动化测试平台: 芒果测试平台是UI和API的自动化测试\")",
|
|
21
|
+
"exp": 2,
|
|
22
|
+
"sleep": None,
|
|
23
|
+
"sub": None,
|
|
24
|
+
"is_iframe": 0,
|
|
25
|
+
"ope_key": "w_open_new_tab_and_switch",
|
|
26
|
+
"ope_value": [
|
|
27
|
+
{
|
|
28
|
+
"f": "locating",
|
|
29
|
+
"p": None,
|
|
30
|
+
"d": False,
|
|
31
|
+
"v": ""
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"key_list": None,
|
|
35
|
+
"sql": None,
|
|
36
|
+
"key": None,
|
|
37
|
+
"value": None
|
|
38
|
+
})
|
|
39
|
+
element_model_2 = ElementModel(**{
|
|
40
|
+
"id": 10, "type": 2, "name": "结果内容", "loc": "get_by_role(\"heading\", name=\"芒果测试平台是集UI,API\")",
|
|
41
|
+
"exp": 0,
|
|
42
|
+
"sleep": None, "sub": None, "is_iframe": 0, "ope_key": "w_get_text",
|
|
43
|
+
"ope_value": [{"f": "locating", "p": None, "d": False, "v": ""},
|
|
44
|
+
{"f": "set_cache_key", "p": None, "d": True, "v": "结果内容"}]
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TestUi(unittest.IsolatedAsyncioTestCase):
|
|
49
|
+
async def test_a(self):
|
|
50
|
+
driver_object = DriverObject(True)
|
|
51
|
+
driver_object.set_web(0, r"C:\Program Files\Google\Chrome\Application\chrome.exe")
|
|
52
|
+
base_data = BaseData(test_data, log)
|
|
53
|
+
base_data.log = log
|
|
54
|
+
base_data.url = 'https://www.baidu.com/'
|
|
55
|
+
|
|
56
|
+
base_data.context, base_data.page = await driver_object.web.new_web_page()
|
|
57
|
+
element = AsyncElement(base_data, element_model_1, 0)
|
|
58
|
+
await element.open_url()
|
|
59
|
+
await asyncio.sleep(5)
|
|
60
|
+
await element.element_main()
|
|
61
|
+
print(element.element_result_model.model_dump())
|
|
62
|
+
element = AsyncElement(base_data, element_model_2, 0)
|
|
63
|
+
await element.element_main()
|
|
64
|
+
print(element.element_result_model.model_dump())
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class TestUi2(unittest.TestCase):
|
|
68
|
+
|
|
69
|
+
def test_s(self):
|
|
70
|
+
driver_object = DriverObject()
|
|
71
|
+
driver_object.set_web(0, r"C:\Program Files\Google\Chrome\Application\chrome.exe")
|
|
72
|
+
base_data = BaseData(test_data, log)
|
|
73
|
+
base_data.url = 'https://www.baidu.com/'
|
|
74
|
+
base_data.context, base_data.page = driver_object.web.new_web_page()
|
|
75
|
+
element = SyncElement(base_data, element_model_1, 0)
|
|
76
|
+
element.open_url()
|
|
77
|
+
element.element_main()
|