系列文章目录
微软新开源!不用写 1 行代码的自动化测试工具
https://github.com/microsoft/playwright-python @[TOC](文章目录)
1. 需要安装依赖库(本次介绍pip版本),详见:
详细官网使用方法:
1、 下载安装,执行以下命令,分别对应下载playwright的库,以及Chromium、Firefox 、WebKit浏览器的二进制驱动文件:
pip install --upgrade pip (可忽略)
pip install playwright -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
playwright install (此步骤会比较的慢)
2. conda版本
conda config --add channels conda-forge
conda config --add channels microsoft
conda install playwright
playwright install
2、 自动化脚本录制:
python -m playwright codegen
3.开始使用,此刻会自动打开浏览器
创建文件加src,并执行一下命令:
mkdir src
cd src
playwright codegen wikipedia.org
4.自动记录并创建py脚本
python -m playwright codegen --target python -o 'shortcut.py' -b chromium https://www.baidu.com
5.左边操作,右边自动生成代码
6.自定义编辑py文件,在启动
python xxx.py