首页 > 编程语言 >Playwright+JavaScript-1.环境准备与快速开始

Playwright+JavaScript-1.环境准备与快速开始

时间:2023-03-20 09:35:52浏览次数:39  
标签:tests playwright JavaScript Playwright npx 测试 test 快速

前言

Playwright 可以支持在 TypeScript、JavaScript、Python、.NET、Java中使用,本系列以 JavaScript 语言为示例。

环境准备

1.安装node.js 需要Node.js 14 或更高版本
2.安装vsocde

使用npm 安装playwright

npm init playwright@latest

此时出现2个选项:TypeScript or JavaScript?
我选的是 JavaScript

接着出现的几个提示,全部按enter确定

  • 在 TypeScript 或 JavaScript 之间选择(默认为 TypeScript)
  • 测试文件夹的名称(如果项目中已有测试文件夹,则默认为测试或 e2e)
  • 添加 GitHub Actions 工作流以轻松地在 CI 上运行测试
  • 安装 Playwright 浏览器(默认为真)

创建完成

✔ Success! Created a Playwright Test project at D:\playwright_js

Inside that directory, you can run several commands:

  npx playwright test
    Runs the end-to-end tests.

  npx playwright test --project=chromium
    Runs the tests only on Desktop Chrome.

  npx playwright test example
    Runs the tests in a specific file.

  npx playwright test --debug
    Runs the tests in debug mode.

  npx playwright codegen
    Auto generate tests with Codegen.

We suggest that you begin by typing:

    npx playwright test

And check out the following files:
  - .\tests\example.spec.js - Example end-to-end test
  - .\tests-examples\demo-todo-app.spec.js - Demo Todo App end-to-end tests
  - .\playwright.config.js - Playwright Test configuration

Visit https://playwright.dev/docs/intro for more information. ✨

Happy hacking! 

标签:tests,playwright,JavaScript,Playwright,npx,测试,test,快速
From: https://www.cnblogs.com/yoyoketang/p/17235212.html

相关文章