chore: make visible=false work (#34040)
This commit is contained in:
parent
b58a4762f4
commit
94d0fc780d
|
@ -457,7 +457,8 @@ export class InjectedScript {
|
|||
const queryAll = (root: SelectorRoot, body: string) => {
|
||||
if (root.nodeType !== 1 /* Node.ELEMENT_NODE */)
|
||||
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 };
|
||||
}
|
||||
|
|
|
@ -74,6 +74,18 @@ it('should work with >> visible=', async ({ page }) => {
|
|||
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 }) => {
|
||||
await page.setContent(`
|
||||
<section>
|
||||
|
|
Loading…
Reference in New Issue