按照官方文档对config.json做了如下配置:
{
"project_path": "C:\\Users\\wb.chenchunzhi20\\Desktop\\小程序测试包\\测试环境\\V4.2.1测试",
"dev_tool_path": "C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat",
"platform": "Android",
"device_desire": {
"serial": "e4ddf97e",
"uiautomator_version": "2"
},
"debug_mode": "info",
"test_port": "9420",
"close_ide": "False"
}
/也用\\做了替换;
first_test.py文件中代码如下:
#!/usr/bin/env python3
import minium
mini = minium.WXMinium()
mini.connect_dev_tool()
class test(minium.MiniTest):
def test_ui_op(self):
self.assertTexts(["房间名"], "view")
if __name__ == "__main__":
test().test_ui_op()
右键运行first_test.py文件后,报如下错误:
D:\Python3\python.exe C:/Users/wb.chenchunzhi20/Desktop/UI自动化/小程序自动化/wechatDemo序自动化/wechatDemo/test/first_test.py
C:\Users\wb.chenchunzhi20\Desktop\UI自动化\小程序自动化\wechatDemo序自动化\wechatDemo
Can not find project_path in config, that means you must open dev tool by automation way first
[WinError 10061] 由于目标计算机积极拒绝,无法连接。
minumexception: {'TimeStamp': '2021-05-21 10:59:19', 'Type': 'MiniTimeoutError', 'Args': 'connect to server timeout: ws://localhost:9420, thread:False', 'Trace': '', 'Uin': 0, 'version': '', 'ext': ''}
connect to server timeout: ws://localhost:9420, thread:False
Traceback (most recent call last):
File "D:\Python3\lib\site-packages\minium\miniprogram\wx_minium.py", line 204, in connect_dev_tool
connection = Connection(
File "D:\Python3\lib\site-packages\minium\miniprogram\base_driver\connection.py", line 59, in __init__
self._connect()
File "D:\Python3\lib\site-packages\minium\miniprogram\base_driver\connection.py", line 109, in _connect
raise MiniTimeoutError(
minium.framework.exception.MiniTimeoutError: connect to server timeout: ws://localhost:9420, thread:False
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
[WinError 10061] 由于目标计算机积极拒绝,无法连接。
python版本3.9.5;
minitest版本1.0.6;
微信开发者工具版本为1.05.2105170;
微信开发者工具安全-服务端口已打开;
微信开发者工具基础库为2.16.1;
https://developers.weixin.qq.com/community/develop/doc/000a6ccdbb8b507dcf2c008c453c00