【minium】MacOS14.4.1尝试连接iPhone真机测试时,minium报错
复现步骤: 1.通过tidevice启动iPhone终端的WDA [图片] 2.确保浏览器能够成功访问WDA [图片] 3.编写code尝试调试。code如下: # -*- coding: utf-8 -*-
import minium
mini = minium.Minium({
"platform": "ios", # 来自测试任务配置项
"device_desire": {
"wda_ip": "localhost",
"wda_port": "8100",
"device_info": {
"udid": "bacfb3ea889d42c69ef88f2a68dbc277212c853a"
}
},
"project_path": "/Users/fengwu/软件项目/WeChatProjects/mini-wechat", # 来自组件库配置项
"dev_tool_path": "/Applications/wechatwebdevtools.app/Contents/MacOS/cli", # 来自代理程序配置项,提供文件选择
"debug_mode": "debug", # 来自代理程序配置项,提供下拉选项
"test_port": 9420, # 来自代理程序配置项,提供自动+指定内容输入
"outputs": "outputs", # 来自代理程序配置项,提供文件夹选择+新增文件夹
})
print(mini.get_system_info())
期望结果:成功打印系统信息 实际结果:minium报错,报错信息如下: /Users/fengwu/软件项目/test/testTidevice3/env/bin/python /Users/fengwu/软件项目/test/testTidevice3/first_test.py
[D 2024-05-17 14:20:48 minium wx_minium#111 __init__] {'debug': False, 'base_dir': '/Users/fengwu/软件项目/test/testTidevice3', 'platform': 'ios', 'app': 'wx', 'debug_mode': 'debug', 'close_ide': False, 'auto_capture': 'auto', 'check_mp_foreground': True, 'auto_relaunch': True, 'device_desire': {'wda_ip': 'localhost', 'wda_port': '8100', 'device_info': {'udid': 'bacfb3ea889d42c69ef88f2a68dbc277212c853a'}}, 'account_info': {}, 'report_usage': True, 'remote_connect_timeout': 180, 'request_timeout': 60, 'use_push': True, 'full_reset': False, 'outputs': 'outputs', 'enable_app_log': False, 'enable_network_panel': False, 'project_path': '/Users/fengwu/软件项目/WeChatProjects/mini-wechat', 'dev_tool_path': '/Applications/wechatwebdevtools.app/Contents/MacOS/cli', 'test_port': 9420, 'mock_native_modal': {}, 'mock_request': [], 'auto_authorize': False, 'audits': None, 'teardown_snapshot': False, 'mock_images_dir': '', 'mock_images': {}, 'need_perf': False, 'appid': None, 'enable_h5': True, 'framework_capture': True, 'error_capture': False, 'assert_capture': True}
[I 2024-05-17 14:20:49 minium iosnative#328 ping_driver] ping WebDriver [http://localhost:8100/status]: 200, {
"value" : {
"build" : {
"version" : "8.5.6",
"time" : "May 16 2024 16:32:57",
"productBundleIdentifier" : "com.facebook.WebDriverAgentRunner"
},
"os" : {
"testmanagerdVersion" : 65535,
"name" : "iOS",
"sdkVersion" : "17.4",
"version" : "16.7.2"
},
"device" : "iphone",
"ios" : {
"ip" : "172.20.1.93"
},
"message" : "WebDriverAgent is ready to accept commands",
"state" : "success",
"ready" : true
},
"sessionId" : null
}
[I 2024-05-17 14:20:49 minium basenative#59 wrapper] call BaseNative.is_in_wechat
Traceback (most recent call last):
File "/Users/fengwu/软件项目/test/testTidevice3/first_test.py", line 19, in <module>
mini = minium.Minium({
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/__init__.py", line 31, in Minium
return get_minium_driver(conf, *args, **kwargs)
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/miniprogram/__init__.py", line 28, in get_minium_driver
return APP[application](conf, *args, **kwargs)
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/miniprogram/wx_minium.py", line 121, in __init__
if not self.native.is_in_wechat():
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/native/wx_native/basenative.py", line 60, in wrapper
result = func(*args, **kwargs)
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/native/wx_native/basenative.py", line 756, in is_in_wechat
return self._is_in_wechat(self._get_current_activity())
File "/Users/fengwu/软件项目/test/testTidevice3/env/lib/python3.10/site-packages/minium/native/wx_native/iosnative.py", line 1182, in _get_current_activity
app_status = self.app.session.app_state(self.bundle_id)
AttributeError: 'NoneType' object has no attribute 'session'
Process finished with exit code 1
问题备注:注释掉env/lib/python3.10/site-packages/minium/miniprogram/wx_minium.py文件代码第121行,变更源码为如下,则执行成功: if native is None and conf.platform:
try:
self._native = get_native_driver(conf.platform, conf)
except KeyError as ke: # 配置不全
self.logger.error(ke)
except Exception as e:
self.logger.warning(f"instantiate {conf.platform} native driver fail: {str(e)}")
else:
# if not self.native.is_in_wechat():
self.native.start_wechat()
环境信息: minium版本(minitest -v):{'version': '1.5.4', 'revision': 'd0e4ae555098cbedc3c3d5dd383806e1d5aebe34', 'branch': 'master', 'update_at': '2024-04-22 21:01:28'} 小程序开发者工具版本:RC 1.06.2402301 MacOS版本:arm64 14.4.1 tidevice版本:0.12.10