Skip to content

Commit 11f494d

Browse files
committed
Use locator instead of page.click.
1 parent aa7a960 commit 11f494d

File tree

48 files changed

+121
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+121
-121
lines changed

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ sentryTest('captures Breadcrumb for clicks & debounces them for a second', async
2121

2222
const promise = getFirstSentryEnvelopeRequest<Event>(page);
2323

24-
await page.goto(url);
24+
await Promise.all([page.goto(url), page.locator('#button1').click()]);
2525

26-
await page.click('#button1');
2726
// not debounced because other target
28-
await page.click('#button2');
27+
await page.locator('#button2').click();
2928
// This should be debounced
30-
await page.click('#button2');
29+
await page.locator('#button2').click();
3130

3231
// Wait a second for the debounce to finish
3332
await page.waitForTimeout(1000);
34-
await page.click('#button2');
33+
await page.locator('#button2').click();
3534

3635
const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]);
3736

@@ -76,7 +75,7 @@ sentryTest(
7675
const promise = getFirstSentryEnvelopeRequest<Event>(page);
7776

7877
await page.goto(url);
79-
await page.click('#annotated-button');
78+
await page.locator('#annotated-button').click();
8079
await page.evaluate('Sentry.captureException("test exception")');
8180

8281
const eventData = await promise;

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({
2323

2424
await page.goto(url);
2525

26-
await page.click('#input1');
26+
await page.locator('#input1').click();
2727
// Not debounced because other event type
2828
await page.locator('#input1').pressSequentially('John', { delay: 1 });
2929

@@ -88,7 +88,7 @@ sentryTest(
8888

8989
await page.goto(url);
9090

91-
await page.click('#annotated-input');
91+
await page.locator('#annotated-input').click();
9292
await page.locator('#annotated-input').pressSequentially('John', { delay: 1 });
9393

9494
await page.evaluate('Sentry.captureException("test exception")');

dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sentryTest(
1919

2020
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
2121

22-
const clickPromise = page.click('#inline-error-btn');
22+
const clickPromise = page.locator('#inline-error-btn').click();
2323

2424
const [req] = await Promise.all([eventReqPromise, clickPromise]);
2525

dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sentryTest('should not add source context lines to errors from script files', as
88

99
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
1010

11-
const clickPromise = page.click('#script-error-btn');
11+
const clickPromise = page.locator('#script-error-btn').click();
1212

1313
const [req] = await Promise.all([eventReqPromise, clickPromise]);
1414

dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sentryTest(
1919

2020
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
2121

22-
const clickPromise = page.click('#inline-error-btn');
22+
const clickPromise = page.locator('#inline-error-btn').click();
2323

2424
const [req] = await Promise.all([eventReqPromise, clickPromise]);
2525

dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ sentryTest(
4848
const url = await getLocalTestPath({ testDir: __dirname });
4949

5050
await page.goto(url);
51-
await page.click('#go-background');
52-
await page.click('#error');
51+
await page.locator('#go-background').click();
52+
await page.locator('#error').click();
5353
await new Promise(resolve => setTimeout(resolve, 1000));
5454

5555
// error, no replays
@@ -75,9 +75,9 @@ sentryTest(
7575
}),
7676
).toBe(true);
7777

78-
await page.click('#log');
79-
await page.click('#go-background');
80-
await page.click('#error2');
78+
await page.locator('#log').click();
79+
await page.locator('#go-background').click();
80+
await page.locator('#error2').click();
8181
await new Promise(resolve => setTimeout(resolve, 1000));
8282

8383
// 2 errors
@@ -96,8 +96,8 @@ sentryTest(
9696
await reqErrorPromise;
9797
expect(callsToSentry).toBeGreaterThanOrEqual(3);
9898

99-
await page.click('#log');
100-
await page.click('#go-background');
99+
await page.locator('#log').click();
100+
await page.locator('#go-background').click();
101101

102102
// Switches to session mode and then goes to background
103103
const req1 = await reqPromise1;
@@ -191,8 +191,8 @@ sentryTest(
191191
const url = await getLocalTestPath({ testDir: __dirname });
192192

193193
await page.goto(url);
194-
await page.click('#go-background');
195-
await page.click('#error');
194+
await page.locator('#go-background').click();
195+
await page.locator('#error').click();
196196
await new Promise(resolve => setTimeout(resolve, 1000));
197197

198198
// error, no replays
@@ -218,9 +218,9 @@ sentryTest(
218218
}),
219219
).toBe(true);
220220

221-
await page.click('#log');
222-
await page.click('#go-background');
223-
await page.click('#error2');
221+
await page.locator('#log').click();
222+
await page.locator('#go-background').click();
223+
await page.locator('#error2').click();
224224
await new Promise(resolve => setTimeout(resolve, 1000));
225225

226226
// 2 errors
@@ -239,8 +239,8 @@ sentryTest(
239239
await reqErrorPromise;
240240
expect(callsToSentry).toEqual(3);
241241

242-
await page.click('#log');
243-
await page.click('#go-background');
242+
await page.locator('#log').click();
243+
await page.locator('#go-background').click();
244244

245245
// Has stopped recording, should make no more calls to Sentry
246246
expect(callsToSentry).toEqual(3);
@@ -331,8 +331,8 @@ sentryTest(
331331
}),
332332
).toBe(true);
333333

334-
await page.click('#go-background');
335-
await page.click('#error');
334+
await page.locator('#go-background').click();
335+
await page.locator('#error').click();
336336
await new Promise(resolve => setTimeout(resolve, 1000));
337337

338338
// 1 unsampled error, no replay
@@ -351,7 +351,7 @@ sentryTest(
351351
const [req0] = await Promise.all([
352352
// 1 unsampled error, 1 sampled error -> 1 flush
353353
reqPromise0,
354-
page.click('#error2'),
354+
page.locator('#error2').click(),
355355
]);
356356

357357
const reqError1 = await reqErrorPromise1;

dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sentryTest('continues buffer session in session mode after error & reload', asyn
2828
await page.goto(url);
2929

3030
// buffer session captures an error & switches to session mode
31-
await page.click('#buttonError');
31+
await page.locator('#buttonError').click();
3232
await new Promise(resolve => setTimeout(resolve, 300));
3333
await reqPromise1;
3434

dev-packages/browser-integration-tests/suites/replay/canvas/records/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sentryTest('can record canvas', async ({ getLocalTestUrl, page, browserName }) =
2424

2525
await page.goto(url);
2626
await reqPromise0;
27-
await Promise.all([page.click('#draw'), reqPromise1]);
27+
await Promise.all([page.locator('#draw').click(), reqPromise1]);
2828

2929
const { incrementalSnapshots } = getReplayRecordingContent(await reqPromise2);
3030
expect(incrementalSnapshots).toEqual(

dev-packages/browser-integration-tests/suites/replay/captureConsoleLog/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ sentryTest('should capture console messages in replay', async ({ getLocalTestPat
3434
5_000,
3535
);
3636

37-
await page.click('[data-log]');
37+
await page.locator('[data-log]').click();
3838

3939
// Sometimes this doesn't seem to trigger, so we trigger it twice to be sure...
40-
const [req1] = await Promise.all([reqPromise1, page.click('[data-log]')]);
40+
const [req1] = await Promise.all([reqPromise1, page.locator('[data-log]').click()]);
4141
await forceFlushReplay();
4242

4343
const { breadcrumbs } = getCustomRecordingEvents(req1);
@@ -87,7 +87,7 @@ sentryTest('should capture very large console logs', async ({ getLocalTestPath,
8787
5_000,
8888
);
8989

90-
const [req1] = await Promise.all([reqPromise1, page.click('[data-log-large]')]);
90+
const [req1] = await Promise.all([reqPromise1, page.locator('[data-log-large]').click()]);
9191
await forceFlushReplay();
9292

9393
const { breadcrumbs } = getCustomRecordingEvents(req1);

dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
2525
await page.goto(url);
2626
const replayEvent0 = getReplayEvent(await reqPromise0);
2727

28-
await page.click('button');
28+
await page.locator('button').click();
2929
const replayEvent1 = getReplayEvent(await reqPromise1);
3030

3131
expect(replayEvent0).toBeDefined();

dev-packages/browser-integration-tests/suites/replay/customEvents/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
<div role="button" id="error" class="btn btn-error" aria-label="An Error in aria-label">An Error</div>
8-
<button title="Button title">
8+
<button id="img-button" title="Button title">
99
<img id="img" alt="Alt Text" />
1010
</button>
1111
<button class="sentry-unmask" aria-label="Unmasked label">Unmasked</button>

dev-packages/browser-integration-tests/suites/replay/customEvents/test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sentryTest(
4747

4848
expect(replayEvent0).toEqual(getExpectedReplayEvent({ segment_id: 0 }));
4949

50-
await page.click('button');
50+
await page.locator('#img-button').click();
5151

5252
const replayEvent1 = getReplayEvent(await reqPromise1);
5353
const { performanceSpans: performanceSpans1 } = getCustomRecordingEvents(await reqPromise1);
@@ -104,7 +104,7 @@ sentryTest(
104104
await page.goto(url);
105105
await reqPromise0;
106106

107-
await page.click('#error');
107+
await page.locator('#error').click();
108108
await forceFlushReplay();
109109
const req1 = await reqPromise1;
110110
const content1 = getReplayRecordingContent(req1);
@@ -131,19 +131,20 @@ sentryTest(
131131
]),
132132
);
133133

134-
await page.click('#img');
134+
await page.locator('#img').click();
135135
await forceFlushReplay();
136136
const req2 = await reqPromise2;
137137
const content2 = getReplayRecordingContent(req2);
138138
expect(content2.breadcrumbs).toEqual(
139139
expect.arrayContaining([
140140
{
141141
...expectedClickBreadcrumb,
142-
message: 'body > button[title="Button title"]',
142+
message: 'body > button#img-button[title="Button title"]',
143143
data: {
144144
nodeId: expect.any(Number),
145145
node: {
146146
attributes: {
147+
id: 'img-button',
147148
title: '****** *****',
148149
},
149150
id: expect.any(Number),
@@ -155,7 +156,7 @@ sentryTest(
155156
]),
156157
);
157158

158-
await page.click('.sentry-unmask');
159+
await page.locator('.sentry-unmask').click();
159160
await forceFlushReplay();
160161
const req3 = await reqPromise3;
161162
const content3 = getReplayRecordingContent(req3);
@@ -206,7 +207,7 @@ sentryTest(
206207
await page.goto(url);
207208
await forceFlushReplay();
208209

209-
await page.click('#error');
210+
await page.locator('#error').click();
210211
await forceFlushReplay();
211212

212213
const req0 = await reqPromise0;

dev-packages/browser-integration-tests/suites/replay/errorResponse/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sentryTest('should stop recording after receiving an error response', async ({ g
2626
await page.goto(url);
2727

2828
await waitForReplayRequest(page);
29-
await page.click('button');
29+
await page.locator('button').click();
3030

3131
expect(called).toBe(1);
3232

dev-packages/browser-integration-tests/suites/replay/errors/beforeErrorSampling/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sentryTest(
2424
await page.goto(url);
2525
await waitForReplayRunning(page);
2626

27-
await page.click('#drop');
27+
await page.locator('#drop').click();
2828
await forceFlushReplay();
2929

3030
expect(await getReplaySnapshot(page)).toEqual(

dev-packages/browser-integration-tests/suites/replay/errors/droppedError/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ sentryTest(
3434
await forceFlushReplay();
3535
expect(callsToSentry).toEqual(0);
3636

37-
await page.click('#error');
37+
await page.locator('#error').click();
3838

39-
await page.click('#log');
39+
await page.locator('#log').click();
4040
await forceFlushReplay();
4141

4242
expect(callsToSentry).toEqual(0);

dev-packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ sentryTest(
5252

5353
await Promise.all([
5454
page.goto(url),
55-
page.click('#go-background'),
55+
page.locator('#go-background').click(),
5656
new Promise(resolve => setTimeout(resolve, 1000)),
5757
]);
5858

5959
expect(callsToSentry).toEqual(0);
6060

61-
const [req0] = await Promise.all([reqPromise0, page.click('#error')]);
61+
const [req0] = await Promise.all([reqPromise0, page.locator('#error').click()]);
6262

6363
expect(callsToSentry).toEqual(2); // 1 error, 1 replay event
6464

65-
const [req1] = await Promise.all([reqPromise1, page.click('#go-background'), reqErrorPromise]);
65+
const [req1] = await Promise.all([reqPromise1, page.locator('#go-background').click(), reqErrorPromise]);
6666

6767
expect(callsToSentry).toEqual(3); // 1 error, 2 replay events
6868

69-
await page.click('#log');
69+
await page.locator('#log').click();
7070

71-
const [req2] = await Promise.all([reqPromise2, page.click('#go-background')]);
71+
const [req2] = await Promise.all([reqPromise2, page.locator('#go-background').click()]);
7272

7373
const event0 = getReplayEvent(req0);
7474
const content0 = getReplayRecordingContent(req0);

dev-packages/browser-integration-tests/suites/replay/errors/errorModeCustomTransport/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sentryTest(
3030
await forceFlushReplay();
3131
expect(callsToSentry).toEqual(0);
3232

33-
await page.click('#error');
33+
await page.locator('#error').click();
3434
await promiseReq0;
3535

3636
await forceFlushReplay();

dev-packages/browser-integration-tests/suites/replay/errors/errorNotSent/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ sentryTest(
2727
await forceFlushReplay();
2828
expect(callsToSentry).toEqual(0);
2929

30-
await page.click('#error');
30+
await page.locator('#error').click();
3131

32-
await page.click('#log');
32+
await page.locator('#log').click();
3333
await forceFlushReplay();
3434

3535
// Only sent once, but since API failed we do not go into session mode

dev-packages/browser-integration-tests/suites/replay/errors/errorsInSession/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ sentryTest(
4242
await page.goto(url);
4343
const req0 = await reqPromise0;
4444

45-
await page.click('#error');
45+
await page.locator('#error').click();
4646
await forceFlushReplay();
4747
const req1 = await reqPromise1;
4848

@@ -107,7 +107,7 @@ sentryTest(
107107
await page.goto(url);
108108
await reqPromise0;
109109

110-
await page.click('#drop');
110+
await page.locator('#drop').click();
111111
await forceFlushReplay();
112112
const req1 = await reqPromise1;
113113

dev-packages/browser-integration-tests/suites/replay/eventBufferError/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ window.Replay._replay.eventBuffer.addEvent = (...args) => {
7373
};
7474
`);
7575

76-
void page.click('#button1');
77-
void page.click('#button2');
76+
void page.locator('#button1').click();
77+
void page.locator('#button2').click();
7878

7979
// Should immediately skip retrying and just cancel, no backoff
8080
// This waitForTimeout call should be okay, as we're not checking for any

0 commit comments

Comments
 (0)