1、安装python
打开安装资料--win--python,点击安装
勾选 add python3.10 to path
点击 install now
win+R 输入cmd 输入:python -V
Python 3.10.4
配置:在环境变量path里面增加(python按照路径)
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Scripts
C:\Users\Administrator\AppData\Local\Programs\Python\Python310
2、安装minium
pip3 install minium
3、项目结构
4、config.json
- config.json 放到.py的相同路径
- "project_path"项目路径下包含project.config
- "dev_tool_path"微信开发者工具要用/cli.bat
{
"project_path": "C:\\Users\\Administrator\\Desktop\\dist\\dev\\mp-weixin",
"dev_tool_path": "E:\\微信小程序开发工具\\微信web开发者工具\\cli.bat",
"debug_mode": "info"
}
5、微信开发者工具 要打开服务端口等
设置-安全设置-服务端口(开启)和允许获取工具登录票据(开启)
6、my_test.py
import minium
class test(minium.MiniTest):
def test_my(self):
##元素定位+点击
self.page.get_element("view",inner_text="确认").click()
##页面跳转
self.app.navigate_to("/pages/userCenter/userCenter")
self.page.get_element("view",inner_text="收藏").click()
学习文档: