mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore(api): remove locator.get() (#17709)
This commit is contained in:
parent
d715ad116d
commit
b4ee84fb0c
@ -887,18 +887,6 @@ await locator.ClickAsync();
|
||||
* since: v1.17
|
||||
|
||||
|
||||
## method: Frame.get
|
||||
* since: v1.27
|
||||
- returns: <[Locator]>
|
||||
|
||||
%%-template-locator-root-locator-%%
|
||||
|
||||
### param: Frame.get.selector = %%-find-selector-%%
|
||||
* since: v1.27
|
||||
### option: Frame.get.-inline- = %%-locator-options-list-v1.14-%%
|
||||
* since: v1.27
|
||||
|
||||
|
||||
## async method: Frame.getAttribute
|
||||
* since: v1.8
|
||||
- returns: <[null]|[string]>
|
||||
|
@ -114,18 +114,6 @@ in that iframe.
|
||||
* since: v1.17
|
||||
|
||||
|
||||
## method: FrameLocator.get
|
||||
* since: v1.27
|
||||
- returns: <[Locator]>
|
||||
|
||||
%%-template-locator-locator-%%
|
||||
|
||||
### param: FrameLocator.get.selector = %%-find-selector-%%
|
||||
* since: v1.27
|
||||
### option: FrameLocator.get.-inline- = %%-locator-options-list-v1.14-%%
|
||||
* since: v1.27
|
||||
|
||||
|
||||
## method: FrameLocator.getByLabelText
|
||||
* since: v1.27
|
||||
- returns: <[Locator]>
|
||||
|
@ -618,18 +618,6 @@ await locator.ClickAsync();
|
||||
* since: v1.17
|
||||
|
||||
|
||||
## method: Locator.get
|
||||
* since: v1.27
|
||||
- returns: <[Locator]>
|
||||
|
||||
%%-template-locator-locator-%%
|
||||
|
||||
### param: Locator.get.selector = %%-find-selector-%%
|
||||
* since: v1.27
|
||||
### option: Locator.get.-inline- = %%-locator-options-list-v1.14-%%
|
||||
* since: v1.27
|
||||
|
||||
|
||||
## async method: Locator.getAttribute
|
||||
* since: v1.14
|
||||
- returns: <[null]|[string]>
|
||||
|
@ -2162,18 +2162,6 @@ await locator.ClickAsync();
|
||||
|
||||
An array of all frames attached to the page.
|
||||
|
||||
## method: Page.get
|
||||
* since: v1.27
|
||||
- returns: <[Locator]>
|
||||
|
||||
%%-template-locator-root-locator-%%
|
||||
|
||||
### param: Page.get.selector = %%-find-selector-%%
|
||||
* since: v1.27
|
||||
### option: Page.get.-inline- = %%-locator-options-list-v1.14-%%
|
||||
* since: v1.27
|
||||
|
||||
|
||||
## async method: Page.getAttribute
|
||||
* since: v1.8
|
||||
- returns: <[null]|[string]>
|
||||
|
@ -299,10 +299,6 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Fr
|
||||
return new Locator(this, selector, options);
|
||||
}
|
||||
|
||||
get(selector: string, options?: LocatorOptions): Locator {
|
||||
return this.locator(selector, options);
|
||||
}
|
||||
|
||||
getByTestId(testId: string): Locator {
|
||||
return this.locator(Locator.getByTestIdSelector(testId));
|
||||
}
|
||||
|
@ -189,10 +189,6 @@ export class Locator implements api.Locator {
|
||||
return new Locator(this._frame, this._selector + ' >> ' + selector, options);
|
||||
}
|
||||
|
||||
get(selector: string, options?: LocatorOptions): Locator {
|
||||
return this.locator(selector, options);
|
||||
}
|
||||
|
||||
getByTestId(testId: string): Locator {
|
||||
return this.locator(Locator.getByTestIdSelector(testId));
|
||||
}
|
||||
@ -383,10 +379,6 @@ export class FrameLocator implements api.FrameLocator {
|
||||
return new Locator(this._frame, this._frameSelector + ' >> control=enter-frame >> ' + selector, options);
|
||||
}
|
||||
|
||||
get(selector: string, options?: LocatorOptions): Locator {
|
||||
return this.locator(selector, options);
|
||||
}
|
||||
|
||||
getByTestId(testId: string): Locator {
|
||||
return this.locator(Locator.getByTestIdSelector(testId));
|
||||
}
|
||||
|
@ -564,10 +564,6 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
|
||||
return this.mainFrame().locator(selector, options);
|
||||
}
|
||||
|
||||
get(selector: string, options?: LocatorOptions): Locator {
|
||||
return this.mainFrame().locator(selector, options);
|
||||
}
|
||||
|
||||
getByTestId(testId: string): Locator {
|
||||
return this.mainFrame().getByTestId(testId);
|
||||
}
|
||||
|
102
packages/playwright-core/types/types.d.ts
vendored
102
packages/playwright-core/types/types.d.ts
vendored
@ -2434,32 +2434,6 @@ export interface Page {
|
||||
*/
|
||||
frames(): Array<Frame>;
|
||||
|
||||
/**
|
||||
* The method returns an element locator that can be used to perform actions on this page / frame. Locator is resolved to
|
||||
* the element immediately before performing an action, so a series of actions on the same locator can in fact be performed
|
||||
* on different DOM elements. That would happen if the DOM structure between those actions has changed.
|
||||
*
|
||||
* [Learn more about locators](https://playwright.dev/docs/locators).
|
||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
* @param options
|
||||
*/
|
||||
get(selector: string, options?: {
|
||||
/**
|
||||
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
|
||||
* For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
|
||||
*
|
||||
* Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
|
||||
*/
|
||||
has?: Locator;
|
||||
|
||||
/**
|
||||
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
|
||||
* [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
|
||||
* `<article><div>Playwright</div></article>`.
|
||||
*/
|
||||
hasText?: string|RegExp;
|
||||
}): Locator;
|
||||
|
||||
/**
|
||||
* Returns element attribute value.
|
||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
@ -5494,32 +5468,6 @@ export interface Frame {
|
||||
*/
|
||||
frameLocator(selector: string): FrameLocator;
|
||||
|
||||
/**
|
||||
* The method returns an element locator that can be used to perform actions on this page / frame. Locator is resolved to
|
||||
* the element immediately before performing an action, so a series of actions on the same locator can in fact be performed
|
||||
* on different DOM elements. That would happen if the DOM structure between those actions has changed.
|
||||
*
|
||||
* [Learn more about locators](https://playwright.dev/docs/locators).
|
||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
* @param options
|
||||
*/
|
||||
get(selector: string, options?: {
|
||||
/**
|
||||
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
|
||||
* For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
|
||||
*
|
||||
* Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
|
||||
*/
|
||||
has?: Locator;
|
||||
|
||||
/**
|
||||
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
|
||||
* [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
|
||||
* `<article><div>Playwright</div></article>`.
|
||||
*/
|
||||
hasText?: string|RegExp;
|
||||
}): Locator;
|
||||
|
||||
/**
|
||||
* Returns element attribute value.
|
||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
@ -9909,31 +9857,6 @@ export interface Locator {
|
||||
*/
|
||||
frameLocator(selector: string): FrameLocator;
|
||||
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to [locator.filter([options])](https://playwright.dev/docs/api/class-locator#locator-filter) method.
|
||||
*
|
||||
* [Learn more about locators](https://playwright.dev/docs/locators).
|
||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
* @param options
|
||||
*/
|
||||
get(selector: string, options?: {
|
||||
/**
|
||||
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
|
||||
* For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
|
||||
*
|
||||
* Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
|
||||
*/
|
||||
has?: Locator;
|
||||
|
||||
/**
|
||||
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
|
||||
* [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
|
||||
* `<article><div>Playwright</div></article>`.
|
||||
*/
|
||||
hasText?: string|RegExp;
|
||||
}): Locator;
|
||||
|
||||
/**
|
||||
* Returns element attribute value.
|
||||
* @param name Attribute name to get the value for.
|
||||
@ -15152,31 +15075,6 @@ export interface FrameLocator {
|
||||
*/
|
||||
frameLocator(selector: string): FrameLocator;
|
||||
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to [locator.filter([options])](https://playwright.dev/docs/api/class-locator#locator-filter) method.
|
||||
*
|
||||
* [Learn more about locators](https://playwright.dev/docs/locators).
|
||||
* @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
|
||||
* @param options
|
||||
*/
|
||||
get(selector: string, options?: {
|
||||
/**
|
||||
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
|
||||
* For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
|
||||
*
|
||||
* Note that outer and inner locators must belong to the same frame. Inner locator must not contain [FrameLocator]s.
|
||||
*/
|
||||
has?: Locator;
|
||||
|
||||
/**
|
||||
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
|
||||
* [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
|
||||
* `<article><div>Playwright</div></article>`.
|
||||
*/
|
||||
hasText?: string|RegExp;
|
||||
}): Locator;
|
||||
|
||||
/**
|
||||
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
|
||||
* label text Password in the following DOM:
|
||||
|
@ -69,7 +69,7 @@ async function routeAmbiguous(page: Page) {
|
||||
it('should work for iframe @smoke', async ({ page, server }) => {
|
||||
await routeIframe(page);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const button = page.frameLocator('iframe').get('button');
|
||||
const button = page.frameLocator('iframe').locator('button');
|
||||
await button.waitFor();
|
||||
expect(await button.innerText()).toBe('Hello iframe');
|
||||
await expect(button).toHaveText('Hello iframe');
|
||||
@ -79,7 +79,7 @@ it('should work for iframe @smoke', async ({ page, server }) => {
|
||||
it('should work for nested iframe', async ({ page, server }) => {
|
||||
await routeIframe(page);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const button = page.frameLocator('iframe').frameLocator('iframe').get('button');
|
||||
const button = page.frameLocator('iframe').frameLocator('iframe').locator('button');
|
||||
await button.waitFor();
|
||||
expect(await button.innerText()).toBe('Hello nested iframe');
|
||||
await expect(button).toHaveText('Hello nested iframe');
|
||||
@ -89,15 +89,15 @@ it('should work for nested iframe', async ({ page, server }) => {
|
||||
it('should work for $ and $$', async ({ page, server }) => {
|
||||
await routeIframe(page);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const locator = page.frameLocator('iframe').get('button');
|
||||
const locator = page.frameLocator('iframe').locator('button');
|
||||
await expect(locator).toHaveText('Hello iframe');
|
||||
const spans = page.frameLocator('iframe').get('span');
|
||||
const spans = page.frameLocator('iframe').locator('span');
|
||||
await expect(spans).toHaveCount(2);
|
||||
});
|
||||
|
||||
it('should wait for frame', async ({ page, server }) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const error = await page.frameLocator('iframe').get('span').click({ timeout: 1000 }).catch(e => e);
|
||||
const error = await page.frameLocator('iframe').locator('span').click({ timeout: 1000 }).catch(e => e);
|
||||
expect(error.message).toContain('waiting for frame "iframe"');
|
||||
});
|
||||
|
||||
|
@ -175,8 +175,8 @@ it('should enforce same frame for has/leftOf/rightOf/above/below/near', async ({
|
||||
|
||||
it('alias methods coverage', async ({ page }) => {
|
||||
await page.setContent(`<div><button>Submit</button></div>`);
|
||||
await expect(page.get('button')).toHaveCount(1);
|
||||
await expect(page.get('div').get('button')).toHaveCount(1);
|
||||
await expect(page.get('div').getByRole('button')).toHaveCount(1);
|
||||
await expect(page.mainFrame().get('button')).toHaveCount(1);
|
||||
await expect(page.locator('button')).toHaveCount(1);
|
||||
await expect(page.locator('div').locator('button')).toHaveCount(1);
|
||||
await expect(page.locator('div').getByRole('button')).toHaveCount(1);
|
||||
await expect(page.mainFrame().locator('button')).toHaveCount(1);
|
||||
});
|
||||
|
@ -418,7 +418,7 @@ it('getByTestId should work', async ({ page }) => {
|
||||
await page.setContent('<div><div data-testid="Hello">Hello world</div></div>');
|
||||
await expect(page.getByTestId('Hello')).toHaveText('Hello world');
|
||||
await expect(page.mainFrame().getByTestId('Hello')).toHaveText('Hello world');
|
||||
await expect(page.get('div').getByTestId('Hello')).toHaveText('Hello world');
|
||||
await expect(page.locator('div').getByTestId('Hello')).toHaveText('Hello world');
|
||||
});
|
||||
|
||||
it('getByTestId should escape id', async ({ page }) => {
|
||||
|
@ -25,25 +25,25 @@ test('should detect roles', async ({ page }) => {
|
||||
<details><summary>Hello</summary></details>
|
||||
<div role="dialog">I am a dialog</div>
|
||||
`);
|
||||
expect(await page.get(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hello</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=listbox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=listbox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<select multiple="" size="2"></select>`,
|
||||
]);
|
||||
expect(await page.get(`role=combobox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=combobox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<select></select>`,
|
||||
]);
|
||||
expect(await page.get(`role=heading`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=heading`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<h3>Heading</h3>`,
|
||||
]);
|
||||
expect(await page.get(`role=group`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=group`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<details><summary>Hello</summary></details>`,
|
||||
]);
|
||||
expect(await page.get(`role=dialog`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=dialog`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="dialog">I am a dialog</div>`,
|
||||
]);
|
||||
expect(await page.get(`role=menuitem`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=menuitem`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
]);
|
||||
expect(await page.getByRole('menuitem').evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
]);
|
||||
@ -60,12 +60,12 @@ test('should support selected', async ({ page }) => {
|
||||
<div role="option" aria-selected="false">Hello</div>
|
||||
</div>
|
||||
`);
|
||||
expect(await page.get(`role=option[selected]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=option[selected]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<option selected="">Hello</option>`,
|
||||
`<div role="option" aria-selected="true">Hi</div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=option[selected=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=option[selected=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<option selected="">Hello</option>`,
|
||||
`<div role="option" aria-selected="true">Hi</div>`,
|
||||
]);
|
||||
@ -74,7 +74,7 @@ test('should support selected', async ({ page }) => {
|
||||
`<div role="option" aria-selected="true">Hi</div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=option[selected=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=option[selected=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<option>Hi</option>`,
|
||||
`<div role="option" aria-selected="false">Hello</div>`,
|
||||
]);
|
||||
@ -95,11 +95,11 @@ test('should support checked', async ({ page }) => {
|
||||
`);
|
||||
await page.$eval('[indeterminate]', input => (input as HTMLInputElement).indeterminate = true);
|
||||
|
||||
expect(await page.get(`role=checkbox[checked]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=checkbox[checked]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<input type="checkbox" checked="">`,
|
||||
`<div role="checkbox" aria-checked="true">Hi</div>`,
|
||||
]);
|
||||
expect(await page.get(`role=checkbox[checked=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=checkbox[checked=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<input type="checkbox" checked="">`,
|
||||
`<div role="checkbox" aria-checked="true">Hi</div>`,
|
||||
]);
|
||||
@ -108,7 +108,7 @@ test('should support checked', async ({ page }) => {
|
||||
`<div role="checkbox" aria-checked="true">Hi</div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=checkbox[checked=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=checkbox[checked=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<input type="checkbox">`,
|
||||
`<div role="checkbox" aria-checked="false">Hello</div>`,
|
||||
`<div role="checkbox">Unknown</div>`,
|
||||
@ -119,10 +119,10 @@ test('should support checked', async ({ page }) => {
|
||||
`<div role="checkbox">Unknown</div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=checkbox[checked="mixed"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=checkbox[checked="mixed"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<input type="checkbox" indeterminate="">`,
|
||||
]);
|
||||
expect(await page.get(`role=checkbox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=checkbox`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<input type="checkbox">`,
|
||||
`<input type="checkbox" checked="">`,
|
||||
`<input type="checkbox" indeterminate="">`,
|
||||
@ -139,16 +139,16 @@ test('should support pressed', async ({ page }) => {
|
||||
<button aria-pressed="false">Bye</button>
|
||||
<button aria-pressed="mixed">Mixed</button>
|
||||
`);
|
||||
expect(await page.get(`role=button[pressed]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[pressed]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-pressed="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[pressed=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[pressed=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-pressed="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.getByRole('button', { pressed: true }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-pressed="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[pressed=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[pressed=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-pressed="false">Bye</button>`,
|
||||
]);
|
||||
@ -156,10 +156,10 @@ test('should support pressed', async ({ page }) => {
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-pressed="false">Bye</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[pressed="mixed"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[pressed="mixed"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-pressed="mixed">Mixed</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-pressed="true">Hello</button>`,
|
||||
`<button aria-pressed="false">Bye</button>`,
|
||||
@ -173,16 +173,16 @@ test('should support expanded', async ({ page }) => {
|
||||
<button aria-expanded="true">Hello</button>
|
||||
<button aria-expanded="false">Bye</button>
|
||||
`);
|
||||
expect(await page.get(`role=button[expanded]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[expanded]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-expanded="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[expanded=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[expanded=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-expanded="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.getByRole('button', { expanded: true }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button aria-expanded="true">Hello</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[expanded=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[expanded=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-expanded="false">Bye</button>`,
|
||||
]);
|
||||
@ -202,12 +202,12 @@ test('should support disabled', async ({ page }) => {
|
||||
<button>Yay</button>
|
||||
</fieldset>
|
||||
`);
|
||||
expect(await page.get(`role=button[disabled]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[disabled]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button disabled="">Bye</button>`,
|
||||
`<button aria-disabled="true">Hello</button>`,
|
||||
`<button>Yay</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[disabled=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[disabled=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button disabled="">Bye</button>`,
|
||||
`<button aria-disabled="true">Hello</button>`,
|
||||
`<button>Yay</button>`,
|
||||
@ -217,7 +217,7 @@ test('should support disabled', async ({ page }) => {
|
||||
`<button aria-disabled="true">Hello</button>`,
|
||||
`<button>Yay</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[disabled=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[disabled=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-disabled="false">Oh</button>`,
|
||||
]);
|
||||
@ -233,19 +233,19 @@ test('should support level', async ({ page }) => {
|
||||
<h3>Hi</h3>
|
||||
<div role="heading" aria-level="5">Bye</div>
|
||||
`);
|
||||
expect(await page.get(`role=heading[level=1]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=heading[level=1]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<h1>Hello</h1>`,
|
||||
]);
|
||||
expect(await page.getByRole('heading', { level: 1 }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<h1>Hello</h1>`,
|
||||
]);
|
||||
expect(await page.get(`role=heading[level=3]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=heading[level=3]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<h3>Hi</h3>`,
|
||||
]);
|
||||
expect(await page.getByRole('heading', { level: 3 }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<h3>Hi</h3>`,
|
||||
]);
|
||||
expect(await page.get(`role=heading[level=5]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=heading[level=5]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="heading" aria-level="5">Bye</div>`,
|
||||
]);
|
||||
});
|
||||
@ -277,13 +277,13 @@ test('should filter hidden, unless explicitly asked for', async ({ page }) => {
|
||||
addButton(document.getElementById('host2'), 'Shadow2');
|
||||
</script>
|
||||
`);
|
||||
expect(await page.get(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-hidden="false">Nay</button>`,
|
||||
`<button style="visibility:visible">Still here</button>`,
|
||||
`<button>Shadow1</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button hidden="">Hello</button>`,
|
||||
`<button aria-hidden="true">Yay</button>`,
|
||||
@ -295,7 +295,7 @@ test('should filter hidden, unless explicitly asked for', async ({ page }) => {
|
||||
`<button>Shadow1</button>`,
|
||||
`<button>Shadow2</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[include-hidden=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[include-hidden=true]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button hidden="">Hello</button>`,
|
||||
`<button aria-hidden="true">Yay</button>`,
|
||||
@ -307,7 +307,7 @@ test('should filter hidden, unless explicitly asked for', async ({ page }) => {
|
||||
`<button>Shadow1</button>`,
|
||||
`<button>Shadow2</button>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[include-hidden=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[include-hidden=false]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<button>Hi</button>`,
|
||||
`<button aria-hidden="false">Nay</button>`,
|
||||
`<button style="visibility:visible">Still here</button>`,
|
||||
@ -323,18 +323,18 @@ test('should support name', async ({ page }) => {
|
||||
<div role="button" aria-label="123" aria-hidden="true"></div>
|
||||
<div role="button" aria-label='foo"bar' aria-hidden="true"></div>
|
||||
`);
|
||||
expect(await page.get(`role=button[name="Hello"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name="Hello"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
]);
|
||||
expect(await page.getByRole('button', { name: 'Hello' }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=button[name*="all"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name*="all"]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hallo"></div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=button[name=/^H[ae]llo$/]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name=/^H[ae]llo$/]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
`<div role="button" aria-label="Hallo"></div>`,
|
||||
]);
|
||||
@ -343,7 +343,7 @@ test('should support name', async ({ page }) => {
|
||||
`<div role="button" aria-label="Hallo"></div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=button[name=/h.*o/i]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name=/h.*o/i]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
`<div role="button" aria-label="Hallo"></div>`,
|
||||
]);
|
||||
@ -352,7 +352,7 @@ test('should support name', async ({ page }) => {
|
||||
`<div role="button" aria-label="Hallo"></div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=button[name="Hello"][include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name="Hello"][include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
`<div role="button" aria-label="Hello" aria-hidden="true"></div>`,
|
||||
]);
|
||||
@ -361,10 +361,10 @@ test('should support name', async ({ page }) => {
|
||||
`<div role="button" aria-label="Hello" aria-hidden="true"></div>`,
|
||||
]);
|
||||
|
||||
expect(await page.get(`role=button[name=Hello]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name=Hello]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
]);
|
||||
expect(await page.get(`role=button[name=123][include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
expect(await page.locator(`role=button[name=123][include-hidden]`).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
`<div role="button" aria-label="123" aria-hidden="true"></div>`,
|
||||
]);
|
||||
expect(await page.getByRole('button', { name: '123', includeHidden: true }).evaluateAll(els => els.map(e => e.outerHTML))).toEqual([
|
||||
|
@ -460,5 +460,5 @@ it('getByLabelText should work', async ({ page, asset }) => {
|
||||
expect(await page.getByText('Name').evaluate(e => e.nodeName)).toBe('LABEL');
|
||||
expect(await page.getByLabelText('Name').evaluate(e => e.nodeName)).toBe('INPUT');
|
||||
expect(await page.mainFrame().getByLabelText('Name').evaluate(e => e.nodeName)).toBe('INPUT');
|
||||
expect(await page.get('div').getByLabelText('Name').evaluate(e => e.nodeName)).toBe('INPUT');
|
||||
expect(await page.locator('div').getByLabelText('Name').evaluate(e => e.nodeName)).toBe('INPUT');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user