chore: follow up to getTestById, escape it (#17650)
This commit is contained in:
parent
fbef53ba6c
commit
2a85806cc0
|
|
@ -52,7 +52,7 @@ export class Locator implements api.Locator {
|
|||
}
|
||||
|
||||
static getByTestIdSelector(testId: string): string {
|
||||
return `css=[${Locator._testIdAttributeName}=${testId}]`;
|
||||
return `css=[${Locator._testIdAttributeName}=${JSON.stringify(testId)}]`;
|
||||
}
|
||||
|
||||
static getByTextSelector(text: string | RegExp, options?: { exact?: boolean }): string {
|
||||
|
|
|
|||
|
|
@ -420,3 +420,8 @@ it('getByTestId should work', async ({ page }) => {
|
|||
await expect(page.mainFrame().getByTestId('Hello')).toHaveText('Hello world');
|
||||
await expect(page.get('div').getByTestId('Hello')).toHaveText('Hello world');
|
||||
});
|
||||
|
||||
it('getByTestId should escape id', async ({ page }) => {
|
||||
await page.setContent(`<div><div data-testid='He"llo'>Hello world</div></div>`);
|
||||
await expect(page.getByTestId('He"llo')).toHaveText('Hello world');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ test('should support name', async ({ page }) => {
|
|||
<div role="button" aria-label="Hallo"></div>
|
||||
<div role="button" aria-label="Hello" aria-hidden="true"></div>
|
||||
<div role="button" aria-label="123" aria-hidden="true"></div>
|
||||
<div role="button" aria-label="foo\"bar" 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([
|
||||
`<div role="button" aria-label="Hello"></div>`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue