diff --git a/packages/playwright-core/src/server/injected/selectorEvaluator.ts b/packages/playwright-core/src/server/injected/selectorEvaluator.ts index 1941482757..abe0566249 100644 --- a/packages/playwright-core/src/server/injected/selectorEvaluator.ts +++ b/packages/playwright-core/src/server/injected/selectorEvaluator.ts @@ -206,7 +206,7 @@ export class SelectorEvaluatorImpl implements SelectorEvaluator { if (css !== undefined) { elements = this._queryCSS(context, css); const hasScopeClause = funcs.some(f => f.name === 'scope'); - if (hasScopeClause && context.scope.nodeType === 1 /* Node.ELEMENT_NODE */) + if (hasScopeClause && context.scope.nodeType === 1 /* Node.ELEMENT_NODE */ && this._matchesCSS(context.scope as Element, css)) elements.unshift(context.scope as Element); } else { firstIndex = funcs.findIndex(func => this._getEngine(func.name).query !== undefined); diff --git a/tests/page/selectors-css.spec.ts b/tests/page/selectors-css.spec.ts index bc5e59e38f..8f40f497f6 100644 --- a/tests/page/selectors-css.spec.ts +++ b/tests/page/selectors-css.spec.ts @@ -394,7 +394,6 @@ it('should work with :scope', async ({ page, server }) => { it('should work with :scope and class', async ({ page }) => { it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/17824' }); - it.fixme(); await page.setContent(`
`); const apples = page.locator('.apple');