mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
docs: migration typos (#17247)
This commit is contained in:
parent
b12cd9fb21
commit
81bcbd284f
@ -30,7 +30,7 @@ await locator.ClickAsync();
|
|||||||
|
|
||||||
**Strictness**
|
**Strictness**
|
||||||
|
|
||||||
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches given selector.
|
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches a given selector.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Throws if there are several frames in DOM:
|
// Throws if there are several frames in DOM:
|
||||||
|
@ -5,7 +5,7 @@ title: "Mock APIs"
|
|||||||
|
|
||||||
Playwright provides native support for most of the browser features. However, there are some experimental APIs
|
Playwright provides native support for most of the browser features. However, there are some experimental APIs
|
||||||
and APIs which are not (yet) fully supported by all browsers. Playwright usually doesn't provide dedicated
|
and APIs which are not (yet) fully supported by all browsers. Playwright usually doesn't provide dedicated
|
||||||
automation APIs in such cases. You can use mocks to test behavior of your application in such cases. This guide
|
automation APIs in such cases. You can use mocks to test the behavior of your application in such cases. This guide
|
||||||
gives a few examples.
|
gives a few examples.
|
||||||
|
|
||||||
<!-- TOC -->
|
<!-- TOC -->
|
||||||
@ -18,8 +18,7 @@ battery status.
|
|||||||
|
|
||||||
## Creating mocks
|
## Creating mocks
|
||||||
|
|
||||||
Since the page may be calling the API very early while loading it's important to setup all the mocks before the
|
Since the page may be calling the API very early while loading it's important to setup all the mocks before the page started loading. The easiest way to achieve that is to call [`method: Page.addInitScript`]:
|
||||||
page started loading. The easiest way to achieve that is to call [`method: Page.addInitScript`]:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
await page.addInitScript(() => {
|
await page.addInitScript(() => {
|
||||||
|
@ -140,18 +140,18 @@ Here's how to polyfill `waitForAngular` function in Playwright Test:
|
|||||||
await page.goto('https://example.org');
|
await page.goto('https://example.org');
|
||||||
await waitForAngular(page);
|
await waitForAngular(page);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Playwright Test Super Powers
|
## Playwright Test Super Powers
|
||||||
|
|
||||||
Once you're on Playwright Test, you get a lot!
|
Once you're on Playwright Test, you get a lot!
|
||||||
|
|
||||||
- Full zero-configuration TypeScript support
|
- Full zero-configuration TypeScript support
|
||||||
- Run tests across **all web engines** (Chrome, Firefox, Safari) on **any popular operating system** (Windows, MacOS, Ubuntu)
|
- Run tests across **all web engines** (Chrome, Firefox, Safari) on **any popular operating system** (Windows, macOS, Ubuntu)
|
||||||
- Full support for multiple origins, [(i)frames](./api/class-frame), [tabs and contexts](./pages)
|
- Full support for multiple origins, [(i)frames](./api/class-frame), [tabs and contexts](./pages)
|
||||||
- Run tests in parallel across multiple browsers
|
- Run tests in parallel across multiple browsers
|
||||||
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
||||||
|
|
||||||
Also you get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
||||||
- [Playwright Inspector](./debug.md)
|
- [Playwright Inspector](./debug.md)
|
||||||
- [Playwright Test Code generation](./auth#code-generation)
|
- [Playwright Test Code generation](./auth#code-generation)
|
||||||
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
||||||
|
@ -43,9 +43,9 @@ This guide describes migration to [Playwright Library](./library) and [Playwrigh
|
|||||||
|
|
||||||
`page.waitForNavigation` and `page.waitForSelector` remain, but in many cases will not be necessary due to [auto-waiting](./actionability).
|
`page.waitForNavigation` and `page.waitForSelector` remain, but in many cases will not be necessary due to [auto-waiting](./actionability).
|
||||||
|
|
||||||
The use of [ElementHandle] is discouraged , use [Locator] objects and web-first assertions instead.
|
The use of [ElementHandle] is discouraged, use [Locator] objects and web-first assertions instead.
|
||||||
|
|
||||||
Locators are the central piece of Playwright's auto-waiting and retry-ability. Locators are strict. This means that all operations on locators that imply some target DOM element will throw an exception if more than one element matches given selector.
|
Locators are the central piece of Playwright's auto-waiting and retry-ability. Locators are strict. This means that all operations on locators that imply some target DOM element will throw an exception if more than one element matches a given selector.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ Migration highlights (see inline comments in the Playwright code snippet):
|
|||||||
1. Each Playwright Library file has explicit import of `chromium`. Other browsers `webkit` or `firefox` can be used.
|
1. Each Playwright Library file has explicit import of `chromium`. Other browsers `webkit` or `firefox` can be used.
|
||||||
1. For browser state isolation, consider [browser contexts](./browser-contexts.md)
|
1. For browser state isolation, consider [browser contexts](./browser-contexts.md)
|
||||||
1. `setViewport` becomes `setViewportSize`
|
1. `setViewport` becomes `setViewportSize`
|
||||||
1. `networkidle2` becomes `networkidle`. Please note that on most cases it is not useful, thanks to auto-waiting.
|
1. `networkidle2` becomes `networkidle`. Please note that in most cases it is not useful, thanks to auto-waiting.
|
||||||
|
|
||||||
### Test example
|
### Test example
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ Playwright Test creates an isolated [Page] object for each test. However, if you
|
|||||||
|
|
||||||
With a few lines of code, you can hook up Playwright to your existing JavaScript [test runner](./test-runners).
|
With a few lines of code, you can hook up Playwright to your existing JavaScript [test runner](./test-runners).
|
||||||
|
|
||||||
To improve testing, it is adviced to use [Locators](./api/class-locator) and web-first [Assertions](./test-assertions). See [Writing Tests](./writing-tests)
|
To improve testing, it is advised to use [Locators](./api/class-locator) and web-first [Assertions](./test-assertions). See [Writing Tests](./writing-tests)
|
||||||
|
|
||||||
It is common with Puppeteer to use `page.evaluate()` or `page.$eval()` to inspect an [ElementHandle] and extract the value of text content, attribute, class... Web-first [Assertions](./test-assertions) offers several matchers for this purpose, it is more reliable and readable.
|
It is common with Puppeteer to use `page.evaluate()` or `page.$eval()` to inspect an [ElementHandle] and extract the value of text content, attribute, class... Web-first [Assertions](./test-assertions) offers several matchers for this purpose, it is more reliable and readable.
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ Once you're on Playwright Test, you get a lot!
|
|||||||
- Run tests in isolation in parallel across multiple browsers
|
- Run tests in isolation in parallel across multiple browsers
|
||||||
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
||||||
|
|
||||||
Also you get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
||||||
- [Playwright Inspector](./debug.md)
|
- [Playwright Inspector](./debug.md)
|
||||||
- [Playwright Test Code generation](./auth#code-generation)
|
- [Playwright Test Code generation](./auth#code-generation)
|
||||||
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
||||||
|
@ -83,7 +83,7 @@ Migration highlights (see inline comments in the Playwright Test code snippet):
|
|||||||
|
|
||||||
## Migrating queries
|
## Migrating queries
|
||||||
|
|
||||||
All queries like `getBy...`, `findBy...`, `queryBy...` and their multi-element counterparts are replaced with `page.locator('...')`. Locators always auto-wait and retry when needed, so you don't have to worry about choosing the right method. When you want to do a [list operation](./locators#lists), e.g. assert a list of texts, Playwright automatically performs multi-element opertations.
|
All queries like `getBy...`, `findBy...`, `queryBy...` and their multi-element counterparts are replaced with `page.locator('...')`. Locators always auto-wait and retry when needed, so you don't have to worry about choosing the right method. When you want to do a [list operation](./locators#lists), e.g. assert a list of texts, Playwright automatically performs multi-element operations.
|
||||||
|
|
||||||
1. `getByRole`: use [role selector](./selectors#role-selector) `component.locator('role=button[name="Sign up"]')`.
|
1. `getByRole`: use [role selector](./selectors#role-selector) `component.locator('role=button[name="Sign up"]')`.
|
||||||
1. `getByText`: use `component.locator('text=some value')` and other variations of the [text selector](./selectors#text-selector).
|
1. `getByText`: use `component.locator('text=some value')` and other variations of the [text selector](./selectors#text-selector).
|
||||||
@ -141,7 +141,7 @@ Once you're on Playwright Test, you get a lot!
|
|||||||
- Run tests in isolation in parallel across multiple browsers
|
- Run tests in isolation in parallel across multiple browsers
|
||||||
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
|
||||||
|
|
||||||
Also you get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
|
||||||
- [Playwright Inspector](./debug.md)
|
- [Playwright Inspector](./debug.md)
|
||||||
- [Playwright Test Code generation](./auth#code-generation)
|
- [Playwright Test Code generation](./auth#code-generation)
|
||||||
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
- [Playwright Tracing](./trace-viewer) for post-mortem debugging
|
||||||
|
2
packages/playwright-core/types/types.d.ts
vendored
2
packages/playwright-core/types/types.d.ts
vendored
@ -14499,7 +14499,7 @@ export interface FileChooser {
|
|||||||
* **Strictness**
|
* **Strictness**
|
||||||
*
|
*
|
||||||
* Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
|
* Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
|
||||||
* given selector.
|
* a given selector.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // Throws if there are several frames in DOM:
|
* // Throws if there are several frames in DOM:
|
||||||
|
Loading…
Reference in New Issue
Block a user