pytest+playwright做UI自动化是我最近一直使用的‘套餐’。本文重点playwright,需要对pytest有较深的了解
官网
想系统学习还是要去官网文档:https://playwright.dev/python/docs/intro
安装pytest插件:pytest-playwright
-
没有安装插件之前,我们可以查看一下
pytest
自带有什么fixture
在终端执行:pytest --fixtures
-
安装
pytest-playwright
,之后又增加了什么?
在终端执行:pip install pytest-playwright
安装了好几个依赖,注意已经安装了playwright
和pytest-playwright
安装之后我们看一下有什么fixtures
上图可以看出来多了很多fixture,这些fixture都可以在用例里面直接调用。所有有了官网的第一个案例:https://playwright.dev/python/docs/intro#add-example-test
后续工作中的自动化也是这样调用的。