mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs(protracor): add a simpler "awaitForAngular" (#10834)
This commit is contained in:
parent
027ecd80d0
commit
683dc4eeac
@ -117,7 +117,22 @@ Here's how to polyfill `waitForAngular` function in Playwright Test:
|
|||||||
await executeScriptAsync(page, clientSideScripts.waitForAngular, '');
|
await executeScriptAsync(page, clientSideScripts.waitForAngular, '');
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
If you don't want to keep a version protractor around, you can also use this simpler approach using this function (only works for Angular 2+):
|
||||||
|
```js
|
||||||
|
async function waitForAngular(page) {
|
||||||
|
await page.evaluate(async () => {
|
||||||
|
// @ts-expect-error
|
||||||
|
if (window.getAllAngularTestabilities) {
|
||||||
|
// @ts-expect-error
|
||||||
|
await Promise.all(window.getAllAngularTestabilities().map(whenStable));
|
||||||
|
// @ts-expect-error
|
||||||
|
async function whenStable(testability) {
|
||||||
|
return new Promise((res) => testability.whenStable(res) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
1. Polyfill usage
|
1. Polyfill usage
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user