test: add tests for selectors matching root behavior (#3744)

This commit is contained in:
Dmitry Gozman 2020-09-02 16:00:15 -07:00 committed by GitHub
parent 469541a0b9
commit 5c3bf5bf3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -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);
});

View file

@ -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();
});