Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: do not emit comments from codegen (#17747)
Pavel Feldman5754fb9c6d9c
diff --git a/packages/playwright-core/src/server/recorder/csharp.ts b/packages/playwright-core/src/server/recorder/csharp.tsindex b4455c9987..1b6d52721a 100644--- a/packages/playwright-core/src/server/recorder/csharp.ts+++ b/packages/playwright-core/src/server/recorder/csharp.ts@@ -19,7 +19,6 @@ import type { LanguageGenerator, LanguageGeneratorOptions } from './language';import { sanitizeDeviceOptions, toSignalMap } from './language';import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';-import { actionTitle } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';@@ -65,7 +64,6 @@ export class CSharpLanguageGenerator implements LanguageGenerator {if (this._mode !== 'library')pageAlias = pageAlias.replace('page', 'Page');const formatter = new CSharpFormatter(8);- formatter.add('// ' + actionTitle(action));if (action.name === 'openPage') {formatter.add(`var ${pageAlias} = await context.NewPageAsync();`);diff --git a/packages/playwright-core/src/server/recorder/java.ts b/packages/playwright-core/src/server/recorder/java.tsindex c0221a69ce..5eb65534df 100644--- a/packages/playwright-core/src/server/recorder/java.ts+++ b/packages/playwright-core/src/server/recorder/java.ts@@ -19,7 +19,6 @@ import type { LanguageGenerator, LanguageGeneratorOptions } from './language';import { toSignalMap } from './language';import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';-import { actionTitle } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import deviceDescriptors from '../deviceDescriptors';@@ -37,7 +36,6 @@ export class JavaLanguageGenerator implements LanguageGenerator {const pageAlias = actionInContext.frame.pageAlias;const formatter = new JavaScriptFormatter(6);formatter.newLine();- formatter.add('// ' + actionTitle(action));if (action.name === 'openPage') {formatter.add(`Page ${pageAlias} = context.newPage();`);diff --git a/packages/playwright-core/src/server/recorder/javascript.ts b/packages/playwright-core/src/server/recorder/javascript.tsindex af5118d5a1..895c851a0c 100644--- a/packages/playwright-core/src/server/recorder/javascript.ts+++ b/packages/playwright-core/src/server/recorder/javascript.ts@@ -19,7 +19,6 @@ import type { LanguageGenerator, LanguageGeneratorOptions } from './language';import { sanitizeDeviceOptions, toSignalMap } from './language';import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';-import { actionTitle } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import deviceDescriptors from '../deviceDescriptors';@@ -46,7 +45,6 @@ export class JavaScriptLanguageGenerator implements LanguageGenerator {const pageAlias = actionInContext.frame.pageAlias;const formatter = new JavaScriptFormatter(2);formatter.newLine();- formatter.add('// ' + actionTitle(action));if (action.name === 'openPage') {formatter.add(`const ${pageAlias} = await context.newPage();`);diff --git a/packages/playwright-core/src/server/recorder/python.ts b/packages/playwright-core/src/server/recorder/python.tsindex 32aa101a44..0055e6d680 100644--- a/packages/playwright-core/src/server/recorder/python.ts+++ b/packages/playwright-core/src/server/recorder/python.ts@@ -19,7 +19,6 @@ import type { LanguageGenerator, LanguageGeneratorOptions } from './language';import { sanitizeDeviceOptions, toSignalMap } from './language';import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';-import { actionTitle } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';@@ -53,7 +52,6 @@ export class PythonLanguageGenerator implements LanguageGenerator {const pageAlias = actionInContext.frame.pageAlias;const formatter = new PythonFormatter(4);formatter.newLine();- formatter.add('# ' + actionTitle(action));if (action.name === 'openPage') {formatter.add(`${pageAlias} = ${this._awaitPrefix}context.new_page()`);diff --git a/packages/playwright-core/src/server/recorder/recorderActions.ts b/packages/playwright-core/src/server/recorder/recorderActions.tsindex 96c2d77cd0..f51ab3de67 100644--- a/packages/playwright-core/src/server/recorder/recorderActions.ts+++ b/packages/playwright-core/src/server/recorder/recorderActions.ts@@ -127,38 +127,3 @@ export type FrameDescription = {name?: string;selectorsChain?: string[];};--export function actionTitle(action: Action): string {- switch (action.name) {- case 'openPage':- return `Open new page`;- case 'closePage':- return `Close page`;- case 'check':- return `Check ${action.selector}`;- case 'uncheck':- return `Uncheck ${action.selector}`;- case 'click': {- if (action.clickCount === 1)- return `Click ${action.selector}`;- if (action.clickCount === 2)- return `Double click ${action.selector}`;- if (action.clickCount === 3)- return `Triple click ${action.selector}`;- return `${action.clickCount}× click`;- }- case 'fill':- return `Fill ${action.selector}`;- case 'setInputFiles':- if (action.files.length === 0)- return `Clear selected files`;- else- return `Upload ${action.files.join(', ')}`;- case 'navigate':- return `Go to ${action.url}`;- case 'press':- return `Press ${action.key}` + (action.modifiers ? ' with modifiers' : '');- case 'select':- return `Select ${action.options.join(', ')}`;- }-}diff --git a/tests/library/inspector/cli-codegen-1.spec.ts b/tests/library/inspector/cli-codegen-1.spec.tsindex 28662b91fb..9f5cab42f8 100644--- a/tests/library/inspector/cli-codegen-1.spec.ts+++ b/tests/library/inspector/cli-codegen-1.spec.ts@@ -35,23 +35,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Submitawait page.locator('text=Submit').click();`);expect(sources.get('Python').text).toContain(`- # Click text=Submitpage.locator("text=Submit").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Submitawait page.locator("text=Submit").click()`);expect(sources.get('Java').text).toContain(`- // Click text=Submitpage.locator("text=Submit").click();`);expect(sources.get('C#').text).toContain(`- // Click text=Submitawait page.Locator("text=Submit").ClickAsync();`);expect(message.text()).toBe('click');@@ -83,7 +78,6 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Submitawait page.locator('text=Submit').click();`);expect(message.text()).toBe('click');});@@ -114,7 +108,6 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click canvasawait page.locator('canvas').click({position: {x: 250,@@ -123,20 +116,16 @@ test.describe('cli codegen', () => {});`);expect(sources.get('Python').text).toContain(`- # Click canvaspage.locator("canvas").click(position={"x":250,"y":250})`);expect(sources.get('Python Async').text).toContain(`- # Click canvasawait page.locator("canvas").click(position={"x":250,"y":250})`);expect(sources.get('Java').text).toContain(`- // Click canvaspage.locator("canvas").click(new Locator.ClickOptions().setPosition(250, 250));`);expect(sources.get('C#').text).toContain(`- // Click canvasawait page.Locator("canvas").ClickAsync(new LocatorClickOptions{Position = new Position@@ -169,23 +158,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Submitawait page.locator('text=Submit').click();`);expect(sources.get('Python').text).toContain(`- # Click text=Submitpage.locator("text=Submit").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Submitawait page.locator("text=Submit").click()`);expect(sources.get('Java').text).toContain(`- // Click text=Submitpage.locator("text=Submit").click();`);expect(sources.get('C#').text).toContain(`- // Click text=Submitawait page.Locator("text=Submit").ClickAsync();`);expect(message.text()).toBe('click');@@ -220,7 +204,6 @@ test.describe('cli codegen', () => {page.dispatchEvent('div', 'click', { detail: 1 })]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Some long text hereawait page.locator('text=Some long text here').click();`);expect(message.text()).toBe('click');});@@ -239,22 +222,17 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Fill input[name="name"]await page.locator('input[name="name"]').fill('John');`);expect(sources.get('Java').text).toContain(`- // Fill input[name="name"]page.locator("input[name=\\\"name\\\"]").fill("John");`);expect(sources.get('Python').text).toContain(`- # Fill input[name="name"]page.locator(\"input[name=\\\"name\\\"]\").fill(\"John\")`);expect(sources.get('Python Async').text).toContain(`- # Fill input[name="name"]await page.locator(\"input[name=\\\"name\\\"]\").fill(\"John\")`);expect(sources.get('C#').text).toContain(`- // Fill input[name="name"]await page.Locator(\"input[name=\\\"name\\\"]\").FillAsync(\"John\");`);expect(message.text()).toBe('John');@@ -278,22 +256,17 @@ test.describe('cli codegen', () => {})()]);expect(sources.get('JavaScript').text).toContain(`- // Fill input[name="name"]await page.locator('input[name="name"]').fill('てすと');`);expect(sources.get('Java').text).toContain(`- // Fill input[name="name"]page.locator("input[name=\\\"name\\\"]").fill("てすと");`);expect(sources.get('Python').text).toContain(`- # Fill input[name="name"]page.locator(\"input[name=\\\"name\\\"]\").fill(\"てすと\")`);expect(sources.get('Python Async').text).toContain(`- # Fill input[name="name"]await page.locator(\"input[name=\\\"name\\\"]\").fill(\"てすと\")`);expect(sources.get('C#').text).toContain(`- // Fill input[name="name"]await page.Locator(\"input[name=\\\"name\\\"]\").FillAsync(\"てすと\");`);expect(message.text()).toBe('てすと');@@ -312,7 +285,6 @@ test.describe('cli codegen', () => {page.fill('textarea', 'John')]);expect(sources.get('JavaScript').text).toContain(`- // Fill textarea[name="name"]await page.locator('textarea[name="name"]').fill('John');`);expect(message.text()).toBe('John');});@@ -334,23 +306,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Press Enter with modifiersawait page.locator('input[name="name"]').press('Shift+Enter');`);expect(sources.get('Java').text).toContain(`- // Press Enter with modifierspage.locator("input[name=\\\"name\\\"]").press("Shift+Enter");`);expect(sources.get('Python').text).toContain(`- # Press Enter with modifierspage.locator(\"input[name=\\\"name\\\"]\").press(\"Shift+Enter\")`);expect(sources.get('Python Async').text).toContain(`- # Press Enter with modifiersawait page.locator(\"input[name=\\\"name\\\"]\").press(\"Shift+Enter\")`);expect(sources.get('C#').text).toContain(`- // Press Enter with modifiersawait page.Locator(\"input[name=\\\"name\\\"]\").PressAsync(\"Shift+Enter\");`);expect(messages[0].text()).toBe('press');@@ -376,15 +343,12 @@ test.describe('cli codegen', () => {const text = recorder.sources().get('JavaScript').text;expect(text).toContain(`- // Fill input[name="one"]await page.locator('input[name="one"]').fill('foobar123');`);expect(text).toContain(`- // Press Tabawait page.locator('input[name="one"]').press('Tab');`);expect(text).toContain(`- // Fill input[name="two"]await page.locator('input[name="two"]').fill('barfoo321');`);});@@ -406,7 +370,6 @@ test.describe('cli codegen', () => {page.press('input', 'ArrowDown')]);expect(sources.get('JavaScript').text).toContain(`- // Press ArrowDownawait page.locator('input[name="name"]').press('ArrowDown');`);expect(messages[0].text()).toBe('press:ArrowDown');});@@ -430,7 +393,6 @@ test.describe('cli codegen', () => {page.press('input', 'ArrowDown')]);expect(sources.get('JavaScript').text).toContain(`- // Press ArrowDownawait page.locator('input[name="name"]').press('ArrowDown');`);expect(messages.length).toBe(2);expect(messages[0].text()).toBe('down:ArrowDown');@@ -452,23 +414,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Check input[name="accept"]await page.locator('input[name="accept"]').check();`);expect(sources.get('Java').text).toContain(`- // Check input[name="accept"]page.locator("input[name=\\\"accept\\\"]").check();`);expect(sources.get('Python').text).toContain(`- # Check input[name="accept"]page.locator(\"input[name=\\\"accept\\\"]\").check()`);expect(sources.get('Python Async').text).toContain(`- # Check input[name="accept"]await page.locator(\"input[name=\\\"accept\\\"]\").check()`);expect(sources.get('C#').text).toContain(`- // Check input[name="accept"]await page.Locator(\"input[name=\\\"accept\\\"]\").CheckAsync();`);expect(message.text()).toBe('true');@@ -489,7 +446,6 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Check input[name="accept"]await page.locator('input[name="accept"]').check();`);expect(message.text()).toBe('true');});@@ -509,7 +465,6 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Check input[name="accept"]await page.locator('input[name="accept"]').check();`);expect(message.text()).toBe('true');});@@ -529,23 +484,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Uncheck input[name="accept"]await page.locator('input[name="accept"]').uncheck();`);expect(sources.get('Java').text).toContain(`- // Uncheck input[name="accept"]page.locator("input[name=\\\"accept\\\"]").uncheck();`);expect(sources.get('Python').text).toContain(`- # Uncheck input[name="accept"]page.locator(\"input[name=\\\"accept\\\"]\").uncheck()`);expect(sources.get('Python Async').text).toContain(`- # Uncheck input[name="accept"]await page.locator(\"input[name=\\\"accept\\\"]\").uncheck()`);expect(sources.get('C#').text).toContain(`- // Uncheck input[name="accept"]await page.Locator(\"input[name=\\\"accept\\\"]\").UncheckAsync();`);expect(message.text()).toBe('false');@@ -566,23 +516,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Select 2await page.locator('select').selectOption('2');`);expect(sources.get('Java').text).toContain(`- // Select 2page.locator("select").selectOption("2");`);expect(sources.get('Python').text).toContain(`- # Select 2page.locator(\"select\").select_option(\"2\")`);expect(sources.get('Python Async').text).toContain(`- # Select 2await page.locator(\"select\").select_option(\"2\")`);expect(sources.get('C#').text).toContain(`- // Select 2await page.Locator(\"select\").SelectOptionAsync(new[] { \"2\" });`);expect(message.text()).toBe('2');@@ -604,26 +549,22 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=linkconst [page1] = await Promise.all([page.waitForEvent('popup'),page.locator('text=link').click()]);`);expect(sources.get('Java').text).toContain(`- // Click text=linkPage page1 = page.waitForPopup(() -> {page.locator("text=link").click();});`);expect(sources.get('Python').text).toContain(`- # Click text=linkwith page.expect_popup() as popup_info:page.locator(\"text=link\").click()page1 = popup_info.value`);expect(sources.get('Python Async').text).toContain(`- # Click text=linkasync with page.expect_popup() as popup_info:await page.locator(\"text=link\").click()page1 = await popup_info.value`);@@ -651,37 +592,30 @@ test.describe('cli codegen', () => {]);expect.soft(sources.get('JavaScript').text).toContain(`- // Click text=linkawait page.locator('text=link').click();await page.waitForURL('about:blank#foo');`);expect.soft(sources.get('Playwright Test').text).toContain(`- // Click text=linkawait page.locator('text=link').click();await expect(page).toHaveURL('about:blank#foo');`);expect.soft(sources.get('Java').text).toContain(`- // Click text=linkpage.locator("text=link").click();assertThat(page).hasURL("about:blank#foo");`);expect.soft(sources.get('Python').text).toContain(`- # Click text=linkpage.locator("text=link").click()page.wait_for_url("about:blank#foo")`);expect.soft(sources.get('Python Async').text).toContain(`- # Click text=linkawait page.locator("text=link").click()await page.wait_for_url("about:blank#foo")`);expect.soft(sources.get('Pytest').text).toContain(`- # Click text=linkpage.locator("text=link").click()expect(page).to_have_url("about:blank#foo")`);expect.soft(sources.get('C#').text).toContain(`- // Click text=linkawait page.Locator("text=link").ClickAsync();await page.WaitForURLAsync("about:blank#foo");`);@@ -704,27 +638,22 @@ test.describe('cli codegen', () => {]);expect.soft(sources.get('JavaScript').text).toContain(`- // Click text=linkawait page.locator('text=link').click();await page.waitForURL('about:blank#foo');`);expect.soft(sources.get('Java').text).toContain(`- // Click text=linkpage.locator("text=link").click();assertThat(page).hasURL("about:blank#foo");`);expect.soft(sources.get('Python').text).toContain(`- # Click text=linkpage.locator(\"text=link\").click()page.wait_for_url("about:blank#foo")`);expect.soft(sources.get('Python Async').text).toContain(`- # Click text=linkawait page.locator(\"text=link\").click()await page.wait_for_url("about:blank#foo")`);expect.soft(sources.get('C#').text).toContain(`- // Click text=linkawait page.Locator(\"text=link\").ClickAsync();await page.WaitForURLAsync(\"about:blank#foo\");`);diff --git a/tests/library/inspector/cli-codegen-2.spec.ts b/tests/library/inspector/cli-codegen-2.spec.tsindex 0720ba563e..4e51f8fb19 100644--- a/tests/library/inspector/cli-codegen-2.spec.ts+++ b/tests/library/inspector/cli-codegen-2.spec.ts@@ -28,23 +28,18 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', `page.goto`);expect(sources.get('JavaScript').text).toContain(`- // Open new pageconst page = await context.newPage();`);expect(sources.get('Java').text).toContain(`- // Open new pagePage page = context.newPage();`);expect(sources.get('Python').text).toContain(`- # Open new pagepage = context.new_page()`);expect(sources.get('Python Async').text).toContain(`- # Open new pagepage = await context.new_page()`);expect(sources.get('C#').text).toContain(`- // Open new pagevar page = await context.NewPageAsync();`);});@@ -56,23 +51,18 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', 'page1');expect(sources.get('JavaScript').text).toContain(`- // Open new pageconst page1 = await context.newPage();`);expect(sources.get('Java').text).toContain(`- // Open new pagePage page1 = context.newPage();`);expect(sources.get('Python').text).toContain(`- # Open new pagepage1 = context.new_page()`);expect(sources.get('Python Async').text).toContain(`- # Open new pagepage1 = await context.new_page()`);expect(sources.get('C#').text).toContain(`- // Open new pagevar page1 = await context.NewPageAsync();`);});@@ -132,23 +122,18 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');expect(sources.get('JavaScript').text).toContain(`- // Upload file-to-upload.txtawait page.locator('input[type="file"]').setInputFiles('file-to-upload.txt');`);expect(sources.get('Java').text).toContain(`- // Upload file-to-upload.txtpage.locator("input[type=\\\"file\\\"]").setInputFiles(Paths.get("file-to-upload.txt"));`);expect(sources.get('Python').text).toContain(`- # Upload file-to-upload.txtpage.locator(\"input[type=\\\"file\\\"]\").set_input_files(\"file-to-upload.txt\")`);expect(sources.get('Python Async').text).toContain(`- # Upload file-to-upload.txtawait page.locator(\"input[type=\\\"file\\\"]\").set_input_files(\"file-to-upload.txt\")`);expect(sources.get('C#').text).toContain(`- // Upload file-to-upload.txtawait page.Locator(\"input[type=\\\"file\\\"]\").SetInputFilesAsync(new[] { \"file-to-upload.txt\" });`);});@@ -169,23 +154,18 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');expect(sources.get('JavaScript').text).toContain(`- // Upload file-to-upload.txt, file-to-upload-2.txtawait page.locator('input[type=\"file\"]').setInputFiles(['file-to-upload.txt', 'file-to-upload-2.txt']);`);expect(sources.get('Java').text).toContain(`- // Upload file-to-upload.txt, file-to-upload-2.txtpage.locator("input[type=\\\"file\\\"]").setInputFiles(new Path[] {Paths.get("file-to-upload.txt"), Paths.get("file-to-upload-2.txt")});`);expect(sources.get('Python').text).toContain(`- # Upload file-to-upload.txt, file-to-upload-2.txtpage.locator(\"input[type=\\\"file\\\"]\").set_input_files([\"file-to-upload.txt\", \"file-to-upload-2.txt\"]`);expect(sources.get('Python Async').text).toContain(`- # Upload file-to-upload.txt, file-to-upload-2.txtawait page.locator(\"input[type=\\\"file\\\"]\").set_input_files([\"file-to-upload.txt\", \"file-to-upload-2.txt\"]`);expect(sources.get('C#').text).toContain(`- // Upload file-to-upload.txt, file-to-upload-2.txtawait page.Locator(\"input[type=\\\"file\\\"]\").SetInputFilesAsync(new[] { \"file-to-upload.txt\", \"file-to-upload-2.txt\" });`);});@@ -206,23 +186,18 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', 'setInputFiles');expect(sources.get('JavaScript').text).toContain(`- // Clear selected filesawait page.locator('input[type=\"file\"]').setInputFiles([]);`);expect(sources.get('Java').text).toContain(`- // Clear selected filespage.locator("input[type=\\\"file\\\"]").setInputFiles(new Path[0]);`);expect(sources.get('Python').text).toContain(`- # Clear selected filespage.locator(\"input[type=\\\"file\\\"]\").set_input_files([])`);expect(sources.get('Python Async').text).toContain(`- # Clear selected filesawait page.locator(\"input[type=\\\"file\\\"]\").set_input_files([])`);expect(sources.get('C#').text).toContain(`- // Clear selected filesawait page.Locator(\"input[type=\\\"file\\\"]\").SetInputFilesAsync(new[] { });`);});@@ -254,7 +229,6 @@ test.describe('cli codegen', () => {expect(sources.get('JavaScript').text).toContain(`const context = await browser.newContext();`);expect(sources.get('JavaScript').text).toContain(`- // Click text=Downloadconst [download] = await Promise.all([page.waitForEvent('download'),page.locator('text=Download').click()@@ -263,7 +237,6 @@ test.describe('cli codegen', () => {expect(sources.get('Java').text).toContain(`BrowserContext context = browser.newContext();`);expect(sources.get('Java').text).toContain(`- // Click text=DownloadDownload download = page.waitForDownload(() -> {page.locator("text=Download").click();});`);@@ -271,7 +244,6 @@ test.describe('cli codegen', () => {expect(sources.get('Python').text).toContain(`context = browser.new_context()`);expect(sources.get('Python').text).toContain(`- # Click text=Downloadwith page.expect_download() as download_info:page.locator(\"text=Download\").click()download = download_info.value`);@@ -279,7 +251,6 @@ test.describe('cli codegen', () => {expect(sources.get('Python Async').text).toContain(`context = await browser.new_context()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Downloadasync with page.expect_download() as download_info:await page.locator(\"text=Download\").click()download = await download_info.value`);@@ -287,7 +258,6 @@ test.describe('cli codegen', () => {expect(sources.get('C#').text).toContain(`var context = await browser.NewContextAsync();`);expect(sources.get('C#').text).toContain(`- // Click text=Downloadvar download1 = await page.RunAndWaitForDownloadAsync(async () =>{await page.Locator(\"text=Download\").ClickAsync();@@ -309,7 +279,6 @@ test.describe('cli codegen', () => {const sources = await recorder.waitForOutput('JavaScript', 'once');expect(sources.get('JavaScript').text).toContain(`- // Click text=click mepage.once('dialog', dialog => {console.log(\`Dialog message: \${dialog.message()}\`);dialog.dismiss().catch(() => {});@@ -317,7 +286,6 @@ test.describe('cli codegen', () => {await page.locator('text=click me').click();`);expect(sources.get('Java').text).toContain(`- // Click text=click mepage.onceDialog(dialog -> {System.out.println(String.format("Dialog message: %s", dialog.message()));dialog.dismiss();@@ -325,17 +293,14 @@ test.describe('cli codegen', () => {page.locator("text=click me").click();`);expect(sources.get('Python').text).toContain(`- # Click text=click mepage.once(\"dialog\", lambda dialog: dialog.dismiss())page.locator(\"text=click me\").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=click mepage.once(\"dialog\", lambda dialog: dialog.dismiss())await page.locator(\"text=click me\").click()`);expect(sources.get('C#').text).toContain(`- // Click text=click mevoid page_Dialog1_EventHandler(object sender, IDialog dialog){Console.WriteLine($\"Dialog message: {dialog.Message}\");@@ -375,20 +340,16 @@ test.describe('cli codegen', () => {if (browserName !== 'firefox') {expect(sources.get('JavaScript').text).toContain(`- // Open new pageconst page1 = await context.newPage();await page1.goto('about:blank?foo');`);expect(sources.get('Python Async').text).toContain(`- # Open new pagepage1 = await context.new_page()await page1.goto("about:blank?foo")`);expect(sources.get('C#').text).toContain(`- // Open new pagevar page1 = await context.NewPageAsync();await page1.GotoAsync("about:blank?foo");`);} else {expect(sources.get('JavaScript').text).toContain(`- // Click text=linkconst [page1] = await Promise.all([page.waitForEvent('popup'),page.locator('text=link').click({@@ -576,23 +537,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Fill textarea[name="name"]await page.locator('textarea[name="name"]').fill('Hello\\'"\`\\nWorld');`);expect(sources.get('Java').text).toContain(`- // Fill textarea[name="name"]page.locator("textarea[name=\\\"name\\\"]").fill("Hello'\\"\`\\nWorld");`);expect(sources.get('Python').text).toContain(`- # Fill textarea[name="name"]page.locator(\"textarea[name=\\\"name\\\"]\").fill(\"Hello'\\"\`\\nWorld\")`);expect(sources.get('Python Async').text).toContain(`- # Fill textarea[name="name"]await page.locator(\"textarea[name=\\\"name\\\"]\").fill(\"Hello'\\"\`\\nWorld\")`);expect(sources.get('C#').text).toContain(`- // Fill textarea[name="name"]await page.Locator(\"textarea[name=\\\"name\\\"]\").FillAsync(\"Hello'\\"\`\\nWorld\");`);expect(message.text()).toBe('Hello\'\"\`\nWorld');diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.tsindex 8997ee26dd..853fde6173 100644--- a/tests/library/inspector/cli-codegen-3.spec.ts+++ b/tests/library/inspector/cli-codegen-3.spec.ts@@ -37,23 +37,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Submit >> nth=0await page.locator('text=Submit').first().click();`);expect(sources.get('Python').text).toContain(`- # Click text=Submit >> nth=0page.locator("text=Submit").first.click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Submit >> nth=0await page.locator("text=Submit").first.click()`);expect(sources.get('Java').text).toContain(`- // Click text=Submit >> nth=0page.locator("text=Submit").first().click();`);expect(sources.get('C#').text).toContain(`- // Click text=Submit >> nth=0await page.Locator("text=Submit").First.ClickAsync();`);expect(message.text()).toBe('click1');@@ -77,23 +72,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Submit >> nth=1await page.locator('text=Submit').nth(1).click();`);expect(sources.get('Python').text).toContain(`- # Click text=Submit >> nth=1page.locator("text=Submit").nth(1).click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Submit >> nth=1await page.locator("text=Submit").nth(1).click()`);expect(sources.get('Java').text).toContain(`- // Click text=Submit >> nth=1page.locator("text=Submit").nth(1).click();`);expect(sources.get('C#').text).toContain(`- // Click text=Submit >> nth=1await page.Locator("text=Submit").Nth(1).ClickAsync();`);expect(message.text()).toBe('click2');@@ -131,23 +121,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Hello1await page.frameLocator('#frame1').locator('text=Hello1').click();`);expect(sources.get('Java').text).toContain(`- // Click text=Hello1page.frameLocator("#frame1").locator("text=Hello1").click();`);expect(sources.get('Python').text).toContain(`- # Click text=Hello1page.frame_locator("#frame1").locator("text=Hello1").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Hello1await page.frame_locator("#frame1").locator("text=Hello1").click()`);expect(sources.get('C#').text).toContain(`- // Click text=Hello1await page.FrameLocator("#frame1").Locator("text=Hello1").ClickAsync();`);@@ -157,23 +142,18 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=Hello2await page.frameLocator('#frame1').frameLocator('iframe').locator('text=Hello2').click();`);expect(sources.get('Java').text).toContain(`- // Click text=Hello2page.frameLocator("#frame1").frameLocator("iframe").locator("text=Hello2").click();`);expect(sources.get('Python').text).toContain(`- # Click text=Hello2page.frame_locator("#frame1").frame_locator("iframe").locator("text=Hello2").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=Hello2await page.frame_locator("#frame1").frame_locator("iframe").locator("text=Hello2").click()`);expect(sources.get('C#').text).toContain(`- // Click text=Hello2await page.FrameLocator("#frame1").FrameLocator("iframe").Locator("text=Hello2").ClickAsync();`);@@ -183,25 +163,20 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=HelloNameOneawait page.frame({name: 'one'}).locator('text=HelloNameOne').click();`);expect(sources.get('Java').text).toContain(`- // Click text=HelloNameOnepage.frame("one").locator("text=HelloNameOne").click();`);expect(sources.get('Python').text).toContain(`- # Click text=HelloNameOnepage.frame(name=\"one\").locator(\"text=HelloNameOne\").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=HelloNameOneawait page.frame(name=\"one\").locator(\"text=HelloNameOne\").click()`);expect(sources.get('C#').text).toContain(`- // Click text=HelloNameOneawait page.Frame(\"one\").Locator(\"text=HelloNameOne\").ClickAsync();`);@@ -211,25 +186,20 @@ test.describe('cli codegen', () => {]);expect(sources.get('JavaScript').text).toContain(`- // Click text=HelloNameAnonymousawait page.frame({url: 'about:blank'}).locator('text=HelloNameAnonymous').click();`);expect(sources.get('Java').text).toContain(`- // Click text=HelloNameAnonymouspage.frameByUrl("about:blank").locator("text=HelloNameAnonymous").click();`);expect(sources.get('Python').text).toContain(`- # Click text=HelloNameAnonymouspage.frame(url=\"about:blank\").locator(\"text=HelloNameAnonymous\").click()`);expect(sources.get('Python Async').text).toContain(`- # Click text=HelloNameAnonymousawait page.frame(url=\"about:blank\").locator(\"text=HelloNameAnonymous\").click()`);expect(sources.get('C#').text).toContain(`- // Click text=HelloNameAnonymousawait page.FrameByUrl(\"about:blank\").Locator(\"text=HelloNameAnonymous\").ClickAsync();`);});});diff --git a/tests/library/inspector/cli-codegen-csharp.spec.ts b/tests/library/inspector/cli-codegen-csharp.spec.tsindex dfac43f328..767302114d 100644--- a/tests/library/inspector/cli-codegen-csharp.spec.ts+++ b/tests/library/inspector/cli-codegen-csharp.spec.ts@@ -235,7 +235,6 @@ public class Tests : PageTest[TestMethod]public async Task MyTest(){- // Go to ${emptyHTML}await Page.GotoAsync("${emptyHTML}");}@@ -264,7 +263,6 @@ public class Tests : PageTest[Test]public async Task MyTest(){- // Go to ${emptyHTML}await Page.GotoAsync("${emptyHTML}");}diff --git a/tests/library/inspector/cli-codegen-javascript.spec.ts b/tests/library/inspector/cli-codegen-javascript.spec.tsindex 4f76fdd7f3..59e02c292a 100644--- a/tests/library/inspector/cli-codegen-javascript.spec.ts+++ b/tests/library/inspector/cli-codegen-javascript.spec.ts@@ -101,13 +101,10 @@ test('should save the codegen output to a file if specified', async ({ browserNa});const context = await browser.newContext();- // Open new pageconst page = await context.newPage();- // Go to ${emptyHTML}await page.goto('${emptyHTML}');- // Close pageawait page.close();// ---------------------diff --git a/tests/library/inspector/cli-codegen-pytest.spec.ts b/tests/library/inspector/cli-codegen-pytest.spec.tsindex 03728cbcde..949da8ceff 100644--- a/tests/library/inspector/cli-codegen-pytest.spec.ts+++ b/tests/library/inspector/cli-codegen-pytest.spec.ts@@ -49,7 +49,6 @@ def browser_context_args(browser_context_args, playwright):def test_example(page: Page) -> None:- # Go to ${emptyHTML}page.goto("${emptyHTML}")`);});@@ -64,7 +63,6 @@ test('should save the codegen output to a file if specified', async ({ runCLI },def test_example(page: Page) -> None:- # Go to ${emptyHTML}page.goto("${emptyHTML}")`);});diff --git a/tests/library/inspector/cli-codegen-python-async.spec.ts b/tests/library/inspector/cli-codegen-python-async.spec.tsindex 7df2935672..3439387fbe 100644--- a/tests/library/inspector/cli-codegen-python-async.spec.ts+++ b/tests/library/inspector/cli-codegen-python-async.spec.ts@@ -97,13 +97,10 @@ async def run(playwright: Playwright) -> None:browser = await playwright.${browserName}.launch(${launchOptions(channel)})context = await browser.new_context()- # Open new pagepage = await context.new_page()- # Go to ${emptyHTML}await page.goto("${emptyHTML}")- # Close pageawait page.close()# ---------------------diff --git a/tests/library/inspector/cli-codegen-python.spec.ts b/tests/library/inspector/cli-codegen-python.spec.tsindex b0b5e19dc2..6b2dd2a0d1 100644--- a/tests/library/inspector/cli-codegen-python.spec.ts+++ b/tests/library/inspector/cli-codegen-python.spec.ts@@ -87,13 +87,10 @@ def run(playwright: Playwright) -> None:browser = playwright.${browserName}.launch(${launchOptions(channel)})context = browser.new_context()- # Open new pagepage = context.new_page()- # Go to ${emptyHTML}page.goto("${emptyHTML}")- # Close pagepage.close()# ---------------------