Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(codegen): update csharp boilerplate (#6742)
Dmitry Gozman9dd2f8336196
diff --git a/src/server/supplements/recorder/csharp.ts b/src/server/supplements/recorder/csharp.tsindex 5df0717adc..4dae699fcc 100644--- a/src/server/supplements/recorder/csharp.ts+++ b/src/server/supplements/recorder/csharp.ts@@ -133,13 +133,13 @@ export class CSharpLanguageGenerator implements LanguageGenerator {generateHeader(options: LanguageGeneratorOptions): string {const formatter = new CSharpFormatter(0);formatter.add(`+ using Microsoft.Playwright;using System;using System.Threading.Tasks;- using Microsoft.Playwright;- class Example+ class Program{- static async Task Main(string[] args)+ public static async Task Main(){using var playwright = await Playwright.CreateAsync();await using var browser = await playwright.${toPascal(options.browserName)}.LaunchAsync(${formatObject(options.launchOptions, ' ', 'BrowserTypeLaunchOptions')});@@ -150,7 +150,7 @@ export class CSharpLanguageGenerator implements LanguageGenerator {generateFooter(saveStorage: string | undefined): string {const storageStateLine = saveStorage ? `\n await context.StorageStateAsync(new BrowserContextStorageStateOptions\n {\n Path = ${quote(saveStorage)}\n });\n` : '';return `${storageStateLine} }-}`;+}\n`;}}diff --git a/tests/inspector/cli-codegen-csharp.spec.ts b/tests/inspector/cli-codegen-csharp.spec.tsindex fd85744464..845e498be6 100644--- a/tests/inspector/cli-codegen-csharp.spec.ts+++ b/tests/inspector/cli-codegen-csharp.spec.ts@@ -29,7 +29,15 @@ function capitalize(browserName: string): string {test('should print the correct imports and context options', async ({ browserName, channel, runCLI }) => {const cli = runCLI(['--target=csharp', emptyHTML]);- const expectedResult = ` using var playwright = await Playwright.CreateAsync();+ const expectedResult = `using Microsoft.Playwright;+using System;+using System.Threading.Tasks;++class Program+{+ public static async Task Main()+ {+ using var playwright = await Playwright.CreateAsync();await using var browser = await playwright.${capitalize(browserName)}.LaunchAsync(new BrowserTypeLaunchOptions{${launchOptions(channel)}