mangoautomation 1.0.36__tar.gz → 1.0.38__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 (61) hide show
  1. {mangoautomation-1.0.36/mangoautomation.egg-info → mangoautomation-1.0.38}/PKG-INFO +1 -1
  2. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/exceptions/_error_msg.py +68 -68
  3. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/exceptions/_exceptions.py +14 -14
  4. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/_async_element.py +51 -58
  5. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/_base_data.py +13 -0
  6. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/_sync_element.py +49 -57
  7. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/__init__.py +4 -9
  8. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_browser.py +1 -1
  9. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_element.py +1 -0
  10. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_new_browser.py +7 -8
  11. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/__init__.py +4 -10
  12. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_element.py +1 -0
  13. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_new_browser.py +7 -8
  14. {mangoautomation-1.0.36 → mangoautomation-1.0.38/mangoautomation.egg-info}/PKG-INFO +1 -1
  15. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/setup.py +1 -1
  16. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/LICENSE +0 -0
  17. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/MANIFEST.in +0 -0
  18. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/README.md +0 -0
  19. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/__init__.py +0 -0
  20. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/enums/__init__.py +0 -0
  21. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/enums/_base_enum.py +0 -0
  22. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/enums/_ui_enum.py +0 -0
  23. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/exceptions/__init__.py +0 -0
  24. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/models/__init__.py +0 -0
  25. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/models/_ui_model.py +0 -0
  26. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/tools/__init__.py +0 -0
  27. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/tools/_mate.py +0 -0
  28. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/__init__.py +0 -0
  29. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/_driver_object.py +0 -0
  30. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/__init__.py +0 -0
  31. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_application.py +0 -0
  32. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_assertion.py +0 -0
  33. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_customization.py +0 -0
  34. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_element.py +0 -0
  35. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_equipment.py +0 -0
  36. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_new_android.py +0 -0
  37. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/android/_page.py +0 -0
  38. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/__init__.py +0 -0
  39. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/assertion.py +0 -0
  40. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/customization.py +0 -0
  41. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/element.py +0 -0
  42. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/input_device.py +0 -0
  43. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/pc/new_windows.py +0 -0
  44. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/__init__.py +0 -0
  45. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_assertion.py +0 -0
  46. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_customization.py +0 -0
  47. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_input_device.py +0 -0
  48. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/async_web/_page.py +0 -0
  49. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_assertion.py +0 -0
  50. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_browser.py +0 -0
  51. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_customization.py +0 -0
  52. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_input_device.py +0 -0
  53. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation/uidrive/web/sync_web/_page.py +0 -0
  54. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation.egg-info/SOURCES.txt +0 -0
  55. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation.egg-info/dependency_links.txt +0 -0
  56. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation.egg-info/requires.txt +0 -0
  57. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/mangoautomation.egg-info/top_level.txt +0 -0
  58. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/setup.cfg +0 -0
  59. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/tests/__init__.py +0 -0
  60. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/tests/test_ui_and.py +0 -0
  61. {mangoautomation-1.0.36 → mangoautomation-1.0.38}/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.36
3
+ Version: 1.0.38
4
4
  Summary: 测试工具
5
5
  Home-page: https://gitee.com/mao-peng/testkit
6
6
  Author: 毛鹏
@@ -1,68 +1,68 @@
1
- # -*- coding: utf-8 -*-
2
- # @Project: 芒果测试平台
3
- # @Description: 错误消息统一管理
4
- # @Time : 2024-02-01 10:00
5
- # @Author : 毛鹏
6
-
7
- ERROR_MSG_0001 = (4001, '')
8
- ERROR_MSG_0002 = (4002, '')
9
- ERROR_MSG_0003 = (4003, '')
10
- ERROR_MSG_0004 = (4004, '')
11
- ERROR_MSG_0005 = (4018, '断言失败,断言输入值是:空字符串、null或不满足函数接受类型')
12
- ERROR_MSG_0006 = (4006, '')
13
- ERROR_MSG_0007 = (4007, '安卓设备被关闭,请检查设备')
14
- ERROR_MSG_0008 = (4008, '浏览器类型不正确,请联系管理员检查')
15
- ERROR_MSG_0009 = (4009, '浏览器路径不正确,请手动设置一个正确的浏览器路径,现在的路径:{}')
16
- ERROR_MSG_0010 = (4010, '浏览器被关闭,请不要手动关闭浏览器')
17
- ERROR_MSG_0011 = (4011, '操作元素【{}】超时,请检查元素可见但是是否可操作或调整定位方式')
18
- ERROR_MSG_0012 = (4012, '操作失败,请检查输入的值是否有空字符串,null或不满足传参的值')
19
- ERROR_MSG_0013 = (
20
- 313, '打开url时超时,分为2个问题:1.启用的浏览器过多,应当减少浏览器并发个数;2.自行查看为啥60秒还未打开:{}')
21
- ERROR_MSG_0014 = (4014, '')
22
- ERROR_MSG_0015 = (4015, '的类型错误,请联系管理员进行排查问题')
23
- ERROR_MSG_0016 = (4016, '')
24
- ERROR_MSG_0017 = (4017, '断言失败: {}')
25
- ERROR_MSG_0018 = (4018, '')
26
- ERROR_MSG_0019 = (4019, '配置了sql断言,但是并没有配置mysql的数据库配置,请检查!')
27
- ERROR_MSG_0020 = (4020, '没有更多的断言方式,请检查是否选择了非该设备类型的元素定位方式')
28
- ERROR_MSG_0021 = (4021, '元素未找到,请检查断言前操作是否正常完成')
29
- ERROR_MSG_0022 = (4022, '页面无此元素,请检查传入的元素是否正确')
30
- ERROR_MSG_0023 = (4023, 'iframe中未找到此元素,请检查元素表达式是否是正确的')
31
- ERROR_MSG_0024 = (4024, '上传文件的元素必须要是input标签中的')
32
- ERROR_MSG_0025 = (4025, '无法元素对应的下标,请检查通过下标获取元素的数是否正确,当前元素个数:{}')
33
- ERROR_MSG_0026 = (4026, '')
34
- ERROR_MSG_0027 = (4027,
35
- '您元素的操作内容中没有任何的数据,请检查:1.页面步骤详情中字段->元素操作值是否是空,是空可能是你删除了,也可能是执行器的操作选项没有同步需要点击执行器的同步发送缓存数据;2.元素表达式错误导致查询不到元素;')
36
- ERROR_MSG_0028 = (4028, '')
37
- ERROR_MSG_0029 = (4029, '页面无元素【{}】,表达式:{}')
38
- ERROR_MSG_0030 = (4030, '断言时没有找到元素')
39
- ERROR_MSG_0031 = (4031, '元素未找到准备进行断言获取元素文本类容异常')
40
- ERROR_MSG_0032 = (4032, '元素【{}】的元素表达式定位有多个,或其他元素异常,请检查元素是否可用')
41
- ERROR_MSG_0036 = (4036, '公共参数sql在数据库中查询不到结果,sql:{}')
42
- ERROR_MSG_0038 = (4038, '公共参数的sql_key不是列表')
43
- ERROR_MSG_0040 = (
44
- 340, '设备启动超时!请检查设备是否开启了:文件传输模式、开发者模式、usb调试,开启后请重新连接电脑,设备号:{}')
45
- ERROR_MSG_0041 = (4041, '查找页面元素【{}】时直接失败,报错信息:{}')
46
- ERROR_MSG_0042 = (4042, '实例化对象错误,设备信息是空无法实例化,请联系管理员检查')
47
- ERROR_MSG_0043 = (4043, '元素【{}】可能不存在,报错信息:{}')
48
- ERROR_MSG_0044 = (4044, '元素【{}】可能无法消失,报错信息:{}')
49
- ERROR_MSG_0045 = (4045, '设备启动超时!请检查设备是否已成功连接电脑,设备号:{}')
50
- ERROR_MSG_0046 = (4046, '您要测试的设备中,没有您输入的包名,请检查包名是否正确,或者设备是否安装了这个软件包')
51
- ERROR_MSG_0047 = (4047, '')
52
- ERROR_MSG_0048 = (4048, '选项发生错误,请在执行器点击发送缓存数据,然后重新修改步骤的操作!或联系管理员处理!')
53
- ERROR_MSG_0049 = (4049, 'url格式错误,请检查url或者是选择的测试环境不正确')
54
- ERROR_MSG_0050 = (4050, 'xpath定位未找到元素')
55
- ERROR_MSG_0051 = (4051, '')
56
- ERROR_MSG_0052 = (4052, '元素【{}】 进行断言时发生异常,请检查元素是否可以正常使用')
57
- ERROR_MSG_0053 = (4053, '步骤是断言类型,但是你没有输入断言内容,请查看文档中对元素断言的介绍')
58
- ERROR_MSG_0054 = (4054, '步骤是操作类型,但是你没有输入操作内容,请查看文档中对元素操作的介绍')
59
- ERROR_MSG_0055 = (4055, '您的电脑未安装指定浏览器!')
60
- ERROR_MSG_0056 = (4056, '输入的参数类型不正确,请检查操作输入框的类型是否正确')
61
- ERROR_MSG_0057 = (
62
- 357,
63
- '创建浏览器的时候失败,如果你开启了视频录制,则需要执行帮助文档中,windows部署的模块最后的安装playwright依赖。如果不是视频录制原因,则请发给管理员!')
64
- ERROR_MSG_0058 = (4058, '电脑可能无网络,或者设置了代理,浏览器无法进行请求!')
65
- ERROR_MSG_0059 = (4059, '输入内容的类型不正确')
66
- ERROR_MSG_0060 = (4060, '请把元素等信息都发给管理员来解决这个报错,报错:{}')
67
- ERROR_MSG_0061 = (4061, '')
68
- ERROR_MSG_0062 = (4062, '请执行:playwright install 命令,安装符合要求的浏览器再运行命令行模式的执行器')
1
+ # -*- coding: utf-8 -*-
2
+ # @Project: 芒果测试平台
3
+ # @Description: 错误消息统一管理
4
+ # @Time : 2024-02-01 10:00
5
+ # @Author : 毛鹏
6
+
7
+ ERROR_MSG_0001 = (4001, '')
8
+ ERROR_MSG_0002 = (4002, '')
9
+ ERROR_MSG_0003 = (4003, '')
10
+ ERROR_MSG_0004 = (4004, '')
11
+ ERROR_MSG_0005 = (4018, '断言失败,断言输入值是:空字符串、null或不满足函数接受类型')
12
+ ERROR_MSG_0006 = (4006, '')
13
+ ERROR_MSG_0007 = (4007, '安卓设备被关闭,请检查设备')
14
+ ERROR_MSG_0008 = (4008, '浏览器类型不正确,请联系管理员检查')
15
+ ERROR_MSG_0009 = (4009, '浏览器路径不正确,请手动设置一个正确的浏览器路径,现在的路径:{}')
16
+ ERROR_MSG_0010 = (4010, '浏览器被关闭,请不要手动关闭浏览器')
17
+ ERROR_MSG_0011 = (4011, '操作元素【{}】超时,请检查元素可见但是是否可操作或调整定位方式')
18
+ ERROR_MSG_0012 = (4012, '操作失败,请检查输入的值是否有空字符串,null或不满足传参的值')
19
+ ERROR_MSG_0013 = (
20
+ 313, '打开url时超时,分为2个问题:1.启用的浏览器过多,应当减少浏览器并发个数;2.自行查看为啥60秒还未打开:{}')
21
+ ERROR_MSG_0014 = (4014, '')
22
+ ERROR_MSG_0015 = (4015, '的类型错误,请联系管理员进行排查问题')
23
+ ERROR_MSG_0016 = (4016, '')
24
+ ERROR_MSG_0017 = (4017, '断言失败: {}')
25
+ ERROR_MSG_0018 = (4018, '')
26
+ ERROR_MSG_0019 = (4019, '配置了sql断言,但是并没有配置mysql的数据库配置,请检查!')
27
+ ERROR_MSG_0020 = (4020, '没有更多的断言方式,请检查是否选择了非该设备类型的元素定位方式')
28
+ ERROR_MSG_0021 = (4021, '元素未找到,请检查断言前操作是否正常完成')
29
+ ERROR_MSG_0022 = (4022, '页面无此元素,请检查传入的元素是否正确')
30
+ ERROR_MSG_0023 = (4023, 'iframe中未找到此元素,请检查元素表达式是否是正确的')
31
+ ERROR_MSG_0024 = (4024, '上传文件的元素必须要是input标签中的')
32
+ ERROR_MSG_0025 = (4025, '无法元素对应的下标,请检查通过下标获取元素的数是否正确,当前元素个数:{}')
33
+ ERROR_MSG_0026 = (4026, '')
34
+ ERROR_MSG_0027 = (4027,
35
+ '您元素的操作内容中没有任何的数据,请检查:1.页面步骤详情中字段->元素操作值是否是空,是空可能是你删除了,也可能是执行器的操作选项没有同步需要点击执行器的同步发送缓存数据;2.元素表达式错误导致查询不到元素;')
36
+ ERROR_MSG_0028 = (4028, '')
37
+ ERROR_MSG_0029 = (4029, '页面无元素【{}】,表达式:{}')
38
+ ERROR_MSG_0030 = (4030, '断言时没有找到元素')
39
+ ERROR_MSG_0031 = (4031, '元素未找到准备进行断言获取元素文本类容异常')
40
+ ERROR_MSG_0032 = (4032, '元素【{}】的元素表达式定位有多个,或其他元素异常,请检查元素是否可用')
41
+ ERROR_MSG_0036 = (4036, '公共参数sql在数据库中查询不到结果,sql:{}')
42
+ ERROR_MSG_0038 = (4038, '公共参数的sql_key不是列表')
43
+ ERROR_MSG_0040 = (
44
+ 340, '设备启动超时!请检查设备是否开启了:文件传输模式、开发者模式、usb调试,开启后请重新连接电脑,设备号:{}')
45
+ ERROR_MSG_0041 = (4041, '查找页面元素【{}】时直接失败,报错信息:{}')
46
+ ERROR_MSG_0042 = (4042, '实例化对象错误,设备信息是空无法实例化,请联系管理员检查')
47
+ ERROR_MSG_0043 = (4043, '元素【{}】可能不存在,报错信息:{}')
48
+ ERROR_MSG_0044 = (4044, '元素【{}】可能无法消失,报错信息:{}')
49
+ ERROR_MSG_0045 = (4045, '设备启动超时!请检查设备是否已成功连接电脑,设备号:{}')
50
+ ERROR_MSG_0046 = (4046, '您要测试的设备中,没有您输入的包名,请检查包名是否正确,或者设备是否安装了这个软件包')
51
+ ERROR_MSG_0047 = (4047, '')
52
+ ERROR_MSG_0048 = (4048, '选项发生错误,请在执行器点击发送缓存数据,然后重新修改步骤的操作!或联系管理员处理!')
53
+ ERROR_MSG_0049 = (4049, 'url格式错误,请检查url或者是选择的测试环境不正确')
54
+ ERROR_MSG_0050 = (4050, 'xpath定位未找到元素')
55
+ ERROR_MSG_0051 = (4051, '')
56
+ ERROR_MSG_0052 = (4052, '元素【{}】 进行断言时发生异常,请检查元素是否可以正常使用')
57
+ ERROR_MSG_0053 = (4053, '步骤是断言类型,但是你没有输入断言内容,请查看文档中对元素断言的介绍')
58
+ ERROR_MSG_0054 = (4054, '步骤是操作类型,但是你没有输入操作内容,请查看文档中对元素操作的介绍')
59
+ ERROR_MSG_0055 = (4055, '您的电脑未安装指定浏览器!')
60
+ ERROR_MSG_0056 = (4056, '输入的参数类型不正确,请检查操作输入框的类型是否正确')
61
+ ERROR_MSG_0057 = (
62
+ 357,
63
+ '创建浏览器的时候失败,如果你开启了视频录制,则需要执行帮助文档中,windows部署的模块最后的安装playwright依赖。如果不是视频录制原因,则请发给管理员!')
64
+ ERROR_MSG_0058 = (4058, '电脑可能无网络,或者设置了代理,浏览器无法进行请求!')
65
+ ERROR_MSG_0059 = (4059, '输入内容的类型不正确')
66
+ ERROR_MSG_0060 = (4060, '请把元素等信息都发给管理员来解决这个报错,报错:{}')
67
+ ERROR_MSG_0061 = (4061, '')
68
+ ERROR_MSG_0062 = (4062, '请执行:playwright install 命令,安装符合要求的浏览器再运行命令行模式的执行器')
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
- # @Project: 芒果测试平台
3
- # @Description:
4
- # @Time: 2023-07-16 15:17
5
- # @Author : 毛鹏
6
-
7
- class MangoAutomationError(Exception):
8
-
9
- def __init__(self, code: int, msg: str, value: tuple = None):
10
- self.msg = msg.format(*value) if value else msg
11
- self.code = code
12
-
13
- def __str__(self):
14
- return f"[{self.code}] {self.msg}"
1
+ # -*- coding: utf-8 -*-
2
+ # @Project: 芒果测试平台
3
+ # @Description:
4
+ # @Time: 2023-07-16 15:17
5
+ # @Author : 毛鹏
6
+
7
+ class MangoAutomationError(Exception):
8
+
9
+ def __init__(self, code: int, msg: str, value: tuple = None):
10
+ self.msg = msg.format(*value) if value else msg
11
+ self.code = code
12
+
13
+ def __str__(self):
14
+ return f"[{self.code}] {self.msg}"
@@ -6,6 +6,7 @@
6
6
  import asyncio
7
7
  import os
8
8
  import traceback
9
+ from typing import Optional
9
10
 
10
11
  from playwright._impl._errors import TargetClosedError, Error
11
12
 
@@ -22,12 +23,28 @@ from ..uidrive.web.async_web import AsyncWebDevice, AsyncWebAssertion
22
23
 
23
24
  class AsyncElement(AsyncWebDevice, AndroidDriver):
24
25
 
25
- def __init__(self, base_data, element_model: ElementModel, drive_type: int, element_data: dict | None = None):
26
+ def __init__(self, base_data, drive_type: int, ):
26
27
  super().__init__(base_data)
27
- self.element_data = element_data
28
- self.element_model = element_model
29
28
  self.drive_type = drive_type
30
- self.ope_name = element_model.name if element_model.name else element_model.ope_key
29
+ self.element_model: Optional[ElementModel | None] = None
30
+ self.element_data: dict | None = None
31
+ self.element_result_model: Optional[ElementResultModel | None] = None
32
+
33
+ async def open_device(self, is_open: bool = False):
34
+ if self.drive_type == DriveTypeEnum.WEB.value:
35
+ await self.open_url(is_open)
36
+ elif self.drive_type == DriveTypeEnum.ANDROID.value:
37
+ self.open_app()
38
+ elif self.drive_type == DriveTypeEnum.DESKTOP.value:
39
+ pass
40
+ else:
41
+ self.base_data.log.debug(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
42
+ raise Exception('不存在的设备类型')
43
+
44
+
45
+ async def element_main(self, element_model: ElementModel, element_data: dict | None = None) -> ElementResultModel:
46
+ self.element_model = element_model
47
+ self.element_data = element_data
31
48
  self.element_result_model = ElementResultModel(
32
49
  id=self.element_model.id,
33
50
  name=self.element_model.name,
@@ -45,19 +62,6 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
45
62
 
46
63
  status=StatusEnum.FAIL.value,
47
64
  )
48
-
49
- async def open_device(self, is_open: bool = False):
50
- if self.drive_type == DriveTypeEnum.WEB.value:
51
- await self.open_url(is_open)
52
- elif self.drive_type == DriveTypeEnum.ANDROID.value:
53
- self.open_app()
54
- elif self.drive_type == DriveTypeEnum.DESKTOP.value:
55
- pass
56
- else:
57
- self.base_data.log.debug(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
58
- raise Exception('不存在的设备类型')
59
-
60
- async def element_main(self) -> ElementResultModel:
61
65
  try:
62
66
  await self.__main()
63
67
  if self.element_model.sleep:
@@ -65,19 +69,24 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
65
69
  self.element_result_model.status = StatusEnum.SUCCESS.value
66
70
  self.element_result_model.error_message = None
67
71
  except MangoAutomationError as error:
72
+ self.base_data.log.debug(f'操作元素异常-1,类型:{type(error)},失败详情:{error}')
68
73
  await self.__error(error.msg)
69
- self.base_data.log.debug(f'已知异常,类型:{type(error)},失败详情:{error}')
74
+ except TargetClosedError as error:
75
+ self.base_data.setup()
76
+ self.base_data.log.debug(
77
+ f'操作元素异常-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
78
+ await self.__error(ERROR_MSG_0010[1], False)
70
79
  except Error as error:
71
- await self.__error(f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.message}')
72
80
  self.base_data.log.error(
73
- f'未知错误捕获-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
81
+ f'操作元素异常-3,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
82
+ await self.__error(f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.message}')
74
83
  except Exception as error:
75
84
  error_msg = f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.args}'
76
85
  if hasattr(error, 'msg'):
77
86
  error_msg = error.msg
78
- await self.__error(error_msg)
79
87
  self.base_data.log.error(
80
- f'未知错误捕获-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
88
+ f'操作元素异常-4,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
89
+ await self.__error(error_msg)
81
90
  return self.element_result_model
82
91
 
83
92
  @async_retry()
@@ -87,32 +96,19 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
87
96
  self.element_model.sleep = self.base_data.test_data.replace(self.element_model.sleep)
88
97
  self.element_model.sub = self.base_data.test_data.replace(self.element_model.sub)
89
98
  except MangoAutomationError as error:
90
- self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
99
+ self.base_data.log.error(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
91
100
  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)
101
+ self.base_data.verify_equipment(self.drive_type)
102
+ if self.element_model.type == ElementOperationEnum.OPE.value:
103
+ await self.__ope()
104
+ elif self.element_model.type == ElementOperationEnum.ASS.value:
105
+ await self.__ass()
106
+ elif self.element_model.type == ElementOperationEnum.SQL.value:
107
+ await self.__sql()
108
+ elif self.element_model.type == ElementOperationEnum.CUSTOM.value:
109
+ await self.__custom()
98
110
  else:
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
+ raise MangoAutomationError(*ERROR_MSG_0015)
116
112
 
117
113
  async def __ope(self):
118
114
  method_name = getattr(self.element_model, 'ope_key', None)
@@ -142,9 +138,7 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
142
138
  )
143
139
  else:
144
140
  pass
145
- for i in self.element_model.ope_value:
146
- if i.d:
147
- self.element_result_model.ope_value[i.f] = i.v
141
+ self.element_result_model.ope_value = {i.f: i.v for i in self.element_model.ope_value if i.d}
148
142
 
149
143
  async def __ass(self):
150
144
  if self.element_model.ope_value is None:
@@ -164,9 +158,7 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
164
158
  )
165
159
  else:
166
160
  pass
167
- for i in self.element_model.ope_value:
168
- if i.d:
169
- self.element_result_model.ope_value[i.f] = i.v
161
+ self.element_result_model.ope_value = {i.f: i.v for i in self.element_model.ope_value if i.d}
170
162
 
171
163
  async def __sql(self):
172
164
  if not self.element_data:
@@ -241,7 +233,7 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
241
233
  f'获取操作值失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
242
234
  raise MangoAutomationError(*ERROR_MSG_0027)
243
235
 
244
- async def __error(self, msg: str):
236
+ async def __error(self, msg: str, is_screenshot: bool = True):
245
237
  try:
246
238
  self.element_result_model.status = StatusEnum.FAIL.value
247
239
  self.element_result_model.error_message = msg
@@ -253,11 +245,12 @@ class AsyncElement(AsyncWebDevice, AndroidDriver):
253
245
  self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
254
246
  """
255
247
  )
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)
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
248
+ if is_screenshot:
249
+ file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
250
+ file_path = os.path.join(self.base_data.screenshot_path, file_name)
251
+ await self.__error_screenshot(file_path)
252
+ self.element_result_model.picture_path = file_path
253
+ self.element_result_model.picture_name = file_name
261
254
  except MangoAutomationError as error:
262
255
  self.element_result_model.error_message += f'执行过程中发生失败,准备截图时截图失败,失败原因:{error.msg}'
263
256
  except Exception as error:
@@ -9,6 +9,9 @@ from unittest.mock import MagicMock
9
9
  import sys
10
10
  from uiautomator2 import Device
11
11
 
12
+ from mangoautomation.enums import DriveTypeEnum
13
+ from mangoautomation.exceptions import MangoAutomationError
14
+ from mangoautomation.exceptions._error_msg import ERROR_MSG_0010, ERROR_MSG_0007
12
15
  from mangotools.data_processor import DataProcessor
13
16
  from mangotools.database import MysqlConnect
14
17
  from mangotools.enums import StatusEnum
@@ -101,3 +104,13 @@ class BaseData:
101
104
  bool(db_c_status),
102
105
  bool(db_rud_status))
103
106
  return self
107
+
108
+ def verify_equipment(self, drive_type: int):
109
+ if drive_type == DriveTypeEnum.WEB.value:
110
+ if not self.page or not self.context:
111
+ raise MangoAutomationError(*ERROR_MSG_0010)
112
+ elif drive_type == DriveTypeEnum.ANDROID.value:
113
+ if not self.android:
114
+ raise MangoAutomationError(*ERROR_MSG_0007)
115
+ else:
116
+ pass
@@ -5,6 +5,7 @@
5
5
  # @Author : 毛鹏
6
6
  import os
7
7
  import traceback
8
+ from typing import Optional
8
9
 
9
10
  import time
10
11
  from playwright._impl._errors import TargetClosedError, Error
@@ -22,12 +23,27 @@ from ..uidrive.web.sync_web import SyncWebDevice, SyncWebAssertion
22
23
 
23
24
  class SyncElement(SyncWebDevice, AndroidDriver):
24
25
 
25
- def __init__(self, base_data, element_model: ElementModel, drive_type: int, element_data: dict | None = None):
26
+ def __init__(self, base_data, drive_type: int, ):
26
27
  super().__init__(base_data)
27
- self.element_data = element_data
28
- self.element_model = element_model
29
28
  self.drive_type = drive_type
30
- self.ope_name = element_model.name if element_model.name else element_model.ope_key
29
+ self.element_model: Optional[ElementModel | None] = None
30
+ self.element_data: dict | None = None
31
+ self.element_result_model: Optional[ElementResultModel | None] = None
32
+
33
+ def open_device(self, is_open: bool = False):
34
+ if self.drive_type == DriveTypeEnum.WEB.value:
35
+ self.open_url(is_open)
36
+ elif self.drive_type == DriveTypeEnum.ANDROID.value:
37
+ self.open_app()
38
+ elif self.drive_type == DriveTypeEnum.DESKTOP.value:
39
+ pass
40
+ else:
41
+ self.base_data.log.error(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
42
+ raise Exception('不存在的设备类型')
43
+
44
+ def element_main(self, element_model: ElementModel, element_data: dict | None = None) -> ElementResultModel:
45
+ self.element_model = element_model
46
+ self.element_data = element_data
31
47
  self.element_result_model = ElementResultModel(
32
48
  id=self.element_model.id,
33
49
  name=self.element_model.name,
@@ -45,19 +61,6 @@ class SyncElement(SyncWebDevice, AndroidDriver):
45
61
 
46
62
  status=StatusEnum.FAIL.value,
47
63
  )
48
-
49
- def open_device(self, is_open: bool = False):
50
- if self.drive_type == DriveTypeEnum.WEB.value:
51
- self.open_url(is_open)
52
- elif self.drive_type == DriveTypeEnum.ANDROID.value:
53
- self.open_app()
54
- elif self.drive_type == DriveTypeEnum.DESKTOP.value:
55
- pass
56
- else:
57
- self.base_data.log.error(f'不存在这个类型,如果是非管理员看到这种提示,请联系管理员')
58
- raise Exception('不存在的设备类型')
59
-
60
- def element_main(self) -> ElementResultModel:
61
64
  try:
62
65
  self.__main()
63
66
  if self.element_model.sleep:
@@ -65,19 +68,24 @@ class SyncElement(SyncWebDevice, AndroidDriver):
65
68
  self.element_result_model.status = StatusEnum.SUCCESS.value
66
69
  self.element_result_model.error_message = None
67
70
  except MangoAutomationError as error:
71
+ self.base_data.log.debug(f'操作元素异常-1,类型:{type(error)},失败详情:{error}')
68
72
  self.__error(error.msg)
69
- self.base_data.log.debug(f'已知异常,类型:{type(error)},失败详情:{error}')
73
+ except TargetClosedError as error:
74
+ self.base_data.setup()
75
+ self.base_data.log.debug(
76
+ f'操作元素异常-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
77
+ self.__error(ERROR_MSG_0010[1], False)
70
78
  except Error as error:
71
- self.__error(f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.message}')
72
79
  self.base_data.log.error(
73
- f'未知错误捕获-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
80
+ f'操作元素异常-3,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
81
+ self.__error(f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.message}')
74
82
  except Exception as error:
75
83
  error_msg = f'未知错误失败,请检查测试数据,如果需要明确的提示请联系管理员,提示:{error.args}'
76
84
  if hasattr(error, 'msg'):
77
85
  error_msg = error.msg
78
- self.__error(error_msg)
79
86
  self.base_data.log.error(
80
- f'未知错误捕获-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
87
+ f'操作元素异常-4,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
88
+ self.__error(error_msg)
81
89
  return self.element_result_model
82
90
 
83
91
  @sync_retry()
@@ -89,30 +97,17 @@ class SyncElement(SyncWebDevice, AndroidDriver):
89
97
  except MangoAutomationError as error:
90
98
  self.base_data.log.debug(f'操作元素解析数据失败,类型:{type(error)}, 详情:{error}')
91
99
  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)
100
+ self.base_data.verify_equipment(self.drive_type)
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()
98
109
  else:
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)
110
+ raise MangoAutomationError(*ERROR_MSG_0015)
116
111
 
117
112
  def __ope(self):
118
113
  method_name = getattr(self.element_model, 'ope_key', None)
@@ -142,9 +137,7 @@ class SyncElement(SyncWebDevice, AndroidDriver):
142
137
  )
143
138
  else:
144
139
  pass
145
- for i in self.element_model.ope_value:
146
- if i.d:
147
- self.element_result_model.ope_value[i.f] = i.v
140
+ self.element_result_model.ope_value = {i.f: i.v for i in self.element_model.ope_value if i.d}
148
141
 
149
142
  def __ass(self):
150
143
  if self.element_model.ope_value is None:
@@ -164,9 +157,7 @@ class SyncElement(SyncWebDevice, AndroidDriver):
164
157
  )
165
158
  else:
166
159
  pass
167
- for i in self.element_model.ope_value:
168
- if i.d:
169
- self.element_result_model.ope_value[i.f] = i.v
160
+ self.element_result_model.ope_value = {i.f: i.v for i in self.element_model.ope_value if i.d}
170
161
 
171
162
  def __sql(self):
172
163
  if not self.element_data:
@@ -241,7 +232,7 @@ class SyncElement(SyncWebDevice, AndroidDriver):
241
232
  f'获取操作值失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
242
233
  raise MangoAutomationError(*ERROR_MSG_0027)
243
234
 
244
- def __error(self, msg: str):
235
+ def __error(self, msg: str, is_screenshot: bool = True):
245
236
  try:
246
237
  self.element_result_model.status = StatusEnum.FAIL.value
247
238
  self.element_result_model.error_message = msg
@@ -253,11 +244,12 @@ class SyncElement(SyncWebDevice, AndroidDriver):
253
244
  self.element_result_model.model_dump() if self.element_result_model else self.element_result_model}
254
245
  """
255
246
  )
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)
258
- self.__error_screenshot(file_path)
259
- self.element_result_model.picture_path = file_path
260
- self.element_result_model.picture_name = file_name
247
+ if is_screenshot:
248
+ file_name = f'失败截图-{self.element_model.name}{self.base_data.test_data.get_time_for_min()}.jpg'
249
+ file_path = os.path.join(self.base_data.screenshot_path, file_name)
250
+ self.__error_screenshot(file_path)
251
+ self.element_result_model.picture_path = file_path
252
+ self.element_result_model.picture_name = file_name
261
253
  except MangoAutomationError as error:
262
254
  self.element_result_model.error_message += f'执行过程中发生失败,准备截图时截图失败,失败原因:{error.msg}'
263
255
  except Exception as error:
@@ -6,7 +6,7 @@
6
6
  import re
7
7
  import traceback
8
8
 
9
- from playwright._impl._errors import TimeoutError, Error, TargetClosedError
9
+ from playwright._impl._errors import TimeoutError, Error
10
10
  from playwright.async_api._generated import Locator
11
11
 
12
12
  from mangotools.assertion import PublicAssertion, SqlAssertion
@@ -57,9 +57,6 @@ class AsyncWebDevice(AsyncWebBrowser,
57
57
  except TimeoutError as error:
58
58
  self.base_data.log.error(f'WEB自动化操作失败-1,类型:{type(error)},失败详情:{error}')
59
59
  raise MangoAutomationError(*ERROR_MSG_0011, value=(name,))
60
- except TargetClosedError:
61
- self.base_data.setup()
62
- raise MangoAutomationError(*ERROR_MSG_0010)
63
60
  except Error as error:
64
61
  self.base_data.log.error(f'WEB自动化操作失败-2,类型:{type(error)},失败详情:{error}')
65
62
  raise MangoAutomationError(*ERROR_MSG_0032, value=(name,))
@@ -97,9 +94,7 @@ class AsyncWebDevice(AsyncWebBrowser,
97
94
  except ValueError as error:
98
95
  self.base_data.log.error(f'WEB自动化断言失败-3,类型:{type(error)},失败详情:{error}')
99
96
  raise MangoAutomationError(*ERROR_MSG_0005)
100
- except TargetClosedError:
101
- self.base_data.setup()
102
- raise MangoAutomationError(*ERROR_MSG_0010)
97
+
103
98
  except Error as error:
104
99
  self.base_data.log.error(f'WEB自动化断言失败-4,类型:{type(error)},失败详情:{error}')
105
100
  raise MangoAutomationError(*ERROR_MSG_0052, value=(name,), )
@@ -119,7 +114,7 @@ class AsyncWebDevice(AsyncWebBrowser,
119
114
  text = None
120
115
  return loc, count, text
121
116
  except Error as error:
122
- self.base_data.log.error(
117
+ self.base_data.log.debug(
123
118
  f'WEB自动化查找元素失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
124
119
  raise MangoAutomationError(*ERROR_MSG_0041, value=(name, loc))
125
120
  else:
@@ -129,7 +124,7 @@ class AsyncWebDevice(AsyncWebBrowser,
129
124
  try:
130
125
  count = await locator.count()
131
126
  except Error as error:
132
- self.base_data.log.error(
127
+ self.base_data.log.debug(
133
128
  f'WEB自动化查找元素失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
134
129
  raise MangoAutomationError(*ERROR_MSG_0041, )
135
130
  if count > 0:
@@ -49,7 +49,7 @@ class AsyncWebBrowser(metaclass=Meta):
49
49
  raise MangoAutomationError(*ERROR_MSG_0010, value=(url,))
50
50
  except Error as error:
51
51
  self.base_data.log.debug(
52
- f'打开URL失败-3,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
52
+ f'打开URL失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
53
53
  raise MangoAutomationError(*ERROR_MSG_0058, value=(url,))
54
54
 
55
55
  @async_method_callback('web', '浏览器操作', 2, [
@@ -71,6 +71,7 @@ class AsyncWebElement(metaclass=Meta):
71
71
  @async_method_callback('web', '元素操作', 6, [MethodModel(f='locating')])
72
72
  async def w_many_click(self, locating: Locator):
73
73
  """多元素循环单击"""
74
+ await asyncio.sleep(1)
74
75
  elements = await locating.all()
75
76
  for element in elements:
76
77
  await element.click()
@@ -101,16 +101,15 @@ class AsyncWebNewBrowser:
101
101
  raise MangoAutomationError(*ERROR_MSG_0009, value=(self.web_path,))
102
102
 
103
103
  async 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
-
104
+ args_dict = {}
105
+ if self.web_is_default:
106
+ args_dict["viewport"] = {"width": 1600, "height": 1080}
111
107
  if self.web_h5:
112
- del args_dict['no_viewport']
113
108
  args_dict.update(self.playwright.devices[self.web_h5])
109
+ if not (self.web_is_default or self.web_h5):
110
+ args_dict["no_viewport"] = True
111
+ if self.web_recording and self.videos_path:
112
+ args_dict["record_video_dir"] = self.videos_path
114
113
  return await self.browser.new_context(**args_dict)
115
114
 
116
115
  async def new_page(self, context: BrowserContext) -> Page:
@@ -6,12 +6,12 @@
6
6
  import re
7
7
  import traceback
8
8
 
9
- from playwright._impl._errors import TimeoutError, Error, TargetClosedError
9
+ from playwright._impl._errors import TimeoutError, Error
10
10
  from playwright.sync_api._generated import Locator
11
11
 
12
12
  from mangotools.assertion import PublicAssertion, SqlAssertion
13
- from mangotools.mangos import Mango
14
13
  from mangotools.enums import StatusEnum
14
+ from mangotools.mangos import Mango
15
15
  from ....enums import ElementExpEnum
16
16
  from ....exceptions import MangoAutomationError
17
17
  from ....exceptions._error_msg import *
@@ -57,9 +57,6 @@ class SyncWebDevice(SyncWebBrowser,
57
57
  except TimeoutError as error:
58
58
  self.base_data.log.error(f'WEB自动化操作失败-1,类型:{type(error)},失败详情:{error}')
59
59
  raise MangoAutomationError(*ERROR_MSG_0011, value=(name,))
60
- except TargetClosedError:
61
- self.base_data.setup()
62
- raise MangoAutomationError(*ERROR_MSG_0010)
63
60
  except Error as error:
64
61
  self.base_data.log.error(f'WEB自动化操作失败-2,类型:{type(error)},失败详情:{error}')
65
62
  raise MangoAutomationError(*ERROR_MSG_0032, value=(name,))
@@ -96,9 +93,6 @@ class SyncWebDevice(SyncWebBrowser,
96
93
  except ValueError as error:
97
94
  self.base_data.log.error(f'WEB自动化断言失败-3,类型:{type(error)},失败详情:{error}')
98
95
  raise MangoAutomationError(*ERROR_MSG_0005)
99
- except TargetClosedError:
100
- self.base_data.setup()
101
- raise MangoAutomationError(*ERROR_MSG_0010)
102
96
  except Error as error:
103
97
  self.base_data.log.error(f'WEB自动化断言失败-4,类型:{type(error)},失败详情:{error}')
104
98
  raise MangoAutomationError(*ERROR_MSG_0052, value=(name,), )
@@ -118,7 +112,7 @@ class SyncWebDevice(SyncWebBrowser,
118
112
  text = None
119
113
  return loc, count, text
120
114
  except Error as error:
121
- self.base_data.log.error(
115
+ self.base_data.log.debug(
122
116
  f'WEB自动化查找元素失败-1,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
123
117
  raise MangoAutomationError(*ERROR_MSG_0041, )
124
118
  else:
@@ -128,7 +122,7 @@ class SyncWebDevice(SyncWebBrowser,
128
122
  try:
129
123
  count = locator.count()
130
124
  except Error as error:
131
- self.base_data.log.error(
125
+ self.base_data.log.debug(
132
126
  f'WEB自动化查找元素失败-2,类型:{type(error)},失败详情:{error},失败明细:{traceback.format_exc()}')
133
127
  raise MangoAutomationError(*ERROR_MSG_0041, )
134
128
  if count > 0:
@@ -70,6 +70,7 @@ class SyncWebElement(metaclass=Meta):
70
70
  @sync_method_callback('web', '元素操作', 6, [MethodModel(f='locating')])
71
71
  def w_many_click(self, locating: Locator):
72
72
  """多元素循环单击"""
73
+ time.sleep(1)
73
74
  elements = locating.all()
74
75
  for element in elements:
75
76
  element.click()
@@ -101,16 +101,15 @@ class SyncWebNewBrowser:
101
101
  raise MangoAutomationError(*ERROR_MSG_0009, value=(self.web_path,))
102
102
 
103
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
-
104
+ args_dict = {}
105
+ if self.web_is_default:
106
+ args_dict["viewport"] = {"width": 1600, "height": 1080}
111
107
  if self.web_h5:
112
- del args_dict['no_viewport']
113
108
  args_dict.update(self.playwright.devices[self.web_h5])
109
+ if not (self.web_is_default or self.web_h5):
110
+ args_dict["no_viewport"] = True
111
+ if self.web_recording and self.videos_path:
112
+ args_dict["record_video_dir"] = self.videos_path
114
113
  return self.browser.new_context(**args_dict)
115
114
 
116
115
  def new_page(self, context: BrowserContext) -> Page:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mangoautomation
3
- Version: 1.0.36
3
+ Version: 1.0.38
4
4
  Summary: 测试工具
5
5
  Home-page: https://gitee.com/mao-peng/testkit
6
6
  Author: 毛鹏
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- __version__ = '1.0.36'
3
+ __version__ = '1.0.38'
4
4
 
5
5
  with open("README.md", "r", encoding='utf-8') as fh:
6
6
  long_description = fh.read()