mangoautomation 1.0.51__py3-none-any.whl → 1.0.52__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.

@@ -6,10 +6,10 @@ import asyncio
6
6
  import os
7
7
 
8
8
  import time
9
- from mangotools.decorator import async_method_callback
10
- from mangotools.models import MethodModel
11
9
  from playwright.async_api import Locator, Error
12
10
 
11
+ from mangotools.decorator import async_method_callback
12
+ from mangotools.models import MethodModel
13
13
  from ..._base_data import BaseData
14
14
  from ....exceptions import MangoAutomationError
15
15
  from ....exceptions._error_msg import ERROR_MSG_0024, ERROR_MSG_0056
@@ -55,10 +55,27 @@ class AsyncWebElement(metaclass=Meta):
55
55
  MethodModel(f='set_cache_key', p='请输入获取元素文本后存储的key', d=True)])
56
56
  async def w_get_text(self, locating: Locator, set_cache_key=None):
57
57
  """获取元素文本"""
58
- value = await locating.inner_text()
59
- if set_cache_key:
60
- self.base_data.test_data.set_cache(key=set_cache_key, value=value)
61
- return value
58
+ methods = [
59
+ ("inner_text", locating.inner_text),
60
+ ("text_content", locating.text_content),
61
+ ("input_value", locating.input_value),
62
+ ("get_attribute", lambda: locating.get_attribute("value")),
63
+ ("evaluate", lambda: locating.evaluate("el => el.value")),
64
+ ]
65
+
66
+ for method_name, method in methods:
67
+ try:
68
+ value = await method()
69
+ if value is not None and str(value).strip() and set_cache_key:
70
+ self.base_data.test_data.set_cache(key=set_cache_key, value=value)
71
+ return value
72
+ elif value is not None and str(value).strip():
73
+ return value
74
+ except Exception as e:
75
+ print(f"方法 [{method_name}] 失败: {str(e)}")
76
+ continue
77
+
78
+ return None
62
79
 
63
80
  @async_method_callback('web', '元素操作', 5, [
64
81
  MethodModel(f='locating'),
@@ -54,10 +54,24 @@ class SyncWebElement(metaclass=Meta):
54
54
  MethodModel(f='set_cache_key', p='请输入获取元素文本后存储的key', d=True)])
55
55
  def w_get_text(self, locating: Locator, set_cache_key=None):
56
56
  """获取元素文本"""
57
- value = locating.inner_text()
58
- if set_cache_key:
59
- self.base_data.test_data.set_cache(key=set_cache_key, value=value)
60
- return value
57
+ methods = [
58
+ ("inner_text", lambda: locating.inner_text()),
59
+ ("text_content", lambda: locating.text_content()),
60
+ ("input_value", lambda: locating.input_value() if locating.is_visible() else None),
61
+ ("get_attribute", lambda: locating.get_attribute("value")),
62
+ ("evaluate", lambda: locating.evaluate("el => el.value")),
63
+ ]
64
+ for method_name, method in methods:
65
+ try:
66
+ value = method()
67
+ if value is not None and str(value).strip() and set_cache_key:
68
+ self.base_data.test_data.set_cache(key=set_cache_key, value=value)
69
+ return value
70
+ elif value is not None and str(value).strip():
71
+ return value
72
+ except Exception:
73
+ continue
74
+ return None
61
75
 
62
76
  @sync_method_callback('web', '元素操作', 5, [
63
77
  MethodModel(f='locating'),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mangoautomation
3
- Version: 1.0.51
3
+ Version: 1.0.52
4
4
  Summary: 测试工具
5
5
  Home-page: https://gitee.com/mao-peng/testkit
6
6
  Author: 毛鹏
@@ -35,7 +35,7 @@ mangoautomation/uidrive/web/async_web/__init__.py,sha256=awtvLCGjUKIx46d2rZpO2Cc
35
35
  mangoautomation/uidrive/web/async_web/_assertion.py,sha256=iC_j2pZN1pr2kFmxjEb8fBSX91M0BmrcRKARe3JH-kQ,12761
36
36
  mangoautomation/uidrive/web/async_web/_browser.py,sha256=39YroURzagpq0HoEn1RZnNf1KDKXIgWpKSvp5L_Yut0,5286
37
37
  mangoautomation/uidrive/web/async_web/_customization.py,sha256=uw6p9uLHLXglgSkH4qjDl1v0iGlaNjvf8LljRH5cAHU,347
38
- mangoautomation/uidrive/web/async_web/_element.py,sha256=btIkX2nlic17sgSbXtNZ8h5wD-rPyIK6TH5fH4WaoPk,9506
38
+ mangoautomation/uidrive/web/async_web/_element.py,sha256=Rm53EFUthDjr5dQbmdpZP37AFf_Euak83BYqUOK2p1Q,10222
39
39
  mangoautomation/uidrive/web/async_web/_input_device.py,sha256=sMAMHb_8QyPx3pKci0gRDQc2O7h1OYMGyA7fCWl81iM,3288
40
40
  mangoautomation/uidrive/web/async_web/_new_browser.py,sha256=WsQ-s2QCjXiePN_u4bLwpds_QpuDd9V2w6hLuLCB-zg,5624
41
41
  mangoautomation/uidrive/web/async_web/_page.py,sha256=TCYf79qQdVBBTTNq2COZFJVcLCgg5Ksu9lMgmQPVInU,2147
@@ -43,15 +43,15 @@ mangoautomation/uidrive/web/sync_web/__init__.py,sha256=31U15FJftsv6yyDlKT-2zN0C
43
43
  mangoautomation/uidrive/web/sync_web/_assertion.py,sha256=hVA7-Z3CfPgkmtnK_3M5UGo6sct88W6AJfQTnrqu9jU,12534
44
44
  mangoautomation/uidrive/web/sync_web/_browser.py,sha256=c7xHkIIFPawlzcVkGjwqeKfWAM--87wEJb3V3Ysi29w,5146
45
45
  mangoautomation/uidrive/web/sync_web/_customization.py,sha256=E_pfI8gKd0O6r4huJIvA6hoW-X9fSDVL4zEUqhHgxwE,355
46
- mangoautomation/uidrive/web/sync_web/_element.py,sha256=P5kSFkKyRP8a7qpKJZf_Lhp6Ik1jgHfIVB8Tgpl7kNw,9078
46
+ mangoautomation/uidrive/web/sync_web/_element.py,sha256=KkgLxGVwdl4JhRkIbGrUA12BmHohggdalEGlnztyrSE,9783
47
47
  mangoautomation/uidrive/web/sync_web/_input_device.py,sha256=8t6tJgMb4zgb4Sv02XP3gUU0ZVbApCs3WaILv8Fe1iY,3169
48
48
  mangoautomation/uidrive/web/sync_web/_new_browser.py,sha256=LNwhzjf0SbsBAaIXD_bEq623MsX2RvSdLc6tIt1ygjA,5516
49
49
  mangoautomation/uidrive/web/sync_web/_page.py,sha256=MNekcL7o5YXEloeuvi3YrpOZxGhEWfrq-5i4PbtTLFg,2027
50
50
  tests/__init__.py,sha256=UhCNFqiVjxdh4CXESNo4oE7qfjpYYVkeHbSE5-7LGDY,125
51
51
  tests/test_ui_and.py,sha256=4k0_3bx_k2KbZifeRWGK65sxtdiPUOjkNzZ5oxjrc18,672
52
52
  tests/test_ui_web.py,sha256=MFaUN8O5qKOMMgyk2eelhKZsYcSJm0Do6pCgsdBZEH4,2765
53
- mangoautomation-1.0.51.dist-info/LICENSE,sha256=03WP-mgFmo8ofRYDe1HVDQUEUKQZ2q6P6Q-2A4c-46A,1085
54
- mangoautomation-1.0.51.dist-info/METADATA,sha256=lX0w6NbYonPJ4U75xT7Z0U8WgLBetOIk8PYj1sd1WQs,660
55
- mangoautomation-1.0.51.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
56
- mangoautomation-1.0.51.dist-info/top_level.txt,sha256=g-uCmjvEODG8WFbmwbGM0-G0zHntHv8ZsS0PQRaMGtE,22
57
- mangoautomation-1.0.51.dist-info/RECORD,,
53
+ mangoautomation-1.0.52.dist-info/LICENSE,sha256=03WP-mgFmo8ofRYDe1HVDQUEUKQZ2q6P6Q-2A4c-46A,1085
54
+ mangoautomation-1.0.52.dist-info/METADATA,sha256=zr3lfifZTCbAdVV8jcH-LrU7vnpSwzQk5YLHb3zI_3A,660
55
+ mangoautomation-1.0.52.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
56
+ mangoautomation-1.0.52.dist-info/top_level.txt,sha256=g-uCmjvEODG8WFbmwbGM0-G0zHntHv8ZsS0PQRaMGtE,22
57
+ mangoautomation-1.0.52.dist-info/RECORD,,