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
test: add tests for selectors matching root behavior (#3744)
Dmitry Gozman5c3bf5bf3e44
diff --git a/test/selectors-css.spec.ts b/test/selectors-css.spec.tsindex c1198f64b9..a92b02450b 100644--- a/test/selectors-css.spec.ts+++ b/test/selectors-css.spec.ts@@ -119,3 +119,9 @@ it('should work with attribute selectors', async ({page}) => {expect(await page.$eval(`[attr*=hello] >> span`, e => e.parentNode === window['div'])).toBe(true);expect(await page.$eval(`[attr3="] span"] >> span`, e => e.parentNode === window['div'])).toBe(true);});++it('should not match root after >>', async ({page, server}) => {+ await page.setContent('<section><div>test</div></section>');+ const element = await page.$('css=section >> css=section');+ expect(element).toBe(null);+});diff --git a/test/selectors-text.spec.ts b/test/selectors-text.spec.tsindex d379c536d0..34d079608f 100644--- a/test/selectors-text.spec.ts+++ b/test/selectors-text.spec.ts@@ -204,3 +204,11 @@ it('should waitForSelector with distributed elements', async ({page, server}) =>const handle = await promise;expect(await handle.textContent()).toBe('Hello from light');});++it('should match root after >>', async ({page, server}) => {+ await page.setContent('<section>test</section>');+ const element = await page.$('css=section >> text=test');+ expect(element).toBeTruthy();+ const element2 = await page.$('text=test >> text=test');+ expect(element2).toBeTruthy();+});