checkly/puppeteer-to-playwright hiện có 141 sao trên GitHub, viết chủ yếu bằng JavaScript. Puppeteer to Playwright conversion script
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
puppeteer-to-playwright automatically converts Javascript Puppeteer scripts to Playwright, aiming to reduce the amount of manual work involved in such a migration (ideally reducing it to zero). It is heavily based on jscodeshift.
puppeteer-to-playwright requires Node.js 14 or newer.
Features
puppeteer-to-playwright will convert your existing Puppeteer script to Playwright, including:
Converting import statements
Converting basic methods to match new API (e.g. setViewport to setViewportSize and similar)
Creating browser context explicitly
Eliminating explicit waiting (unless Strict mode is enabled)
Converting cookies-related commands
Currently unsupported
The following features are not yet supported, meaning that the corresponding instructions won't be converted to Playwright if they are used in your Puppeteer script:
File upload
File download
Request/response interception
Multiple contexts / tabs
Still, these might very well be implemented in the near future. If you would like to help, see our how to contribute section.
Getting Started
You can use puppeteer-to-playwright on a script file or multiple scripts at a time.
🚨 It will overwrite the script file when run, so we recommend doing a dry-run first.
Dry run
A dry run will run the conversion without actually writing to the file(s) you point it at.
$ npm run convert -- -d my-puppeteer-script.js
You can add -p to print out the resulting script:
$ npm run convert -- -d -p my-puppeteer-script.js
You can pass additional jscodeshift parameters as described in the project's repository.
Convert script
You can convert scripts one by one...
$ npm run convert my-puppeteer-script.js
...or you can convert entire folders recursively.
$ npm run convert my-puppeteer-folder
puppeteer-to-playwright will ignore files that have any extension other than .js, as well as those that do not import/require Puppeteer.
Strict mode
When converting files, puppeteer-to-playwright will, by default, get rid of likely unnecessary waits that Playwright should handle automatically. If you know that the waits in your Puppeteer script will remain necessary even with Playwright, you can set puppeteer-to-playwright to Strict mode by running export STRICT=true. Alternatively, you can set the flag directly when converting a file or folder, e.g.:
STRICT=true npm run convert my-puppeteer-folder
How to contribute
If you would like to improve this codemod, you are very welcome to send a PR. Make sure it contains a test for the specific feature you are trying to add. Testing is currently set up as follows:
In test/base you have the original Puppeteer script
In test/output you have the original Puppeteer script, which will be automatically converted when tests are run then immediately restored to the original
In test/expected you have the expected Playwright script that your result will need to be equal to
You can run npm run test locally, and tests will run automatically for each new PR.
Links
jscodeshift - without which this project wouldn't be possible.
ASTExplorer - useful debugging tool in case you would like to modify the transform file of this project to tweak its output.
License
MIT
Code, test, and deploy synthetic monitoring at scale From Checkly with ♥️
checkly/puppeteer-to-playwright có phải mã nguồn mở không?
Có — checkly/puppeteer-to-playwright phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/checkly/puppeteer-to-playwright.
checkly/puppeteer-to-playwright là gì?
checkly/puppeteer-to-playwright (checkly/puppeteer-to-playwright) là dự án JavaScript trên GitHub. Theo mô tả gốc: Puppeteer to Playwright conversion script
Đọc thêm về checkly/puppeteer-to-playwright ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/checkly/puppeteer-to-playwright là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về puppeteer-to-playwright?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về puppeteer-to-playwright.