Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(trace): include method into "Fetch" action title (#36350)
Dmitry Gozmanf050c3fc6157
diff --git a/packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts b/packages/playwright-core/src/utils/isomorphic/protocolMetainfo.tsindex 53fc12499d..673dcd2612 100644--- a/packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts+++ b/packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts@@ -17,7 +17,7 @@// This file is generated by generate_channels.js, do not edit manually.export const methodMetainfo = new Map<string, { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean }>([- ['APIRequestContext.fetch', { title: 'Fetch "{url}"', }],+ ['APIRequestContext.fetch', { title: '{method} "{url}"', }],['APIRequestContext.fetchResponseBody', { internal: true, }],['APIRequestContext.fetchLog', { internal: true, }],['APIRequestContext.storageState', { internal: true, }],diff --git a/packages/protocol/src/protocol.yml b/packages/protocol/src/protocol.ymlindex 849bc91305..c33c381bdf 100644--- a/packages/protocol/src/protocol.yml+++ b/packages/protocol/src/protocol.yml@@ -366,7 +366,7 @@ APIRequestContext:commands:fetch:- title: Fetch "{url}"+ title: '{method} "{url}"'parameters:url: stringencodedParams: string?diff --git a/packages/trace-viewer/src/ui/actionList.tsx b/packages/trace-viewer/src/ui/actionList.tsxindex 6e86410e24..ec8d90bd7e 100644--- a/packages/trace-viewer/src/ui/actionList.tsx+++ b/packages/trace-viewer/src/ui/actionList.tsx@@ -164,7 +164,10 @@ export function renderTitleForCall(action: ActionTraceEvent): { elements: React.title.push(chunk);const param = formatProtocolParam(action.params, quotedText);- elements.push(<span className='action-title-param'>{param}</span>);+ if (match.index === 0)+ elements.push(param);+ else+ elements.push(<span className='action-title-param'>{param}</span>);title.push(param);currentIndex = match.index + fullMatch.length;}diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex 71dc0c70f6..942f89422f 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -1056,16 +1056,16 @@ test('should open two trace files', async ({ context, page, request, server, shoconst traceViewer = await showTraceViewer([contextTrace, apiTrace]);- await traceViewer.selectAction('FETCH', 0);- await traceViewer.selectAction('FETCH', 1);- await traceViewer.selectAction('FETCH', 2);+ await traceViewer.selectAction('GET');+ await traceViewer.selectAction('HEAD');+ await traceViewer.selectAction('POST');await expect(traceViewer.actionTitles).toHaveText([- /Fetch "\/simple\.json"/,+ /GET "\/simple\.json"/,/Navigate to "\/input\/button\.html"/,- /Fetch "\/simplezip\.json"/,+ /HEAD "\/simplezip\.json"/,/Click.*locator\('button'\)/,/Click.*locator\('button'\)/,- /Fetch "\/one-style\.css"/,+ /POST "\/one-style\.css"/,]);await traceViewer.page.getByRole('tab', { name: 'Metadata' }).click();diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.tsindex 1a88370e38..e1aff51bc2 100644--- a/tests/library/tracing.spec.ts+++ b/tests/library/tracing.spec.ts@@ -165,7 +165,7 @@ test('should include context API requests', async ({ context, page, server }, teawait page.request.post(server.PREFIX + '/simple.json', { data: { foo: 'bar' } });await context.tracing.stop({ path: testInfo.outputPath('trace.zip') });const { events, actions } = await parseTraceRaw(testInfo.outputPath('trace.zip'));- expect(actions).toContain('Fetch "/simple.json"');+ expect(actions).toContain('POST "/simple.json"');const harEntry = events.find(e => e.type === 'resource-snapshot');expect(harEntry).toBeTruthy();expect(harEntry.snapshot.request.url).toBe(server.PREFIX + '/simple.json');diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 08d49c00e7..745a1dee31 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -98,7 +98,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {' Fixture "page"',' Create page','Navigate to "about:blank"',- 'Fetch "/empty.html"',+ 'GET "/empty.html"','After Hooks',' Fixture "page"',' Fixture "context"',@@ -108,7 +108,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {expect(trace2.actionTree).toEqual(['Before Hooks','Create request context',- 'Fetch "/empty.html"',+ 'GET "/empty.html"','After Hooks',]);const trace3 = await parseTrace(testInfo.outputPath('test-results', 'a-fail', 'trace.zip'));@@ -121,7 +121,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {' Fixture "page"',' Create page','Navigate to "about:blank"',- 'Fetch "/empty.html"',+ 'GET "/empty.html"','Expect "toBe"','After Hooks',' Fixture "page"',@@ -328,7 +328,7 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve' afterAll hook',' Fixture "request"',' Create request context',- ' Fetch "/empty.html"',+ ' GET "/empty.html"',' Fixture "request"','Worker Cleanup',' Fixture "browser"',@@ -488,7 +488,7 @@ test(`trace:retain-on-failure should create trace if request context is disposed}, { trace: 'retain-on-failure' });const tracePath = test.info().outputPath('test-results', 'a-passing-test', 'trace.zip');const trace = await parseTrace(tracePath);- expect(trace.titles).toContain('Fetch "/empty.html"');+ expect(trace.titles).toContain('GET "/empty.html"');expect(result.failed).toBe(1);});@@ -1137,7 +1137,7 @@ test('trace:retain-on-first-failure should create trace if request context is di}, { trace: 'retain-on-first-failure' });const tracePath = test.info().outputPath('test-results', 'a-fail', 'trace.zip');const trace = await parseTrace(tracePath);- expect(trace.titles).toContain('Fetch "/empty.html"');+ expect(trace.titles).toContain('GET "/empty.html"');expect(result.failed).toBe(1);});@@ -1243,7 +1243,7 @@ test('should not nest top level expect into unfinished api calls ', {' Fixture "page"',' Create page','Navigate to "/index"',- 'Fetch "/hang"',+ 'GET "/hang"','Expect "toBeVisible"','After Hooks',' Fixture "page"',diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex fc57ad7f73..83465d8d06 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -637,7 +637,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {await page.click('text=Source');await expect(page.locator('.source-line-running')).toContainText('page.evaluate');- await page.click('.action-title >> text=FETCH');+ await page.click('.action-title >> text=GET');await page.click('text=Source');await expect(page.locator('.source-line-running')).toContainText('request.get');});@@ -668,10 +668,10 @@ for (const useIntermediateMergeReport of [true, false] as const) {await page.getByRole('link', { name: 'View Trace' }).click();// Trace viewer should not hang here when displaying parallal requests.- await expect(page.getByTestId('actions-tree')).toContainText('Fetch');- await page.getByText('Fetch').nth(2).click();- await page.getByText('Fetch').nth(1).click();- await page.getByText('Fetch').nth(0).click();+ await expect(page.getByTestId('actions-tree')).toContainText('GET');+ await page.getByText('GET').nth(2).click();+ await page.getByText('GET').nth(1).click();+ await page.getByText('GET').nth(0).click();});test('should warn user when viewing via file:// protocol', async ({ runInlineTest, page, showReport }, testInfo) => {diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.tsindex af3aa21219..2e2447dab5 100644--- a/tests/playwright-test/test-step.spec.ts+++ b/tests/playwright-test/test-step.spec.ts@@ -1222,9 +1222,9 @@ pw:api |Wait for navigation @ a.test.ts:5pw:api |Navigate to "data:" @ a.test.ts:6pw:api |Click locator('button') @ a.test.ts:8pw:api |Click getByRole('button') @ a.test.ts:9-pw:api |Fetch "/empty.html" @ a.test.ts:10+pw:api |GET "/empty.html" @ a.test.ts:10pw:api |↪ error: <error message>-pw:api |Fetch "/empty.html" @ a.test.ts:11+pw:api |GET "/empty.html" @ a.test.ts:11pw:api |↪ error: <error message>hook |After Hooksfixture | request@@ -1519,7 +1519,7 @@ fixture | pagepw:api | Create pagetest.step |custom step @ a.test.ts:4pw:api | Navigate to "/empty.html" @ a.test.ts:12-pw:api | Fetch "/empty.html" @ a.test.ts:6+pw:api | GET "/empty.html" @ a.test.ts:6expect | toBe @ a.test.ts:8hook |After Hooksfixture | page