mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
bc0b04beef
commit
514ad107d7
@ -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
|
||||
|
@ -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)');
|
||||
|
Loading…
Reference in New Issue
Block a user