1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test, expect } from './inspectorTest';
import fs from 'fs';
test.describe('cli codegen', () => {
test.skip(({ mode }) => mode !== 'default');
test('should contain open page', async ({ openRecorder }) => {
const { recorder } = await openRecorder();
await recorder.setContentAndWait(``);
const sources = await recorder.waitForOutput('JavaScript', `page.goto`);
expect(sources.get('JavaScript')!.text).toContain(`
const page = await context.newPage();`);
expect(sources.get('Java')!.text).toContain(`
Page page = context.newPage();`);
expect(sources.get('Python')!.text).toContain(`
page = context.new_page()`);
expect(sources.get('Python Async')!.text).toContain(`
page = await context.new_page()`);
expect(sources.get('C#')!.text).toContain(`
var page = await context.NewPageAsync();`);
});
test('should contain second page', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(``);
await page.context().newPage();
const sources = await recorder.waitForOutput('JavaScript', 'page1');
expect(sources.get('JavaScript')!.text).toContain(`
const page1 = await context.newPage();`);
expect(sources.get('Java')!.text).toContain(`
Page page1 = context.newPage();`);
expect(sources.get('Python')!.text).toContain(`
page1 = context.new_page()`);
expect(sources.get('Python Async')!.text).toContain(`
page1 = await context.new_page()`);
expect(sources.get('C#')!.text).toContain(`
var page1 = await context.NewPageAsync();`);
});
test('should contain close page', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(``);
await page.context().newPage();
await recorder.page.close();
const sources = await recorder.waitForOutput('JavaScript', 'page.close();');
expect(sources.get('JavaScript')!.text).toContain(`
await page.close();`);
expect(sources.get('Java')!.text).toContain(`
page.close();`);
expect(sources.get('Python')!.text).toContain(`
page.close()`);
expect(sources.get('Python Async')!.text).toContain(`
await page.close()`);
expect(sources.get('C#')!.text).toContain(`
await page.CloseAsync();`);
});
test('should not lead to an error if html gets clicked', async ({ openRecorder, platform, macVersion }) => {
test.skip(platform === 'darwin' && macVersion < 15, 'recorder.page.evaluate hangs on CDP layer for some reason on macOS 14.');
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait('');
await page.context().newPage();
const errors: any[] = [];
recorder.page.on('pageerror', e => errors.push(e));
await recorder.page.evaluate(() => document.querySelector('body')!.remove());
await page.dispatchEvent('html', 'mousemove', { detail: 1 });
await recorder.page.close();
await recorder.waitForOutput('JavaScript', 'page.close();');
expect(errors.length).toBe(0);
});
test('should upload a single file', async ({ openRecorder, browserName, asset, isLinux }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<form>
<input type="file">
</form>
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', asset('file-to-upload.txt'));
await page.click('input[type=file]');
const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');
expect(sources.get('JavaScript')!.text).toContain(`
await page.getByRole('button', { name: 'Choose File' }).setInputFiles('file-to-upload.txt');`);
expect(sources.get('Java')!.text).toContain(`
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Choose File")).setInputFiles(Paths.get("file-to-upload.txt"));`);
expect(sources.get('Python')!.text).toContain(`
page.get_by_role("button", name="Choose File").set_input_files(\"file-to-upload.txt\")`);
expect(sources.get('Python Async')!.text).toContain(`
await page.get_by_role("button", name="Choose File").set_input_files(\"file-to-upload.txt\")`);
expect(sources.get('C#')!.text).toContain(`
await page.GetByRole(AriaRole.Button, new() { Name = "Choose File" }).SetInputFilesAsync(new[] { \"file-to-upload.txt\" });`);
});
test('should upload multiple files', async ({ openRecorder, browserName, asset, isLinux }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<form>
<input type="file" multiple>
</form>
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', [asset('file-to-upload.txt'), asset('file-to-upload-2.txt')]);
await page.click('input[type=file]');
const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');
expect(sources.get('JavaScript')!.text).toContain(`
await page.getByRole('button', { name: 'Choose File' }).setInputFiles(['file-to-upload.txt', 'file-to-upload-2.txt']);`);
expect(sources.get('Java')!.text).toContain(`
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Choose File")).setInputFiles(new Path[] {Paths.get("file-to-upload.txt"), Paths.get("file-to-upload-2.txt")});`);
expect(sources.get('Python')!.text).toContain(`
page.get_by_role("button", name="Choose File").set_input_files([\"file-to-upload.txt\", \"file-to-upload-2.txt\"]`);
expect(sources.get('Python Async')!.text).toContain(`
await page.get_by_role("button", name="Choose File").set_input_files([\"file-to-upload.txt\", \"file-to-upload-2.txt\"]`);
expect(sources.get('C#')!.text).toContain(`
await page.GetByRole(AriaRole.Button, new() { Name = "Choose File" }).SetInputFilesAsync(new[] { \"file-to-upload.txt\", \"file-to-upload-2.txt\" });`);
});
test('should clear files', async ({ openRecorder, browserName, asset, isLinux }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<form>
<input type="file" multiple>
</form>
`);
await page.focus('input[type=file]');
await page.setInputFiles('input[type=file]', asset('file-to-upload.txt'));
await page.setInputFiles('input[type=file]', []);
await page.click('input[type=file]');
const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');
expect(sources.get('JavaScript')!.text).toContain(`
await page.getByRole('button', { name: 'Choose File' }).setInputFiles([]);`);
expect(sources.get('Java')!.text).toContain(`
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Choose File")).setInputFiles(new Path[0]);`);
expect(sources.get('Python')!.text).toContain(`
page.get_by_role("button", name="Choose File").set_input_files([])`);
expect(sources.get('Python Async')!.text).toContain(`
await page.get_by_role("button", name="Choose File").set_input_files([])`);
expect(sources.get('C#')!.text).toContain(`
await page.GetByRole(AriaRole.Button, new() { Name = "Choose File" }).SetInputFilesAsync(new[] { });`);
});
test('should download files', async ({ openRecorder, server }) => {
const { page, recorder } = await openRecorder();
server.setRoute('/download', (req, res) => {
const pathName = new URL(req.url, 'http://localhost').pathname;
if (pathName === '/download') {
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
res.end(`Hello world`);
} else {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('');
}
});
await recorder.setContentAndWait(`
<a href="${server.PREFIX}/download" download>Download</a>
`, server.PREFIX);
await recorder.hoverOverElement('a');
await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const sources = await recorder.waitForOutput('JavaScript', 'await downloadPromise');
expect.soft(sources.get('JavaScript')!.text).toContain(`
const downloadPromise = page.waitForEvent('download');
await page.getByRole('link', { name: 'Download' }).click();
const download = await downloadPromise;`);
expect.soft(sources.get('Java')!.text).toContain(`
Download download = page.waitForDownload(() -> {
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Download")).click();
});`);
expect.soft(sources.get('Python')!.text).toContain(`
with page.expect_download() as download_info:
page.get_by_role("link", name="Download").click()
download = download_info.value`);
expect.soft(sources.get('Python Async')!.text).toContain(`
async with page.expect_download() as download_info:
await page.get_by_role("link", name="Download").click()
download = await download_info.value`);
expect.soft(sources.get('C#')!.text).toContain(`
var download = await page.RunAndWaitForDownloadAsync(async () =>
{
await page.GetByRole(AriaRole.Link, new() { Name = "Download" }).ClickAsync();
});`);
});
test('should handle dialogs', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<button onclick="alert()">click me</button>
`);
await recorder.hoverOverElement('button');
page.once('dialog', async dialog => {
await dialog.dismiss();
});
await page.click('button');
const sources = await recorder.waitForOutput('JavaScript', 'once');
expect.soft(sources.get('JavaScript')!.text).toContain(`
page.once('dialog', dialog => {
console.log(\`Dialog message: \${dialog.message()}\`);
dialog.dismiss().catch(() => {});
});
await page.getByRole('button', { name: 'click me' }).click();`);
expect.soft(sources.get('Java')!.text).toContain(`
page.onceDialog(dialog -> {
System.out.println(String.format("Dialog message: %s", dialog.message()));
dialog.dismiss();
});
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("click me")).click();`);
expect.soft(sources.get('Python')!.text).toContain(`
page.once(\"dialog\", lambda dialog: dialog.dismiss())
page.get_by_role("button", name="click me").click()`);
expect.soft(sources.get('Python Async')!.text).toContain(`
page.once(\"dialog\", lambda dialog: dialog.dismiss())
await page.get_by_role("button", name="click me").click()`);
expect.soft(sources.get('C#')!.text).toContain(`
void page_Dialog_EventHandler(object sender, IDialog dialog)
{
Console.WriteLine($\"Dialog message: {dialog.Message}\");
dialog.DismissAsync();
page.Dialog -= page_Dialog_EventHandler;
}
page.Dialog += page_Dialog_EventHandler;
await page.GetByRole(AriaRole.Button, new() { Name = "click me" }).ClickAsync();`);
});
test('should handle history.postData', async ({ openRecorder, server }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<script>
let seqNum = 0;
function pushState() {
history.pushState({}, 'title', '${server.PREFIX}/#seqNum=' + (++seqNum));
}
</script>`, server.PREFIX);
for (let i = 1; i < 3; ++i) {
await page.evaluate('pushState()');
await recorder.waitForOutput('JavaScript', `await page.goto('${server.PREFIX}/#seqNum=${i}');`);
}
});
test('should record open in a new tab with url', async ({ openRecorder, browserName }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<a href="about:blank?foo">link</a>`);
const locator = await recorder.hoverOverElement('a');
expect(locator).toBe(`getByRole('link', { name: 'link' })`);
await page.click('a', { modifiers: ['ControlOrMeta'] });
const sources = await recorder.waitForOutput('JavaScript', 'page1');
if (browserName !== 'firefox') {
expect(sources.get('JavaScript')!.text).toContain(`
const page1 = await context.newPage();
await page1.goto('about:blank?foo');`);
expect(sources.get('Python Async')!.text).toContain(`
page1 = await context.new_page()
await page1.goto("about:blank?foo")`);
expect(sources.get('C#')!.text).toContain(`
var page1 = await context.NewPageAsync();
await page1.GotoAsync("about:blank?foo");`);
} else {
expect(sources.get('JavaScript')!.text).toContain(`
const page1Promise = page.waitForEvent('popup');
await page.getByRole('link', { name: 'link' }).click({
modifiers: ['ControlOrMeta']
});
const page1 = await page1Promise;`);
}
});
test('should not clash pages', async ({ openRecorder, browserName }) => {
const { page, recorder } = await openRecorder();
const [popup1] = await Promise.all([
page.context().waitForEvent('page'),
page.evaluate(`window.open('about:blank')`)
]);
await recorder.setPageContentAndWait(popup1, '<input id=name>');
const [popup2] = await Promise.all([
page.context().waitForEvent('page'),
page.evaluate(`window.open('about:blank')`)
]);
await recorder.setPageContentAndWait(popup2, '<input id=name>');
await popup1.type('input', 'TextA');
await recorder.waitForOutput('JavaScript', 'TextA');
await popup2.type('input', 'TextB');
await recorder.waitForOutput('JavaScript', 'TextB');
const sources = recorder.sources();
expect(sources.get('JavaScript')!.text).toContain(`await page1.locator('#name').fill('TextA');`);
expect(sources.get('JavaScript')!.text).toContain(`await page2.locator('#name').fill('TextB');`);
expect(sources.get('Java')!.text).toContain(`page1.locator("#name").fill("TextA");`);
expect(sources.get('Java')!.text).toContain(`page2.locator("#name").fill("TextB");`);
expect(sources.get('Python')!.text).toContain(`page1.locator("#name").fill("TextA")`);
expect(sources.get('Python')!.text).toContain(`page2.locator("#name").fill("TextB")`);
expect(sources.get('Python Async')!.text).toContain(`await page1.locator("#name").fill("TextA")`);
expect(sources.get('Python Async')!.text).toContain(`await page2.locator("#name").fill("TextB")`);
expect(sources.get('C#')!.text).toContain(`await page1.Locator("#name").FillAsync("TextA");`);
expect(sources.get('C#')!.text).toContain(`await page2.Locator("#name").FillAsync("TextB");`);
});
test('click should emit events in order', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<button id=button>
<script>
button.addEventListener('mousedown', e => console.log(e.type));
button.addEventListener('mouseup', e => console.log(e.type));
button.addEventListener('click', e => console.log(e.type));
</script>
`);
const messages: any[] = [];
page.on('console', message => {
if (message.type() !== 'error')
messages.push(message.text());
});
await Promise.all([
page.click('button'),
recorder.waitForOutput('JavaScript', '.click(')
]);
await expect.poll(() => messages).toEqual(['mousedown', 'mouseup', 'click']);
});
test('should reset hover model on action when element detaches', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<input id="checkbox" onclick="document.getElementById('checkbox').remove()">`);
const [models] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.hovered).toBe(null);
});
test('should update active model on action', async ({ openRecorder, browserName, headless }) => {
test.fixme(browserName === 'webkit');
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
const [models] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.active).toBe('#checkbox');
});
test('should check input with chaining id', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name = 'updated'"></input>`);
await Promise.all([
recorder.waitForActionPerformed(),
page.click('input[id=checkbox]')
]);
});
test('should record navigations after identical pushState', async ({ openRecorder, server }) => {
const { page, recorder } = await openRecorder();
server.setRoute('/page2.html', (req, res) => {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello world');
});
await recorder.setContentAndWait(`
<script>
function pushState() {
history.pushState({}, 'title', '${server.PREFIX}');
}
</script>`, server.PREFIX);
for (let i = 1; i < 3; ++i)
await page.evaluate('pushState()');
await page.goto(server.PREFIX + '/page2.html');
await recorder.waitForOutput('JavaScript', `await page.goto('${server.PREFIX}/page2.html');`);
});
test('should save assets via SIGINT', async ({ runCLI, platform }, testInfo) => {
test.skip(platform === 'win32', 'SIGINT not supported on Windows');
const storageFileName = testInfo.outputPath('auth.json');
const harFileName = testInfo.outputPath('har.har');
const cli = runCLI([`--save-storage=${storageFileName}`, `--save-har=${harFileName}`]);
await cli.waitFor(`import { test, expect } from '@playwright/test'`);
// Since our interrupt is non-graceful, we need to wait for the process to settle.
// This test should be fixed.
await new Promise(resolve => setTimeout(resolve, 2000));
const { exitCode, signal } = await cli.sigint();
if (exitCode !== null) {
expect(exitCode).toBe(130);
} else {
// If the runner is slow enough, the process will be forcibly terminated by the signal
expect(signal).toBe('SIGINT');
}
expect(fs.existsSync(storageFileName)).toBeTruthy();
expect(fs.existsSync(harFileName)).toBeTruthy();
});
test('should fill tricky characters', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`<textarea spellcheck=false id="textarea" name="name" oninput="console.log(textarea.value)"></textarea>`);
const locator = await recorder.focusElement('textarea');
expect(locator).toBe(`locator('#textarea')`);
const [message, sources] = await Promise.all([
page.waitForEvent('console', msg => msg.type() !== 'error'),
recorder.waitForOutput('JavaScript', 'fill'),
page.fill('textarea', 'Hello\'\"\`\nWorld')
]);
expect(sources.get('JavaScript')!.text).toContain(`
await page.locator('#textarea').fill('Hello\\'"\`\\nWorld');`);
expect(sources.get('Java')!.text).toContain(`
page.locator("#textarea").fill("Hello'\\"\`\\nWorld");`);
expect(sources.get('Python')!.text).toContain(`
page.locator("#textarea").fill(\"Hello'\\"\`\\nWorld\")`);
expect(sources.get('Python Async')!.text).toContain(`
await page.locator("#textarea").fill(\"Hello'\\"\`\\nWorld\")`);
expect(sources.get('C#')!.text).toContain(`
await page.Locator("#textarea").FillAsync(\"Hello'\\"\`\\nWorld\");`);
expect(message.text()).toBe('Hello\'\"\`\nWorld');
});
test('should --test-id-attribute', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder({ testIdAttributeName: 'my-test-id' });
await recorder.setContentAndWait(`<div my-test-id="foo">Hello</div>`);
await page.click('[my-test-id=foo]');
const sources = await recorder.waitForOutput('JavaScript', `page.getByTestId`);
expect.soft(sources.get('JavaScript')!.text).toContain(`await page.getByTestId('foo').click()`);
expect.soft(sources.get('Java')!.text).toContain(`page.getByTestId("foo").click()`);
expect.soft(sources.get('Python')!.text).toContain(`page.get_by_test_id("foo").click()`);
expect.soft(sources.get('Python Async')!.text).toContain(`await page.get_by_test_id("foo").click()`);
expect.soft(sources.get('C#')!.text).toContain(`await page.GetByTestId("foo").ClickAsync();`);
});
test('should auto-generate toBeVisible', async ({ openRecorder }) => {
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
<button id=one>one</button>
<div id=insertion></div>
<button id=two>two</button>
<script>
const one = document.getElementById('one');
const insertion = document.getElementById('insertion');
one.addEventListener('click', () => {
insertion.innerHTML = '<h2>new header</h2>';
console.log('clicked one');
});
two.addEventListener('click', () => {
console.log('clicked two');
});
</script>
`);
await recorder.recorderPage.getByRole('button', { name: 'Settings' }).click();
await recorder.recorderPage.getByRole('checkbox', { name: 'Generate assertions' }).check();
const locatorOne = await recorder.hoverOverElement('#one');
expect(locatorOne).toBe(`getByRole('button', { name: 'one' })`);
await Promise.all([
page.waitForEvent('console', msg => msg.text() === 'clicked one'),
recorder.waitForOutput('JavaScript', 'one'),
recorder.trustedClick(),
]);
const locatorTwo = await recorder.hoverOverElement('#two');
expect(locatorTwo).toBe(`getByRole('button', { name: 'two' })`);
const [sources] = await Promise.all([
recorder.waitForOutput('JavaScript', 'two'),
page.waitForEvent('console', msg => msg.text() === 'clicked two'),
recorder.trustedClick(),
]);
expect.soft(sources.get('Playwright Test')!.text).toContain(`
await expect(page.getByRole('heading', { name: 'new header' })).toBeVisible();
await page.getByRole('button', { name: 'two' }).click();`);
expect.soft(sources.get('Python')!.text).toContain(`
expect(page.get_by_role("heading", name="new header")).to_be_visible()
page.get_by_role("button", name="two").click()`);
expect.soft(sources.get('Python Async')!.text).toContain(`
await expect(page.get_by_role("heading", name="new header")).to_be_visible()
await page.get_by_role("button", name="two").click()`);
expect.soft(sources.get('Java')!.text).toContain(`
assertThat(page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("new header"))).isVisible();
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("two")).click();`);
expect.soft(sources.get('C#')!.text).toContain(`
await Expect(page.GetByRole(AriaRole.Heading, new() { Name = "new header" })).ToBeVisibleAsync();
await page.GetByRole(AriaRole.Button, new() { Name = "two" }).ClickAsync();`);
});
});