docs: add a few examples for ARIA queries (#10320)

Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
This commit is contained in:
Alex Rudenko 2023-06-06 09:46:26 +02:00 committed by GitHub
parent bc0b04beef
commit 514ad107d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -121,6 +121,9 @@ ARIA selectors can be used to find elements with a given ARIA label. These label
```ts
const node = await page.waitForSelector('::-p-aria(Submit)');
const node = await page.waitForSelector(
'::-p-aria([name="Click me"][role="button"])'
);
```
### Custom selectors

View File

@ -446,6 +446,28 @@ describe('Query handler tests', function () {
).toBeTruthy();
});
it('should work ARIA selectors with role', async () => {
const {page} = getTestState();
const element = await page.$('::-p-aria(world[role="button"])');
assert(element, 'Could not find element');
expect(
await element.evaluate(element => {
return element.id === 'b';
})
).toBeTruthy();
});
it('should work ARIA selectors with name and role', async () => {
const {page} = getTestState();
const element = await page.$('::-p-aria([name="world"][role="button"])');
assert(element, 'Could not find element');
expect(
await element.evaluate(element => {
return element.id === 'b';
})
).toBeTruthy();
});
it('should work XPath selectors', async () => {
const {page} = getTestState();
const element = await page.$('div ::-p-xpath(//button)');