Skip to content

Commit

Permalink
test: add tests for selectors matching root behavior (#3744)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Sep 2, 2020
1 parent 469541a commit 5c3bf5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/selectors-css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
8 changes: 8 additions & 0 deletions test/selectors-text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 5c3bf5b

Please sign in to comment.