当前位置:网站首页>[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 install
pip 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 firefox
All 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~~
边栏推荐
- Good bosses, please ask the flink CDC oracle to Doris, found that the CPU is unusual, a run down
- DDTL: Domain Transfer Learning at a Distance
- lombok注解@RequiredArgsConstructor的使用
- QNX Hypervisor 2.2 user manual] 10.1 gm vdev options
- keytool命令
- Presto中broadcast join和partition join执行计划的处理过程
- What is SVN (Subversion)?
- flask框架初学-06-对数据库的增删改查
- Example 040: Reverse List
- MySQL高级-读写分离-分库分表
猜你喜欢
mpf5_定价Bond_yield curve_Spot coupon_duration_有效利率_连续复利_远期_Vasicek短期_CIR模型Derivatives_Tridiagonal_ppf
编写 BOLL 心得体会
关联接口测试
融云「音视频架构实践」技术专场【内含完整PPT】
C程序编译和预定义详解
Simple record of Flink principle flow chart
Use of lombok annotation @RequiredArgsConstructor
STM8S项目创建(STVD创建)---使用 COSMIC 创建 C 语言项目
Flask Framework Beginner-05-Command Management Manager and Database Use
Example 041: Methods and variables of a class
随机推荐
Example 041: Methods and variables of a class
MallBook 助力SKT思珂特教育集团,立足变化,拥抱敏捷交易
2022广东省安全员A证第三批(主要负责人)考试题库及模拟考试
web端动效 lottie-web 使用
LeetCode:899. 有序队列【思维题】
sqoop ETL工具
实例038:矩阵对角线之和
C程序编译和预定义详解
Example 039: Inserting elements into an ordered list
2022.8.3-----leetcode.899
Simple sorting (summer vacation daily question 14)
第08章 索引的创建与设计原则【2.索引及调优篇】【MySQL高级】
Simple record of Flink principle flow chart
Flask Framework Beginner-05-Command Management Manager and Database Use
C语言--环形缓存区
倒计时2天,“文化数字化战略新型基础设施暨文化艺术链生态建设发布会”启幕在即
STM8S项目创建(STVD创建)---使用 COSMIC 创建 C 语言项目
Good bosses, please ask the flink CDC oracle to Doris, found that the CPU is unusual, a run down
Variable string
简单排序(暑假每日一题 14)