Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: make visible=false work (#34040)
Pavel Feldman94d0fc780db9
diff --git a/packages/playwright-core/src/server/injected/injectedScript.ts b/packages/playwright-core/src/server/injected/injectedScript.tsindex 74ff799ff1..a1ffdf893c 100644--- a/packages/playwright-core/src/server/injected/injectedScript.ts+++ b/packages/playwright-core/src/server/injected/injectedScript.ts@@ -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 };}diff --git a/tests/page/selectors-misc.spec.ts b/tests/page/selectors-misc.spec.tsindex 384bf4aef1..605ff6c5a0 100644--- a/tests/page/selectors-misc.spec.ts+++ b/tests/page/selectors-misc.spec.ts@@ -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>