Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: rebase Inspector recorder api tests (#36830)

Max Schmittb4e910b909a3
diff --git a/tests/library/inspector/recorder-api.spec.ts b/tests/library/inspector/recorder-api.spec.ts
index c3feb8aca2..6459deeac7 100644
--- a/tests/library/inspector/recorder-api.spec.ts
+++ b/tests/library/inspector/recorder-api.spec.ts
@@ -46,7 +46,7 @@ function normalizeCode(code: string): string {
return code.replace(/\s+/g, ' ').trim();
}
-test('should click', async ({ context }) => {
+test('should click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button onclick="console.log('click')">Submit</button>`);
@@ -59,7 +59,8 @@ test('should click', async ({ context }) => {
name: 'click',
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
- ariaSnapshot: '- button "Submit" [active] [ref=e2]',
+ // Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
+ ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})
@@ -68,7 +69,7 @@ test('should click', async ({ context }) => {
expect(normalizeCode(clickActions[0].code)).toEqual(`await page.getByRole('button', { name: 'Submit' }).click();`);
});
-test('should double click', async ({ context }) => {
+test('should double click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button onclick="console.log('click')" ondblclick="console.log('dblclick')">Submit</button>`);
@@ -82,7 +83,8 @@ test('should double click', async ({ context }) => {
clickCount: 2,
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
- ariaSnapshot: '- button "Submit" [active] [ref=e2]',
+ // Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
+ ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})
@@ -91,7 +93,7 @@ test('should double click', async ({ context }) => {
expect(normalizeCode(clickActions[0].code)).toEqual(`await page.getByRole('button', { name: 'Submit' }).dblclick();`);
});
-test('should right click', async ({ context }) => {
+test('should right click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button oncontextmenu="console.log('contextmenu')">Submit</button>`);
@@ -105,7 +107,8 @@ test('should right click', async ({ context }) => {
button: 'right',
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
- ariaSnapshot: '- button "Submit" [active] [ref=e2]',
+ // Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
+ ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})