当前位置:网站首页>[Playwright Test Tutorial] 5 minutes to get started
[Playwright Test Tutorial] 5 minutes to get started
2022-08-04 02:34:00 【Zeze says test】
I love Playwright!This is a very powerful automation tool that Microsoft has open sourced, and in a few years, it is likely to replace Selenium in the notification position of browser automation.After using it for a period of time, I didn't find any good Chinese materials to refer to, so many problems could not be solved in time, so I decided to record the notes I used to give back to the community.
Start
This time I want to sort out how to quickly build the execution environment of Playwright. There are some pits, I will also record them, and I will follow the operation when I re-build the environment in the future.
Playwright currently supports JavaScript, Python, Java, .NET, and this tutorial uses Python language for demonstration.To use Playwright with the Python language, two steps are required.The first step is to install the python execution environment.The second step is to install Playwright.
Install
To install python, you only need to download the installation package from the official website and click install to complete.First, we open the official website of python, and then click download to download the installation package.Different operating systems will recommend different installation packages.After the download is complete, click the installation file to complete the installation.
Install Playwright
The Python language installation package for Playwright almost containsWith all the required components, the only thing you need to do to install the playwright tool is to open the command line tool and enter the installation instructions:
pip install playwrightplaywright installpip install playwright installs the language pack tool. In addition, playwright needs to rely on the browser environment to run. Playwright install means downloading and installing the dependent browser.The browser does not need to be installed in advance. With this command, the program will automatically download a chrioum browser and a firefox browser, and subsequent browser operations will run on these browsers.After waiting patiently for the browser to download, the installation is completed, and the download will not be repeated every time you run it in the future.
If you feel that the waiting time is too long, you can also choose to install the chromium browser or firefox browser separately. Currently supported browsers include chromium, chrome, chrome-beta, msedge, msedge-beta, msedge-dev, firefox, webkit.
playwright install chromium# orplaywright install firefoxAll command line parameters about playwright can be viewed through the help command:
$ playwright --helpUsage: npx playwright [options] [command]Options:-V, --version output the version number-h, --help display help for commandCommands:open [options] [url] open page in browser specified via -b, --browsercodegen [options] [url] open page and generate code for user actionsinstall [options] [browser...] ensure browsers necessary for this version of Playwright are installedinstall-deps [browser...] install dependencies necessary to run browsers (will ask for sudo permissions)cr [options] [url] open page in Chromiumff [options] [url] open page in Firefoxwk [options] [url] open page in WebKitscreenshot [options] capture a page screenshotpdf [options] save page as pdfshow-trace [options] [trace] Show trace viewerhelp [command] display help for command Run
After installing Playwright and the browser, we can simply run the code below.This program will open a browser and visit a web address, then you can perform actions on the browser.Every operation you do will be recorded by playwright, and the running code will be generated and displayed in an Inspector interface. These codes can be copied and saved to the code base.
playwright codegen http://www.baidu.com
To be continued~~
边栏推荐
- Intranet penetration - application
- C语言--环形缓存区
- 【原创】启动Win10自带的XPS/OXPS阅读器
- There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
- idea中diagram使用
- 阿里云国际版基于快照与镜像功能迁移云服务器数据
- 云开发校园微社区微信小程序源码/二手交易/兼职交友微信小程序开源源码
- 实例040:逆序列表
- Zabbix set up email alert + enterprise WeChat alert
- QNX Hypervisor 2.2用户手册]10.2 vdev 8259
猜你喜欢
随机推荐
董明珠直播时冷脸离场,员工频犯低级错误,自家产品没人能弄明白
Variable string
Countdown to 2 days, the "New Infrastructure of Cultural Digital Strategy and Ecological Construction of Cultural Art Chain" will kick off soon
多线程间的通信方式你知道几种?
为什么用Selenium做自动化测试
WPE详细教程
Snake game bug analysis and function expansion
STM8S105k4t6c--------------点亮LED
C语言力扣第54题之螺旋矩阵。模拟旋转
sql有关问题,小时粒度,找到前一个小时内的数据
flask框架初学-06-对数据库的增删改查
FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
pytorch应用于MNIST手写字体识别
activiti流程执行过程中,数据库表的使用关系
实例040:逆序列表
返回字符串中的最大回文数
Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
持续投入商品研发,叮咚买菜赢在了供应链投入上
2022年茶艺师(中级)考试试题模拟考试平台操作









