diff --git a/dev-packages/browser-integration-tests/package.json b/dev-packages/browser-integration-tests/package.json index 31a660b2a8c7..4f8ed780d68d 100644 --- a/dev-packages/browser-integration-tests/package.json +++ b/dev-packages/browser-integration-tests/package.json @@ -9,13 +9,14 @@ "private": true, "scripts": { "clean": "rimraf -g suites/**/dist loader-suites/**/dist tmp", - "install-browsers": "playwright install --with-deps", + "install-browsers": "npx playwright install --with-deps", "lint": "eslint . --format stylish", "fix": "eslint . --format stylish --fix", "type-check": "tsc", + "postinstall": "yarn install-browsers", "pretest": "yarn clean && yarn type-check", - "test": "playwright test ./suites --project='chromium'", - "test:all": "playwright test ./suites", + "test": "yarn test:all --project='chromium'", + "test:all": "npx playwright test -c playwright.browser.config.ts", "test:bundle:es5": "PW_BUNDLE=bundle_es5 yarn test", "test:bundle:es5:min": "PW_BUNDLE=bundle_es5_min yarn test", "test:bundle:es6": "PW_BUNDLE=bundle_es6 yarn test", @@ -30,21 +31,21 @@ "test:bundle:tracing:replay:es6:min": "PW_BUNDLE=bundle_tracing_replay_es6_min yarn test", "test:cjs": "PW_BUNDLE=cjs yarn test", "test:esm": "PW_BUNDLE=esm yarn test", - "test:loader": "playwright test ./loader-suites --project='chromium'", + "test:loader": "npx playwright test -c playwright.loader.config.ts --project='chromium'", "test:loader:base": "PW_BUNDLE=loader_base yarn test:loader", "test:loader:eager": "PW_BUNDLE=loader_eager yarn test:loader", "test:loader:tracing": "PW_BUNDLE=loader_tracing yarn test:loader", "test:loader:replay": "PW_BUNDLE=loader_replay yarn test:loader", "test:loader:full": "PW_BUNDLE=loader_tracing_replay yarn test:loader", "test:loader:debug": "PW_BUNDLE=loader_debug yarn test:loader", - "test:ci": "playwright test ./suites --reporter='line'", + "test:ci": "yarn test:all --reporter='line'", "test:update-snapshots": "yarn test:all --update-snapshots", "test:detect-flaky": "ts-node scripts/detectFlakyTests.ts", "validate:es5": "es-check es5 'fixtures/loader.js'" }, "dependencies": { "@babel/preset-typescript": "^7.16.7", - "@playwright/test": "^1.31.1", + "@playwright/test": "^1.40.1", "@sentry-internal/rrweb": "2.9.0", "@sentry/browser": "7.97.0", "@sentry/tracing": "7.97.0", @@ -52,7 +53,6 @@ "babel-loader": "^8.2.2", "html-webpack-plugin": "^5.5.0", "pako": "^2.1.0", - "playwright": "^1.31.1", "webpack": "^5.52.0" }, "devDependencies": { diff --git a/dev-packages/browser-integration-tests/playwright.browser.config.ts b/dev-packages/browser-integration-tests/playwright.browser.config.ts new file mode 100644 index 000000000000..dd48c8f54746 --- /dev/null +++ b/dev-packages/browser-integration-tests/playwright.browser.config.ts @@ -0,0 +1,9 @@ +import type { PlaywrightTestConfig } from '@playwright/test'; +import CorePlaywrightConfig from './playwright.config'; + +const config: PlaywrightTestConfig = { + ...CorePlaywrightConfig, + testDir: './suites', +}; + +export default config; diff --git a/dev-packages/browser-integration-tests/playwright.config.ts b/dev-packages/browser-integration-tests/playwright.config.ts index 05d0ada178ae..91568658d316 100644 --- a/dev-packages/browser-integration-tests/playwright.config.ts +++ b/dev-packages/browser-integration-tests/playwright.config.ts @@ -8,6 +8,7 @@ const config: PlaywrightTestConfig = { // Use 3 workers on CI, else use defaults (based on available CPU cores) // Note that 3 is a random number selected to work well with our CI setup workers: process.env.CI ? 3 : undefined, + testMatch: /test.ts/, projects: [ { diff --git a/dev-packages/browser-integration-tests/playwright.loader.config.ts b/dev-packages/browser-integration-tests/playwright.loader.config.ts new file mode 100644 index 000000000000..01a829fbba3a --- /dev/null +++ b/dev-packages/browser-integration-tests/playwright.loader.config.ts @@ -0,0 +1,9 @@ +import type { PlaywrightTestConfig } from '@playwright/test'; +import CorePlaywrightConfig from './playwright.config'; + +const config: PlaywrightTestConfig = { + ...CorePlaywrightConfig, + testDir: './loader-suites', +}; + +export default config; diff --git a/dev-packages/browser-integration-tests/scripts/detectFlakyTests.ts b/dev-packages/browser-integration-tests/scripts/detectFlakyTests.ts index 8059b4841176..299ebb002692 100644 --- a/dev-packages/browser-integration-tests/scripts/detectFlakyTests.ts +++ b/dev-packages/browser-integration-tests/scripts/detectFlakyTests.ts @@ -43,7 +43,7 @@ ${changedPaths.join('\n')} try { await new Promise((resolve, reject) => { const cp = childProcess.spawn( - `yarn playwright test ${ + `npx playwright test ${ testPaths.length ? testPaths.join(' ') : './suites' } --reporter='line' --repeat-each ${runCount}`, { shell: true, cwd }, diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts index 37ac97c633ca..a9f4a335c4e4 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts @@ -4,62 +4,58 @@ import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../../utils/fixtures'; import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers'; -sentryTest( - 'captures Breadcrumb for clicks & debounces them for a second', - async ({ getLocalTestUrl, page, browserName }) => { - sentryTest.skip(browserName === 'chromium', 'This consistently flakes on chrome.'); - - const url = await getLocalTestUrl({ testDir: __dirname }); - - await page.route('**/foo', route => { - return route.fulfill({ - status: 200, - body: JSON.stringify({ - userNames: ['John', 'Jane'], - }), - headers: { - 'Content-Type': 'application/json', - }, - }); - }); - - const promise = getFirstSentryEnvelopeRequest(page); - - await page.goto(url); - - await page.click('#button1'); - // not debounced because other target - await page.click('#button2'); - // This should be debounced - await page.click('#button2'); - - // Wait a second for the debounce to finish - await page.waitForTimeout(1000); - await page.click('#button2'); - - const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]); - - expect(eventData.exception?.values).toHaveLength(1); - - expect(eventData.breadcrumbs).toEqual([ - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button1[type="button"]', - }, - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button2[type="button"]', - }, - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > button#button2[type="button"]', +sentryTest('captures Breadcrumb for clicks & debounces them for a second', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + + await page.route('**/foo', route => { + return route.fulfill({ + status: 200, + body: JSON.stringify({ + userNames: ['John', 'Jane'], + }), + headers: { + 'Content-Type': 'application/json', }, - ]); - }, -); + }); + }); + + const promise = getFirstSentryEnvelopeRequest(page); + + await page.goto(url); + + await page.locator('#button1').click(); + + // not debounced because other target + await page.locator('#button2').click(); + // This should be debounced + await page.locator('#button2').click(); + + // Wait a second for the debounce to finish + await page.waitForTimeout(1000); + await page.locator('#button2').click(); + + const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]); + + expect(eventData.exception?.values).toHaveLength(1); + + expect(eventData.breadcrumbs).toEqual([ + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button1[type="button"]', + }, + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button2[type="button"]', + }, + { + timestamp: expect.any(Number), + category: 'ui.click', + message: 'body > button#button2[type="button"]', + }, + ]); +}); sentryTest( 'uses the annotated component name in the breadcrumb messages and adds it to the data object', @@ -81,7 +77,7 @@ sentryTest( const promise = getFirstSentryEnvelopeRequest(page); await page.goto(url); - await page.click('#annotated-button'); + await page.locator('#annotated-button').click(); await page.evaluate('Sentry.captureException("test exception")'); const eventData = await promise; diff --git a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts index 3a25abb1f9fe..b4549a105c7a 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts @@ -23,17 +23,18 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({ await page.goto(url); - await page.click('#input1'); // Not debounced because other event type - await page.type('#input1', 'John', { delay: 1 }); + await page.locator('#input1').pressSequentially('John', { delay: 1 }); + // This should be debounced - await page.type('#input1', 'Abby', { delay: 1 }); + await page.locator('#input1').pressSequentially('Abby', { delay: 1 }); + // not debounced because other target - await page.type('#input2', 'Anne', { delay: 1 }); + await page.locator('#input2').pressSequentially('Anne', { delay: 1 }); // Wait a second for the debounce to finish await page.waitForTimeout(1000); - await page.type('#input2', 'John', { delay: 1 }); + await page.locator('#input2').pressSequentially('John', { delay: 1 }); await page.evaluate('Sentry.captureException("test exception")'); @@ -42,11 +43,6 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({ expect(eventData.exception?.values).toHaveLength(1); expect(eventData.breadcrumbs).toEqual([ - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > input#input1[type="text"]', - }, { timestamp: expect.any(Number), category: 'ui.input', @@ -86,20 +82,13 @@ sentryTest( await page.goto(url); - await page.click('#annotated-input'); - await page.type('#annotated-input', 'John', { delay: 1 }); + await page.locator('#annotated-input').pressSequentially('John', { delay: 1 }); await page.evaluate('Sentry.captureException("test exception")'); const eventData = await promise; expect(eventData.exception?.values).toHaveLength(1); expect(eventData.breadcrumbs).toEqual([ - { - timestamp: expect.any(Number), - category: 'ui.click', - message: 'body > AnnotatedInput', - data: { 'ui.component_name': 'AnnotatedInput' }, - }, { timestamp: expect.any(Number), category: 'ui.input', diff --git a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts index c1521bfe16ec..157e4d163067 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts @@ -19,7 +19,7 @@ sentryTest( const eventReqPromise = waitForErrorRequestOnUrl(page, url); - const clickPromise = page.click('#inline-error-btn'); + const clickPromise = page.locator('#inline-error-btn').click(); const [req] = await Promise.all([eventReqPromise, clickPromise]); diff --git a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts index cd90d8477080..522c895d7b2e 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts @@ -8,7 +8,7 @@ sentryTest('should not add source context lines to errors from script files', as const eventReqPromise = waitForErrorRequestOnUrl(page, url); - const clickPromise = page.click('#script-error-btn'); + const clickPromise = page.locator('#script-error-btn').click(); const [req] = await Promise.all([eventReqPromise, clickPromise]); diff --git a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts index f66208a87d4d..7f974b9d55c3 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts @@ -19,7 +19,7 @@ sentryTest( const eventReqPromise = waitForErrorRequestOnUrl(page, url); - const clickPromise = page.click('#inline-error-btn'); + const clickPromise = page.locator('#inline-error-btn').click(); const [req] = await Promise.all([eventReqPromise, clickPromise]); diff --git a/dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts b/dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts index 1ff15a3d3ff2..1ed90b81b37a 100644 --- a/dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts @@ -48,8 +48,8 @@ sentryTest( const url = await getLocalTestPath({ testDir: __dirname }); await page.goto(url); - await page.click('#go-background'); - await page.click('#error'); + await page.locator('#go-background').click(); + await page.locator('#error').click(); await new Promise(resolve => setTimeout(resolve, 1000)); // error, no replays @@ -76,9 +76,9 @@ sentryTest( }), ).toBe(true); - await page.click('#log'); - await page.click('#go-background'); - await page.click('#error2'); + await page.locator('#log').click(); + await page.locator('#go-background').click(); + await page.locator('#error2').click(); await new Promise(resolve => setTimeout(resolve, 1000)); // 2 errors @@ -98,8 +98,8 @@ sentryTest( await reqErrorPromise; expect(callsToSentry).toBeGreaterThanOrEqual(3); - await page.click('#log'); - await page.click('#go-background'); + await page.locator('#log').click(); + await page.locator('#go-background').click(); // Switches to session mode and then goes to background const req1 = await reqPromise1; @@ -193,8 +193,8 @@ sentryTest( const url = await getLocalTestPath({ testDir: __dirname }); await page.goto(url); - await page.click('#go-background'); - await page.click('#error'); + await page.locator('#go-background').click(); + await page.locator('#error').click(); await new Promise(resolve => setTimeout(resolve, 1000)); // error, no replays @@ -221,9 +221,9 @@ sentryTest( }), ).toBe(true); - await page.click('#log'); - await page.click('#go-background'); - await page.click('#error2'); + await page.locator('#log').click(); + await page.locator('#go-background').click(); + await page.locator('#error2').click(); await new Promise(resolve => setTimeout(resolve, 1000)); // 2 errors @@ -243,8 +243,8 @@ sentryTest( await reqErrorPromise; expect(callsToSentry).toEqual(3); - await page.click('#log'); - await page.click('#go-background'); + await page.locator('#log').click(); + await page.locator('#go-background').click(); // Has stopped recording, should make no more calls to Sentry expect(callsToSentry).toEqual(3); @@ -336,8 +336,8 @@ sentryTest( }), ).toBe(true); - await page.click('#go-background'); - await page.click('#error'); + await page.locator('#go-background').click(); + await page.locator('#error').click(); await new Promise(resolve => setTimeout(resolve, 1000)); // 1 unsampled error, no replay @@ -357,7 +357,7 @@ sentryTest( const [req0] = await Promise.all([ // 1 unsampled error, 1 sampled error -> 1 flush reqPromise0, - page.click('#error2'), + page.locator('#error2').click(), ]); const reqError1 = await reqErrorPromise1; diff --git a/dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts b/dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts index 95e2bf399592..79fc60497ccc 100644 --- a/dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts @@ -28,7 +28,7 @@ sentryTest('continues buffer session in session mode after error & reload', asyn await page.goto(url); // buffer session captures an error & switches to session mode - await page.click('#buttonError'); + await page.locator('#buttonError').click(); await new Promise(resolve => setTimeout(resolve, 300)); await reqPromise1; diff --git a/dev-packages/browser-integration-tests/suites/replay/captureConsoleLog/test.ts b/dev-packages/browser-integration-tests/suites/replay/captureConsoleLog/test.ts index d7052b1384ad..d773cd553c05 100644 --- a/dev-packages/browser-integration-tests/suites/replay/captureConsoleLog/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/captureConsoleLog/test.ts @@ -34,10 +34,10 @@ sentryTest('should capture console messages in replay', async ({ getLocalTestPat 5_000, ); - await page.click('[data-log]'); + await page.locator('[data-log]').click(); // Sometimes this doesn't seem to trigger, so we trigger it twice to be sure... - const [req1] = await Promise.all([reqPromise1, page.click('[data-log]')]); + const [req1] = await Promise.all([reqPromise1, page.locator('[data-log]').click()]); await forceFlushReplay(); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -87,7 +87,7 @@ sentryTest('should capture very large console logs', async ({ getLocalTestPath, 5_000, ); - const [req1] = await Promise.all([reqPromise1, page.click('[data-log-large]')]); + const [req1] = await Promise.all([reqPromise1, page.locator('[data-log-large]').click()]); await forceFlushReplay(); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts b/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts index 421e725bb3e4..f5634036dc13 100644 --- a/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts @@ -25,7 +25,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT await page.goto(url); const replayEvent0 = getReplayEvent(await reqPromise0); - await page.click('button'); + await page.locator('button').click(); const replayEvent1 = getReplayEvent(await reqPromise1); expect(replayEvent0).toBeDefined(); diff --git a/dev-packages/browser-integration-tests/suites/replay/customEvents/template.html b/dev-packages/browser-integration-tests/suites/replay/customEvents/template.html index 62f0454d4db4..d4aa8cc643b3 100644 --- a/dev-packages/browser-integration-tests/suites/replay/customEvents/template.html +++ b/dev-packages/browser-integration-tests/suites/replay/customEvents/template.html @@ -5,7 +5,7 @@
An Error
- diff --git a/dev-packages/browser-integration-tests/suites/replay/customEvents/test.ts b/dev-packages/browser-integration-tests/suites/replay/customEvents/test.ts index 78fbca08d4cd..41c90d94ffdf 100644 --- a/dev-packages/browser-integration-tests/suites/replay/customEvents/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/customEvents/test.ts @@ -47,7 +47,7 @@ sentryTest( expect(replayEvent0).toEqual(getExpectedReplayEvent({ segment_id: 0 })); - await page.click('button'); + await page.locator('#img-button').click(); const replayEvent1 = getReplayEvent(await reqPromise1); const { performanceSpans: performanceSpans1 } = getCustomRecordingEvents(await reqPromise1); @@ -104,7 +104,7 @@ sentryTest( await page.goto(url); await reqPromise0; - await page.click('#error'); + await page.locator('#error').click(); await forceFlushReplay(); const req1 = await reqPromise1; const content1 = getReplayRecordingContent(req1); @@ -131,7 +131,7 @@ sentryTest( ]), ); - await page.click('#img'); + await page.locator('#img').click(); await forceFlushReplay(); const req2 = await reqPromise2; const content2 = getReplayRecordingContent(req2); @@ -139,11 +139,12 @@ sentryTest( expect.arrayContaining([ { ...expectedClickBreadcrumb, - message: 'body > button[title="Button title"]', + message: 'body > button#img-button[title="Button title"]', data: { nodeId: expect.any(Number), node: { attributes: { + id: 'img-button', title: '****** *****', }, id: expect.any(Number), @@ -155,7 +156,7 @@ sentryTest( ]), ); - await page.click('.sentry-unmask'); + await page.locator('.sentry-unmask').click(); await forceFlushReplay(); const req3 = await reqPromise3; const content3 = getReplayRecordingContent(req3); @@ -206,7 +207,7 @@ sentryTest( await page.goto(url); await forceFlushReplay(); - await page.click('#error'); + await page.locator('#error').click(); await forceFlushReplay(); const req0 = await reqPromise0; diff --git a/dev-packages/browser-integration-tests/suites/replay/errorResponse/test.ts b/dev-packages/browser-integration-tests/suites/replay/errorResponse/test.ts index 2037f67c4530..70887ef2b9f6 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errorResponse/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errorResponse/test.ts @@ -26,7 +26,7 @@ sentryTest('should stop recording after receiving an error response', async ({ g await page.goto(url); await waitForReplayRequest(page); - await page.click('button'); + await page.locator('button').click(); expect(called).toBe(1); diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/beforeErrorSampling/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/beforeErrorSampling/test.ts index 1f42c14e80ad..cbb4826df195 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/beforeErrorSampling/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/beforeErrorSampling/test.ts @@ -24,7 +24,7 @@ sentryTest( await page.goto(url); await waitForReplayRunning(page); - await page.click('#drop'); + await page.locator('#drop').click(); await forceFlushReplay(); expect(await getReplaySnapshot(page)).toEqual( diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/droppedError/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/droppedError/test.ts index 9698326a082f..04503ca52cb7 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/droppedError/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/droppedError/test.ts @@ -34,9 +34,9 @@ sentryTest( await forceFlushReplay(); expect(callsToSentry).toEqual(0); - await page.click('#error'); + await page.locator('#error').click(); - await page.click('#log'); + await page.locator('#log').click(); await forceFlushReplay(); expect(callsToSentry).toEqual(0); diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts index 4bb4c45ae978..b2f7e067e969 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts @@ -52,23 +52,23 @@ sentryTest( await Promise.all([ page.goto(url), - page.click('#go-background'), + page.locator('#go-background').click(), new Promise(resolve => setTimeout(resolve, 1000)), ]); expect(callsToSentry).toEqual(0); - const [req0] = await Promise.all([reqPromise0, page.click('#error')]); + const [req0] = await Promise.all([reqPromise0, page.locator('#error').click()]); expect(callsToSentry).toEqual(2); // 1 error, 1 replay event - const [req1] = await Promise.all([reqPromise1, page.click('#go-background'), reqErrorPromise]); + const [req1] = await Promise.all([reqPromise1, page.locator('#go-background').click(), reqErrorPromise]); expect(callsToSentry).toEqual(3); // 1 error, 2 replay events - await page.click('#log'); + await page.locator('#log').click(); - const [req2] = await Promise.all([reqPromise2, page.click('#go-background')]); + const [req2] = await Promise.all([reqPromise2, page.locator('#go-background').click()]); const event0 = getReplayEvent(req0); const content0 = getReplayRecordingContent(req0); diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts index 8efe303afb88..81ff9f06cc78 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts @@ -30,7 +30,7 @@ sentryTest( await forceFlushReplay(); expect(callsToSentry).toEqual(0); - await page.click('#error'); + await page.locator('#error').click(); await promiseReq0; await forceFlushReplay(); diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/errorNotSent/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/errorNotSent/test.ts index 89c6d0342983..c47f4bf4e105 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/errorNotSent/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/errorNotSent/test.ts @@ -27,9 +27,9 @@ sentryTest( await forceFlushReplay(); expect(callsToSentry).toEqual(0); - await page.click('#error'); + await page.locator('#error').click(); - await page.click('#log'); + await page.locator('#log').click(); await forceFlushReplay(); // Only sent once, but since API failed we do not go into session mode diff --git a/dev-packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts b/dev-packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts index 603758c95409..5fb1e7b4e340 100644 --- a/dev-packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts @@ -42,7 +42,7 @@ sentryTest( await page.goto(url); const req0 = await reqPromise0; - await page.click('#error'); + await page.locator('#error').click(); await forceFlushReplay(); const req1 = await reqPromise1; @@ -107,7 +107,7 @@ sentryTest( await page.goto(url); await reqPromise0; - await page.click('#drop'); + await page.locator('#drop').click(); await forceFlushReplay(); const req1 = await reqPromise1; diff --git a/dev-packages/browser-integration-tests/suites/replay/eventBufferError/test.ts b/dev-packages/browser-integration-tests/suites/replay/eventBufferError/test.ts index 639df9d91401..a6924bdda3c9 100644 --- a/dev-packages/browser-integration-tests/suites/replay/eventBufferError/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/eventBufferError/test.ts @@ -73,8 +73,8 @@ window.Replay._replay.eventBuffer.addEvent = (...args) => { }; `); - void page.click('#button1'); - void page.click('#button2'); + void page.locator('#button1').click(); + void page.locator('#button2').click(); // Should immediately skip retrying and just cancel, no backoff // This waitForTimeout call should be okay, as we're not checking for any diff --git a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts index 8c119390eadc..d1cc0a58e118 100644 --- a/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/extendNetworkBreadcrumbs/fetch/captureRequestHeaders/test.ts @@ -270,6 +270,7 @@ sentryTest('captures request headers as Headers instance', async ({ getLocalTest const replayRequestPromise1 = waitForReplayRequest(page, 0); const url = await getLocalTestPath({ testDir: __dirname }); + await page.goto(url); await page.evaluate(() => { diff --git a/dev-packages/browser-integration-tests/suites/replay/flushing/test.ts b/dev-packages/browser-integration-tests/suites/replay/flushing/test.ts index 2d57da3b4d30..91308d7736c8 100644 --- a/dev-packages/browser-integration-tests/suites/replay/flushing/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/flushing/test.ts @@ -36,7 +36,7 @@ sentryTest('replay events are flushed after max flush delay was reached', async expect(replayEvent0).toEqual(getExpectedReplayEvent()); // trigger one mouse click - void page.click('#something'); + void page.locator('#something').click(); // this must eventually lead to a flush after the max delay was reached const replayEvent1 = getReplayEvent(await reqPromise1); @@ -46,7 +46,7 @@ sentryTest('replay events are flushed after max flush delay was reached', async for (let i = 0; i < 700; i++) { setTimeout(async () => { try { - await page.click('#something'); + await page.locator('#something').click(); } catch { // ignore errors here, we don't care if the page is closed } diff --git a/dev-packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts b/dev-packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts index 2c8665ac93b6..948c3bb4ea41 100644 --- a/dev-packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts @@ -23,7 +23,7 @@ sentryTest( // We have to click in order to ensure the LCP is generated, leading to consistent results async function gotoPageAndClick() { await page.goto(url); - await page.click('#noop'); + await page.locator('#noop').click(); } const [res0] = await Promise.all([waitForReplayRequest(page, 0), gotoPageAndClick()]); await forceFlushReplay(); @@ -33,7 +33,7 @@ sentryTest( const parsed = getReplayRecordingContent(res); return !!parsed.incrementalSnapshots.length || !!parsed.fullSnapshots.length; }), - page.click('#button-add'), + page.locator('#button-add').click(), forceFlushReplay(), ]); @@ -42,7 +42,7 @@ sentryTest( const parsed = getReplayRecordingContent(res); return !!parsed.incrementalSnapshots.length || !!parsed.fullSnapshots.length; }), - page.click('#button-modify'), + page.locator('#button-modify').click(), forceFlushReplay(), ]); @@ -51,7 +51,7 @@ sentryTest( const parsed = getReplayRecordingContent(res); return !!parsed.incrementalSnapshots.length || !!parsed.fullSnapshots.length; }), - page.click('#button-remove'), + page.locator('#button-remove').click(), forceFlushReplay(), ]); diff --git a/dev-packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts b/dev-packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts index faa03431bdbd..672190e2d0a0 100644 --- a/dev-packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts @@ -28,7 +28,7 @@ sentryTest( // We have to click in order to ensure the LCP is generated, leading to consistent results async function gotoPageAndClick() { await page.goto(url); - await page.click('#noop'); + await page.locator('#noop').click(); } const [res0] = await Promise.all([waitForReplayRequest(page, 0), gotoPageAndClick()]); @@ -39,7 +39,7 @@ sentryTest( const parsed = getReplayRecordingContent(res); return !!parsed.incrementalSnapshots.length || !!parsed.fullSnapshots.length; }), - page.click('#button-add'), + page.locator('#button-add').click(), forceFlushReplay(), ]); @@ -48,10 +48,10 @@ sentryTest( expect(replay.session).toBe(undefined); expect(replay._isEnabled).toBe(false); - await page.click('#button-modify'); + await page.locator('#button-modify').click(); await forceFlushReplay(); - await page.click('#button-remove'); + await page.locator('#button-remove').click(); await forceFlushReplay(); const replayData0 = getReplayRecordingContent(res0); diff --git a/dev-packages/browser-integration-tests/suites/replay/maxReplayDuration/test.ts b/dev-packages/browser-integration-tests/suites/replay/maxReplayDuration/test.ts index 2890f58691b5..a133f7ae77d9 100644 --- a/dev-packages/browser-integration-tests/suites/replay/maxReplayDuration/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/maxReplayDuration/test.ts @@ -28,7 +28,7 @@ sentryTest('keeps track of max duration across reloads', async ({ getLocalTestPa await new Promise(resolve => setTimeout(resolve, MAX_REPLAY_DURATION / 2)); - await Promise.all([page.reload(), page.click('#button1')]); + await Promise.all([page.reload(), page.locator('#button1').click()]); // After the second reload, we should have a new session (because we exceeded max age) const reqPromise3 = waitForReplayRequest(page, 0); @@ -38,7 +38,7 @@ sentryTest('keeps track of max duration across reloads', async ({ getLocalTestPa const [req0, req1] = await Promise.all([ reqPromise0, reqPromise1, - page.click('#button1'), + page.locator('#button1').click(), page.evaluate( `Object.defineProperty(document, 'visibilityState', { configurable: true, diff --git a/dev-packages/browser-integration-tests/suites/replay/multiple-pages/test.ts b/dev-packages/browser-integration-tests/suites/replay/multiple-pages/test.ts index 4b04a61995a4..1148847f09c7 100644 --- a/dev-packages/browser-integration-tests/suites/replay/multiple-pages/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/multiple-pages/test.ts @@ -64,7 +64,7 @@ sentryTest( expect(normalize(recording0.fullSnapshots)).toMatchSnapshot('seg-0-snap-full'); expect(recording0.incrementalSnapshots.length).toEqual(0); - const [req1] = await Promise.all([reqPromise1, page.click('#go-background')]); + const [req1] = await Promise.all([reqPromise1, page.locator('#go-background').click()]); const replayEvent1 = getReplayEvent(req1); const recording1 = getReplayRecordingContent(req1); @@ -104,7 +104,7 @@ sentryTest( expect(normalize(recording2.fullSnapshots)).toMatchSnapshot('seg-2-snap-full'); expect(recording2.incrementalSnapshots.length).toEqual(0); - const [req3] = await Promise.all([reqPromise3, page.click('#go-background')]); + const [req3] = await Promise.all([reqPromise3, page.locator('#go-background').click()]); const replayEvent3 = getReplayEvent(req3); const recording3 = getReplayRecordingContent(req3); @@ -133,7 +133,7 @@ sentryTest( // ----------------------------------------------------------------------------------------- // Test subsequent link navigation to another page - const [req4] = await Promise.all([reqPromise4, page.click('a')]); + const [req4] = await Promise.all([reqPromise4, page.locator('a').click()]); const replayEvent4 = getReplayEvent(req4); const recording4 = getReplayRecordingContent(req4); @@ -156,7 +156,7 @@ sentryTest( expect(normalize(recording4.fullSnapshots)).toMatchSnapshot('seg-4-snap-full'); expect(recording4.incrementalSnapshots.length).toEqual(0); - const [req5] = await Promise.all([reqPromise5, page.click('#go-background')]); + const [req5] = await Promise.all([reqPromise5, page.locator('#go-background').click()]); const replayEvent5 = getReplayEvent(req5); const recording5 = getReplayRecordingContent(req5); @@ -201,7 +201,7 @@ sentryTest( // ----------------------------------------------------------------------------------------- // Test subsequent navigation without a page reload (i.e. SPA navigation) - const [req6] = await Promise.all([reqPromise6, page.click('#spa-navigation')]); + const [req6] = await Promise.all([reqPromise6, page.locator('#spa-navigation').click()]); const replayEvent6 = getReplayEvent(req6); const recording6 = getReplayRecordingContent(req6); @@ -224,7 +224,7 @@ sentryTest( expect(recording6.fullSnapshots.length).toEqual(0); expect(normalize(recording6.incrementalSnapshots)).toMatchSnapshot('seg-6-snap-incremental'); - const [req7] = await Promise.all([reqPromise7, page.click('#go-background')]); + const [req7] = await Promise.all([reqPromise7, page.locator('#go-background').click()]); const replayEvent7 = getReplayEvent(req7); const recording7 = getReplayRecordingContent(req7); @@ -271,7 +271,7 @@ sentryTest( // // ----------------------------------------------------------------------------------------- // // And just to finish this off, let's go back to the index page - const [req8] = await Promise.all([reqPromise8, page.click('a')]); + const [req8] = await Promise.all([reqPromise8, page.locator('a').click()]); const replayEvent8 = getReplayEvent(req8); const recording8 = getReplayRecordingContent(req8); @@ -284,7 +284,7 @@ sentryTest( expect(normalize(recording8.fullSnapshots)).toMatchSnapshot('seg-8-snap-full'); expect(recording8.incrementalSnapshots.length).toEqual(0); - const [req9] = await Promise.all([reqPromise9, page.click('#go-background')]); + const [req9] = await Promise.all([reqPromise9, page.locator('#go-background').click()]); const replayEvent9 = getReplayEvent(req9); const recording9 = getReplayRecordingContent(req9); diff --git a/dev-packages/browser-integration-tests/suites/replay/requests/test.ts b/dev-packages/browser-integration-tests/suites/replay/requests/test.ts index 52d78a144787..a15665b357dc 100644 --- a/dev-packages/browser-integration-tests/suites/replay/requests/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/requests/test.ts @@ -31,11 +31,11 @@ sentryTest('replay recording should contain fetch request span', async ({ getLoc const url = await getLocalTestPath({ testDir: __dirname }); - const [req0] = await Promise.all([reqPromise0, page.goto(url), page.click('#go-background')]); + const [req0] = await Promise.all([reqPromise0, page.goto(url), page.locator('#go-background').click()]); const { performanceSpans: spans0 } = getReplayRecordingContent(req0); - await Promise.all([page.waitForResponse('https://example.com'), page.click('#fetch')]); + await Promise.all([page.waitForResponse('https://example.com'), page.locator('#fetch').click()]); const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1); @@ -69,11 +69,11 @@ sentryTest('replay recording should contain XHR request span', async ({ getLocal const url = await getLocalTestPath({ testDir: __dirname }); - const [req0] = await Promise.all([reqPromise0, page.goto(url), page.click('#go-background')]); + const [req0] = await Promise.all([reqPromise0, page.goto(url), page.locator('#go-background').click()]); const { performanceSpans: spans0 } = getReplayRecordingContent(req0); - await Promise.all([page.waitForResponse('https://example.com'), page.click('#xhr')]); + await Promise.all([page.waitForResponse('https://example.com'), page.locator('#xhr').click()]); const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1); diff --git a/dev-packages/browser-integration-tests/suites/replay/sampling/test.ts b/dev-packages/browser-integration-tests/suites/replay/sampling/test.ts index 752c9c89a431..92aa50ff3744 100644 --- a/dev-packages/browser-integration-tests/suites/replay/sampling/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/sampling/test.ts @@ -22,7 +22,7 @@ sentryTest('should not send replays if both sample rates are 0', async ({ getLoc const url = await getLocalTestPath({ testDir: __dirname }); await page.goto(url); - await page.click('button'); + await page.locator('button').click(); const replay = await getReplaySnapshot(page); diff --git a/dev-packages/browser-integration-tests/suites/replay/sessionExpiry/test.ts b/dev-packages/browser-integration-tests/suites/replay/sessionExpiry/test.ts index 3b78c859b8ae..05842705227e 100644 --- a/dev-packages/browser-integration-tests/suites/replay/sessionExpiry/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/sessionExpiry/test.ts @@ -46,7 +46,7 @@ sentryTest('handles an expired session', async ({ browserName, forceFlushReplay, // We wait for another segment 0 const reqPromise2 = waitForReplayRequest(page, 0); - await page.click('#button1'); + await page.locator('#button1').click(); await forceFlushReplay(); const req1 = await reqPromise1; @@ -58,7 +58,7 @@ sentryTest('handles an expired session', async ({ browserName, forceFlushReplay, await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT)); - await page.click('#button2'); + await page.locator('#button2').click(); await forceFlushReplay(); const req2 = await reqPromise2; diff --git a/dev-packages/browser-integration-tests/suites/replay/sessionInactive/test.ts b/dev-packages/browser-integration-tests/suites/replay/sessionInactive/test.ts index 60b78d121bbb..614f9a3d99d7 100644 --- a/dev-packages/browser-integration-tests/suites/replay/sessionInactive/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/sessionInactive/test.ts @@ -44,7 +44,7 @@ sentryTest('handles an inactive session', async ({ getLocalTestPath, page, brows const stringifiedSnapshot = normalize(fullSnapshots0[0]); expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json'); - await page.click('#button1'); + await page.locator('#button1').click(); // Now we wait for the session timeout, nothing should be sent in the meanwhile await new Promise(resolve => setTimeout(resolve, SESSION_PAUSED)); @@ -67,7 +67,7 @@ sentryTest('handles an inactive session', async ({ getLocalTestPath, page, brows const reqPromise1 = waitForReplayRequest(page); // Trigger an action, should resume the recording - await page.click('#button2'); + await page.locator('#button2').click(); const req1 = await reqPromise1; const replay3 = await getReplaySnapshot(page); diff --git a/dev-packages/browser-integration-tests/suites/replay/sessionMaxAge/test.ts b/dev-packages/browser-integration-tests/suites/replay/sessionMaxAge/test.ts index 7cc02cb83a05..0a253597f367 100644 --- a/dev-packages/browser-integration-tests/suites/replay/sessionMaxAge/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/sessionMaxAge/test.ts @@ -59,7 +59,7 @@ sentryTest('handles session that exceeds max age', async ({ forceFlushReplay, ge // Wait half of the session max age (after initial flush), but account for potentially slow runners const timePassed1 = Date.now() - startTimestamp; await new Promise(resolve => setTimeout(resolve, Math.max(MAX_REPLAY_DURATION / 2 - timePassed1, 0))); - await page.click('#button1'); + await page.locator('#button1').click(); await forceFlushReplay(); const req1 = await reqPromise1; @@ -73,7 +73,7 @@ sentryTest('handles session that exceeds max age', async ({ forceFlushReplay, ge // Wait for session to expire const timePassed2 = Date.now() - startTimestamp; await new Promise(resolve => setTimeout(resolve, Math.max(MAX_REPLAY_DURATION - timePassed2, 0))); - await page.click('#button2'); + await page.locator('#button2').click(); await forceFlushReplay(); const req2 = await reqPromise2; diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/clickTargets/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/clickTargets/test.ts index 8074f34a40fb..b5b8a5b24988 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/clickTargets/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/clickTargets/test.ts @@ -54,7 +54,7 @@ import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click(`#${id}`), + page.locator(`#${id}`).click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -109,7 +109,7 @@ import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click(`#${id}`), + page.locator(`#${id}`).click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/disable/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/disable/test.ts index aef218a63cae..c57b5d05b3f2 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/disable/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/disable/test.ts @@ -26,7 +26,7 @@ sentryTest('does not capture slow click when slowClickTimeout === 0', async ({ g return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#mutationButton'), + page.locator('#mutationButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/error/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/error/test.ts index 09c1fc29d3c0..570a633443d4 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/error/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/error/test.ts @@ -31,7 +31,7 @@ sentryTest('slow click that triggers error is captured', async ({ getLocalTestUr return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#buttonError'), + page.locator('#buttonError').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req0); @@ -105,7 +105,7 @@ sentryTest( return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#buttonErrorMutation'), + page.locator('#buttonErrorMutation').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/ignore/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/ignore/test.ts index f80789d46a78..9d6c49abc29d 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/ignore/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/ignore/test.ts @@ -26,7 +26,7 @@ sentryTest('click is ignored on ignoreSelectors', async ({ getLocalTestUrl, page return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#mutationIgnoreButton'), + page.locator('#mutationIgnoreButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -77,7 +77,7 @@ sentryTest('click is ignored on div', async ({ getLocalTestUrl, page }) => { return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - await page.click('#mutationDiv'), + await page.locator('#mutationDiv').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/multiClick/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/multiClick/test.ts index a21327058a81..16f3036a3cca 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/multiClick/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/multiClick/test.ts @@ -31,7 +31,7 @@ sentryTest('captures multi click when not detecting slow click', async ({ getLoc return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.multiClick'); }), - page.click('#mutationButtonImmediately', { clickCount: 4 }), + page.locator('#mutationButtonImmediately').click({ clickCount: 4 }), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -69,7 +69,7 @@ sentryTest('captures multi click when not detecting slow click', async ({ getLoc return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.multiClick'); }), - page.click('#mutationButtonImmediately', { clickCount: 3 }), + page.locator('#mutationButtonImmediately').click({ clickCount: 3 }), ]); const { breadcrumbs: breadcrumbb2 } = getCustomRecordingEvents(req2); @@ -132,13 +132,13 @@ sentryTest('captures multiple multi clicks', async ({ getLocalTestUrl, page, for return false; }); - await page.click('#mutationButtonImmediately', { clickCount: 4 }); + await page.locator('#mutationButtonImmediately').click({ clickCount: 4 }); await forceFlushReplay(); // Ensure we waited at least 1s, which is the threshold to create a new ui.click breadcrumb await new Promise(resolve => setTimeout(resolve, 1001)); - await page.click('#mutationButtonImmediately', { clickCount: 2 }); + await page.locator('#mutationButtonImmediately').click({ clickCount: 2 }); await forceFlushReplay(); const responses = await reqsPromise; diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/mutation/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/mutation/test.ts index 39599c84cd32..ba3dd43ac3d3 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/mutation/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/mutation/test.ts @@ -28,7 +28,7 @@ sentryTest('mutation after threshold results in slow click', async ({ forceFlush return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#mutationButton'), + page.locator('#mutationButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -86,7 +86,7 @@ sentryTest('multiple clicks are counted', async ({ getLocalTestUrl, page }) => { return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#mutationButton', { clickCount: 4 }), + page.locator('#mutationButton').click({ clickCount: 4 }), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -156,7 +156,7 @@ sentryTest('immediate mutation does not trigger slow click', async ({ forceFlush return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#mutationButtonImmediately'), + page.locator('#mutationButtonImmediately').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -213,7 +213,7 @@ sentryTest('inline click handler does not trigger slow click', async ({ forceFlu return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#mutationButtonInline'), + page.locator('#mutationButtonInline').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -262,7 +262,7 @@ sentryTest('mouseDown events are considered', async ({ getLocalTestUrl, page }) return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#mouseDownButton'), + page.locator('#mouseDownButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/scroll/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/scroll/test.ts index 1f5b672ff659..a7101351061f 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/scroll/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/scroll/test.ts @@ -26,7 +26,7 @@ sentryTest('immediate scroll does not trigger slow click', async ({ getLocalTest return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click'); }), - page.click('#scrollButton'), + page.locator('#scrollButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -75,7 +75,7 @@ sentryTest('late scroll triggers slow click', async ({ getLocalTestUrl, page }) return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#scrollLateButton'), + page.locator('#scrollLateButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/timeout/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/timeout/test.ts index 6e6a1f13e3b6..8adf24302089 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/timeout/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/timeout/test.ts @@ -26,7 +26,7 @@ sentryTest('mutation after timeout results in slow click', async ({ getLocalTest return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#mutationButtonLate'), + page.locator('#mutationButtonLate').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); @@ -82,7 +82,7 @@ sentryTest('console.log results in slow click', async ({ getLocalTestUrl, page } return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.slowClickDetected'); }), - page.click('#consoleLogButton'), + page.locator('#consoleLogButton').click(), ]); const { breadcrumbs } = getCustomRecordingEvents(req1); diff --git a/dev-packages/browser-integration-tests/suites/replay/slowClick/windowOpen/test.ts b/dev-packages/browser-integration-tests/suites/replay/slowClick/windowOpen/test.ts index 98ca0cc4c2a0..c029f19b8c28 100644 --- a/dev-packages/browser-integration-tests/suites/replay/slowClick/windowOpen/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/slowClick/windowOpen/test.ts @@ -30,7 +30,7 @@ sentryTest('window.open() is considered for slow click', async ({ getLocalTestUr const context = browser.contexts()[0]; const waitForNewPage = context.waitForEvent('page'); - await page.click('#windowOpenButton'); + await page.locator('#windowOpenButton').click(); const { breadcrumbs } = getCustomRecordingEvents(await reqPromise1); diff --git a/dev-packages/browser-integration-tests/suites/replay/throttleBreadcrumbs/test.ts b/dev-packages/browser-integration-tests/suites/replay/throttleBreadcrumbs/test.ts index e025c90a77e0..0eb0495eb1ea 100644 --- a/dev-packages/browser-integration-tests/suites/replay/throttleBreadcrumbs/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/throttleBreadcrumbs/test.ts @@ -29,7 +29,7 @@ sentryTest( await forceFlushReplay(); const res0 = getCustomRecordingEvents(await reqPromise0); - await page.click('[data-console]'); + await page.locator('[data-console]').click(); await forceFlushReplay(); const res1 = getCustomRecordingEvents(await reqPromise1); diff --git a/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts b/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts index 8a48f161c93b..1359f90ac0e0 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/start-session/test.ts @@ -26,7 +26,7 @@ sentryTest('should start a new session with navigation.', async ({ getLocalTestP const initSession = await getFirstSentryEnvelopeRequest(page, url); - await page.click('#navigate'); + await page.locator('#navigate').click(); const newSession = await getFirstSentryEnvelopeRequest(page, url); diff --git a/dev-packages/browser-integration-tests/suites/sessions/update-session/test.ts b/dev-packages/browser-integration-tests/suites/sessions/update-session/test.ts index dfde68dce175..422d716db9e6 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/update-session/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/update-session/test.ts @@ -8,7 +8,7 @@ sentryTest('should update session when an error is thrown.', async ({ getLocalTe const url = await getLocalTestPath({ testDir: __dirname }); const pageloadSession = await getFirstSentryEnvelopeRequest(page, url); const updatedSession = ( - await Promise.all([page.click('#throw-error'), getFirstSentryEnvelopeRequest(page)]) + await Promise.all([page.locator('#throw-error').click(), getFirstSentryEnvelopeRequest(page)]) )[1]; expect(pageloadSession).toBeDefined(); @@ -26,7 +26,7 @@ sentryTest('should update session when an exception is captured.', async ({ getL const pageloadSession = await getFirstSentryEnvelopeRequest(page, url); const updatedSession = ( - await Promise.all([page.click('#capture-exception'), getFirstSentryEnvelopeRequest(page)]) + await Promise.all([page.locator('#capture-exception').click(), getFirstSentryEnvelopeRequest(page)]) )[1]; expect(pageloadSession).toBeDefined(); diff --git a/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts b/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts index 8a48f161c93b..1359f90ac0e0 100644 --- a/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts +++ b/dev-packages/browser-integration-tests/suites/sessions/v7-hub-start-session/test.ts @@ -26,7 +26,7 @@ sentryTest('should start a new session with navigation.', async ({ getLocalTestP const initSession = await getFirstSentryEnvelopeRequest(page, url); - await page.click('#navigate'); + await page.locator('#navigate').click(); const newSession = await getFirstSentryEnvelopeRequest(page, url); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts index eca82197d80c..de1cd552ccab 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts @@ -19,7 +19,7 @@ sentryTest('should finish a custom transaction when the page goes background', a const pageloadTransaction = await getFirstSentryEnvelopeRequest(page, url); expect(pageloadTransaction).toBeDefined(); - await page.click('#start-transaction'); + await page.locator('#start-transaction').click(); const transactionHandle = await page.evaluateHandle('window.transaction'); const id_before = await getPropertyValue(transactionHandle, 'span_id'); @@ -31,7 +31,7 @@ sentryTest('should finish a custom transaction when the page goes background', a expect(status_before).toBeUndefined(); expect(tags_before).toStrictEqual({}); - await page.click('#go-background'); + await page.locator('#go-background').click(); const id_after = await getPropertyValue(transactionHandle, 'span_id'); const name_after = await getPropertyValue(transactionHandle, 'name'); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts index 485d50d12641..8432245f9c9b 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts @@ -11,7 +11,7 @@ sentryTest('should finish pageload transaction when the page goes background', a const url = await getLocalTestPath({ testDir: __dirname }); await page.goto(url); - await page.click('#go-background'); + await page.locator('#go-background').click(); const pageloadTransaction = await getFirstSentryEnvelopeRequest(page); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts index d7cf60e3e726..fb6e9e540c46 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; @@ -22,12 +21,13 @@ sentryTest( expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); + expect(requestHeaders).toMatchObject({ 'sentry-trace': expect.any(String), baggage: expect.any(String), }); - }); + } }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts index 19c949ad07a7..a6cc58ca46ff 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; @@ -22,12 +21,12 @@ sentryTest( expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).not.toMatchObject({ 'sentry-trace': expect.any(String), baggage: expect.any(String), }); - }); + } }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts index 47c24618492a..9f32b7b1ad28 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; @@ -22,12 +21,12 @@ sentryTest( expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).toMatchObject({ 'sentry-trace': expect.any(String), baggage: expect.any(String), }); - }); + } }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts index 3edbd3d3c99b..120b36ec88db 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; @@ -22,12 +21,12 @@ sentryTest( expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).toMatchObject({ 'sentry-trace': expect.any(String), baggage: expect.any(String), }); - }); + } }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts index 445fa0fdba70..116319259101 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; @@ -22,12 +21,12 @@ sentryTest( expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).not.toMatchObject({ 'sentry-trace': expect.any(String), baggage: expect.any(String), }); - }); + } }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts index 90dde1ec2ecd..94402e4f6ab3 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts @@ -14,7 +14,7 @@ sentryTest('should capture a FID vital.', async ({ browserName, getLocalTestPath await page.goto(url); // To trigger FID - await page.click('#fid-btn'); + await page.locator('#fid-btn').click(); const eventData = await getFirstSentryEnvelopeRequest(page); diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts index b4126c91a12d..cbe60ae1ea62 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts @@ -18,7 +18,7 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN const [eventData] = await Promise.all([ getFirstSentryEnvelopeRequest(page), page.goto(url), - page.click('button'), + page.locator('button').click(), ]); expect(eventData.measurements).toBeDefined(); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts index 15e99f80f8d2..7bffc0131b2f 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; @@ -58,10 +57,10 @@ sentryTest('should attach `sentry-trace` header to multiple fetch requests', asy expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).toMatchObject({ 'sentry-trace': expect.any(String), }); - }); + } }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts index 163b85110891..d1c64e253e71 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts @@ -1,4 +1,3 @@ -import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; @@ -46,10 +45,10 @@ sentryTest('should attach `sentry-trace` header to multiple XHR requests', async expect(requests).toHaveLength(3); - requests?.forEach(async (request: Request) => { - const requestHeaders = await request.allHeaders(); + for (const request of requests) { + const requestHeaders = request.headers(); expect(requestHeaders).toMatchObject({ 'sentry-trace': expect.any(String), }); - }); + } }); diff --git a/dev-packages/browser-integration-tests/utils/replayEventTemplates.ts b/dev-packages/browser-integration-tests/utils/replayEventTemplates.ts index 8824d8ab1812..3be00a1f9840 100644 --- a/dev-packages/browser-integration-tests/utils/replayEventTemplates.ts +++ b/dev-packages/browser-integration-tests/utils/replayEventTemplates.ts @@ -60,7 +60,7 @@ export function getExpectedReplayEvent(customExpectedReplayEvent: Partial