Merge branch 'main' of https://github.com/microsoft/playwright into eslint-if-braces
This commit is contained in:
commit
f058ca647c
|
|
@ -96,7 +96,7 @@ In case this browser is connected to, clears all created contexts belonging to t
|
||||||
browser server.
|
browser server.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
This is similar to force quitting the browser. Therefore, you should call [`method: BrowserContext.close`] on any [BrowserContext]'s you explicitly created earlier with [`method: Browser.newContext`] **before** calling [`method: Browser.close`].
|
This is similar to force-quitting the browser. To close pages gracefully and ensure you receive page close events, call [`method: BrowserContext.close`] on any [BrowserContext] instances you explicitly created earlier using [`method: Browser.newContext`] **before** calling [`method: Browser.close`].
|
||||||
:::
|
:::
|
||||||
|
|
||||||
The [Browser] object itself is considered to be disposed and cannot be used anymore.
|
The [Browser] object itself is considered to be disposed and cannot be used anymore.
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,8 @@ export class InjectedScript {
|
||||||
if (root.nodeType !== 1 /* Node.ELEMENT_NODE */) {
|
if (root.nodeType !== 1 /* Node.ELEMENT_NODE */) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return isElementVisible(root as Element) === Boolean(body) ? [root as Element] : [];
|
const visible = body === 'true';
|
||||||
|
return isElementVisible(root as Element) === visible ? [root as Element] : [];
|
||||||
};
|
};
|
||||||
return { queryAll };
|
return { queryAll };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,6 @@ async function generateFrameSelectorInParent(parent: Frame, frame: Frame): Promi
|
||||||
}, frameElement);
|
}, frameElement);
|
||||||
return selector;
|
return selector;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e.toString();
|
|
||||||
}
|
}
|
||||||
}, monotonicTime() + 2000);
|
}, monotonicTime() + 2000);
|
||||||
if (!result.timedOut && result.result) {
|
if (!result.timedOut && result.result) {
|
||||||
|
|
|
||||||
7
packages/playwright-core/types/types.d.ts
vendored
7
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -9589,10 +9589,11 @@ export interface Browser {
|
||||||
* In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from
|
* In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from
|
||||||
* the browser server.
|
* the browser server.
|
||||||
*
|
*
|
||||||
* **NOTE** This is similar to force quitting the browser. Therefore, you should call
|
* **NOTE** This is similar to force-quitting the browser. To close pages gracefully and ensure you receive page close
|
||||||
|
* events, call
|
||||||
* [browserContext.close([options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-close) on
|
* [browserContext.close([options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-close) on
|
||||||
* any [BrowserContext](https://playwright.dev/docs/api/class-browsercontext)'s you explicitly created earlier with
|
* any [BrowserContext](https://playwright.dev/docs/api/class-browsercontext) instances you explicitly created earlier
|
||||||
* [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#browser-new-context) **before**
|
* using [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#browser-new-context) **before**
|
||||||
* calling [browser.close([options])](https://playwright.dev/docs/api/class-browser#browser-close).
|
* calling [browser.close([options])](https://playwright.dev/docs/api/class-browser#browser-close).
|
||||||
*
|
*
|
||||||
* The [Browser](https://playwright.dev/docs/api/class-browser) object itself is considered to be disposed and cannot
|
* The [Browser](https://playwright.dev/docs/api/class-browser) object itself is considered to be disposed and cannot
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ export class BaseReporter implements ReporterV2 {
|
||||||
console.log(colors.yellow(' Slow test file: ') + file + colors.yellow(` (${milliseconds(duration)})`));
|
console.log(colors.yellow(' Slow test file: ') + file + colors.yellow(` (${milliseconds(duration)})`));
|
||||||
});
|
});
|
||||||
if (slowTests.length) {
|
if (slowTests.length) {
|
||||||
console.log(colors.yellow(' Consider splitting slow test files to speed up parallel execution'));
|
console.log(colors.yellow(' Consider running tests from slow files in parallel, see https://playwright.dev/docs/test-parallel.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,11 @@ export function useMeasure<T extends Element>() {
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bounds = target.getBoundingClientRect();
|
||||||
|
|
||||||
|
setMeasure(new DOMRect(0, 0, bounds.width, bounds.height));
|
||||||
|
|
||||||
const resizeObserver = new ResizeObserver((entries: any) => {
|
const resizeObserver = new ResizeObserver((entries: any) => {
|
||||||
const entry = entries[entries.length - 1];
|
const entry = entries[entries.length - 1];
|
||||||
if (entry && entry.contentRect) {
|
if (entry && entry.contentRect) {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export async function createSkipTestPredicate(projectName: string): Promise<Shou
|
||||||
return (info: TestInfo) => {
|
return (info: TestInfo) => {
|
||||||
const key = info.titlePath.join(' › ');
|
const key = info.titlePath.join(' › ');
|
||||||
const expectation = expectationsMap.get(key);
|
const expectation = expectationsMap.get(key);
|
||||||
return expectation === 'fail' || expectation === 'timeout';
|
return expectation === 'timeout';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,18 @@ it('should work with >> visible=', async ({ page }) => {
|
||||||
expect(await page.$eval('div >> visible=true', div => div.id)).toBe('target2');
|
expect(await page.$eval('div >> visible=true', div => div.id)).toBe('target2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with >> visible=false', async ({ page }) => {
|
||||||
|
await page.setContent(`
|
||||||
|
<section>
|
||||||
|
<div id=target1></div>
|
||||||
|
<div id=target2></div>
|
||||||
|
</section>
|
||||||
|
`);
|
||||||
|
await expect(page.locator('div >> visible=false')).toHaveCount(2);
|
||||||
|
await page.locator('#target2').evaluate(div => div.textContent = 'Now visible');
|
||||||
|
await expect(page.locator('div >> visible=false')).toHaveCount(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should work with :nth-match', async ({ page }) => {
|
it('should work with :nth-match', async ({ page }) => {
|
||||||
await page.setContent(`
|
await page.setContent(`
|
||||||
<section>
|
<section>
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
|
||||||
expect(result.output).toContain(`Slow test file: [bar] › dir${path.sep}a.test.js (`);
|
expect(result.output).toContain(`Slow test file: [bar] › dir${path.sep}a.test.js (`);
|
||||||
expect(result.output).toContain(`Slow test file: [baz] › dir${path.sep}a.test.js (`);
|
expect(result.output).toContain(`Slow test file: [baz] › dir${path.sep}a.test.js (`);
|
||||||
expect(result.output).toContain(`Slow test file: [qux] › dir${path.sep}a.test.js (`);
|
expect(result.output).toContain(`Slow test file: [qux] › dir${path.sep}a.test.js (`);
|
||||||
expect(result.output).toContain(`Consider splitting slow test files to speed up parallel execution`);
|
expect(result.output).toContain(`Consider running tests from slow files in parallel`);
|
||||||
expect(result.output).not.toContain(`Slow test file: [foo] › dir${path.sep}b.test.js (`);
|
expect(result.output).not.toContain(`Slow test file: [foo] › dir${path.sep}b.test.js (`);
|
||||||
expect(result.output).not.toContain(`Slow test file: [bar] › dir${path.sep}b.test.js (`);
|
expect(result.output).not.toContain(`Slow test file: [bar] › dir${path.sep}b.test.js (`);
|
||||||
expect(result.output).not.toContain(`Slow test file: [baz] › dir${path.sep}b.test.js (`);
|
expect(result.output).not.toContain(`Slow test file: [baz] › dir${path.sep}b.test.js (`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue