断断续续用了两年了playwright做个笔记吧

发布时间 2023-07-06 00:47:47作者: Tarzen

pytest+playwright做UI自动化是我最近一直使用的‘套餐’。本文重点playwright,需要对pytest有较深的了解

官网

想系统学习还是要去官网文档:https://playwright.dev/python/docs/intro

安装pytest插件:pytest-playwright

  • 没有安装插件之前,我们可以查看一下pytest自带有什么fixture
    在终端执行:pytest --fixtures
    image

  • 安装pytest-playwright,之后又增加了什么?
    在终端执行:pip install pytest-playwright
    image
    安装了好几个依赖,注意已经安装了playwrightpytest-playwright
    安装之后我们看一下有什么fixtures
    image
    上图可以看出来多了很多fixture,这些fixture都可以在用例里面直接调用。所有有了官网的第一个案例:https://playwright.dev/python/docs/intro#add-example-test
    image
    后续工作中的自动化也是这样调用的。