cherry-pick: sync ToT docs (#16448)

This PR cherry-picks the following commits:

- 16d9f66ff9
- fcee4d5444
- d12afa7ff3
This commit is contained in:
Playwright Service 2022-08-11 03:29:25 -07:00 committed by GitHub
parent bb54c04096
commit 3bc6b4b644
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 20 deletions

49
docs/src/codegen-intro.md Normal file
View file

@ -0,0 +1,49 @@
---
id: codegen-intro
title: "Test Generator"
---
Playwright comes with the ability to generate tests out of the box and is a great way to quickly get started with testing. It will open two windows, a browser window where you interact with the website you wish to test and the Playwright Inspector window where you can record your tests, copy the tests, clear your tests as well as change the language of your tests.
**You will learn**
- [How to generate tests with Codegen](/codegen.md#running-codegen)
## Running Codegen
```bash js
npx playwright codegen playwright.dev
```
```bash java
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen playwright.dev"
```
```bash python
playwright codegen playwright.dev
```
```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen playwright.dev
```
Run `codegen` and perform actions in the browser. Playwright will generate the code for the user interactions. `Codegen` will attempt to generate resilient text-based selectors.
<img width="1183" alt="Codegen generating code for tests for playwright.dev website" src="https://user-images.githubusercontent.com/13063165/181852815-971c10da-0b55-4e54-8a73-77e1e825193c.png" />
When you have finished interacting with the page, press the **record** button to stop the recording and use the **copy** button to copy the generated code to your editor.
<img width="1266" alt="Codegen generating code for tests for playwright.dev" src="https://user-images.githubusercontent.com/13063165/183905981-003c4173-0d5e-4960-8190-50e6ca71b2c3.png" />
Use the **clear** button to clear the code to start recording again. Once finished close the Playwright inspector window or stop the terminal command.
To learn more about generating tests check out or detailed guide on [Codegen](./codegen.md).
## What's Next
- [See a trace of your tests](./trace-viewer.md)

View file

@ -5,16 +5,6 @@ title: "Test Generator"
Playwright comes with the ability to generate tests out of the box and is a great way to quickly get started with testing. It will open two windows, a browser window where you interact with the website you wish to test and the Playwright Inspector window where you can record your tests, copy the tests, clear your tests as well as change the language of your tests. Playwright comes with the ability to generate tests out of the box and is a great way to quickly get started with testing. It will open two windows, a browser window where you interact with the website you wish to test and the Playwright Inspector window where you can record your tests, copy the tests, clear your tests as well as change the language of your tests.
**You will learn**
- [How to generate tests with Codegen](/codegen.md#running-codegen)
- [How to emulate viewport size](/codegen.md#emulate-viewport-size)
- [How to emulate devices](/codegen.md#emulate-devices)
- [How to emulate color scheme](/codegen.md#emulate-color-scheme)
- [How to emulate geolocation, language and timezone](/codegen.md#emulate-geolocation-language-and-timezone)
- [How to preserve authenticated state](/codegen.md#preserve-authenticated-state)
- [How to record using a custom setup](/codegen.md#record-using-custom-setup)
## Running Codegen ## Running Codegen
```bash js ```bash js
@ -285,7 +275,3 @@ await context.RouteAsync('**/*', route => route.ContinueAsync());
var page = await context.NewPageAsync(); var page = await context.NewPageAsync();
await page.PauseAsync(); await page.PauseAsync();
``` ```
## What's Next
- [See a trace of your tests](./trace-viewer-intro.md)

View file

@ -62,13 +62,9 @@ tests-examples/
demo-todo-app.spec.ts demo-todo-app.spec.ts
``` ```
The playwright [playwright.config](./test-configuration.md) is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on. The [playwright.config](./test-configuration.md) is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on. If you are running tests inside an already existing project then dependencies will be added directly to your `package.json`.
If you are running tests inside an already existing project then dependencies will be added directly to your `package.json`. The `tests` folder contains a basic example test to help you get started with testing. For a more detailed example check out the `tests-examples` folder which contains tests written to test a todo app.
The `tests` folder contains a basic example test to help you get started with testing.
For a more detailed example check out the `tests-examples` folder which contains tests written to test a todo app.
## Running the Example Test ## Running the Example Test

View file

@ -650,4 +650,5 @@ export default config;
## Third party reporter showcase ## Third party reporter showcase
* [Allure](https://www.npmjs.com/package/allure-playwright) * [Allure](https://www.npmjs.com/package/allure-playwright)
* [Monocart](https://github.com/cenfun/monocart-reporter)
* [Tesults](https://www.tesults.com/docs/playwright) * [Tesults](https://www.tesults.com/docs/playwright)