o 1、创建虚拟环境
§ python -m venv venv
o 2、进入创建的虚拟环境中
§ source venv/bin/activate
o 3、安装playwright,pytest, pytest-asyncio相关依赖
§ pip install playwright pytest pytest-asyncio
o 4、安装playwright 浏览器
§ playwright install
o 5、可能会遇到的问题
§ 1、ValueError: Browser.new_context: The future belongs to a different loop than the one specified as the loop argument
· 检查pytest和pytest-asyncio的版本
o 确保 pytest 和 pytest-asyncio 的版本兼容是运行异步测试的关键。通过安装兼容的版本并使用适当的配置,你应该能够顺利运行异步测试。如果遇到特定版本兼容性问题,可以查阅官方文档或更新到最新的兼容版本
o pip freeze > requirements.txt
o pip install -r requirements.txt