chore: do not emit comments from codegen (#17747)
This commit is contained in:
parent
be150796f4
commit
5754fb9c6d
|
|
@ -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();`);
|
||||
|
|
|
|||
|
|
@ -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();`);
|
||||
|
|
|
|||
|
|
@ -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();`);
|
||||
|
|
|
|||
|
|
@ -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()`);
|
||||
|
|
|
|||
|
|
@ -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(', ')}`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,23 +35,18 @@ test.describe('cli codegen', () => {
|
|||
]);
|
||||
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Click text=Submit
|
||||
await page.locator('text=Submit').click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Submit
|
||||
page.locator("text=Submit").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Submit
|
||||
await page.locator("text=Submit").click()`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Submit
|
||||
page.locator("text=Submit").click();`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Submit
|
||||
await 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=Submit
|
||||
await 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 canvas
|
||||
await page.locator('canvas').click({
|
||||
position: {
|
||||
x: 250,
|
||||
|
|
@ -123,20 +116,16 @@ test.describe('cli codegen', () => {
|
|||
});`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click canvas
|
||||
page.locator("canvas").click(position={"x":250,"y":250})`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click canvas
|
||||
await page.locator("canvas").click(position={"x":250,"y":250})`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click canvas
|
||||
page.locator("canvas").click(new Locator.ClickOptions()
|
||||
.setPosition(250, 250));`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click canvas
|
||||
await 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=Submit
|
||||
await page.locator('text=Submit').click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Submit
|
||||
page.locator("text=Submit").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Submit
|
||||
await page.locator("text=Submit").click()`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Submit
|
||||
page.locator("text=Submit").click();`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Submit
|
||||
await 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 here
|
||||
await 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 modifiers
|
||||
await page.locator('input[name="name"]').press('Shift+Enter');`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Press Enter with modifiers
|
||||
page.locator("input[name=\\\"name\\\"]").press("Shift+Enter");`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Press Enter with modifiers
|
||||
page.locator(\"input[name=\\\"name\\\"]\").press(\"Shift+Enter\")`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Press Enter with modifiers
|
||||
await page.locator(\"input[name=\\\"name\\\"]\").press(\"Shift+Enter\")`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Press Enter with modifiers
|
||||
await 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 Tab
|
||||
await 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 ArrowDown
|
||||
await 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 ArrowDown
|
||||
await 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 2
|
||||
await page.locator('select').selectOption('2');`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Select 2
|
||||
page.locator("select").selectOption("2");`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Select 2
|
||||
page.locator(\"select\").select_option(\"2\")`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Select 2
|
||||
await page.locator(\"select\").select_option(\"2\")`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Select 2
|
||||
await 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=link
|
||||
const [page1] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
page.locator('text=link').click()
|
||||
]);`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=link
|
||||
Page page1 = page.waitForPopup(() -> {
|
||||
page.locator("text=link").click();
|
||||
});`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=link
|
||||
with page.expect_popup() as popup_info:
|
||||
page.locator(\"text=link\").click()
|
||||
page1 = popup_info.value`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=link
|
||||
async 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=link
|
||||
await page.locator('text=link').click();
|
||||
await page.waitForURL('about:blank#foo');`);
|
||||
|
||||
expect.soft(sources.get('Playwright Test').text).toContain(`
|
||||
// Click text=link
|
||||
await page.locator('text=link').click();
|
||||
await expect(page).toHaveURL('about:blank#foo');`);
|
||||
|
||||
expect.soft(sources.get('Java').text).toContain(`
|
||||
// Click text=link
|
||||
page.locator("text=link").click();
|
||||
assertThat(page).hasURL("about:blank#foo");`);
|
||||
|
||||
expect.soft(sources.get('Python').text).toContain(`
|
||||
# Click text=link
|
||||
page.locator("text=link").click()
|
||||
page.wait_for_url("about:blank#foo")`);
|
||||
|
||||
expect.soft(sources.get('Python Async').text).toContain(`
|
||||
# Click text=link
|
||||
await page.locator("text=link").click()
|
||||
await page.wait_for_url("about:blank#foo")`);
|
||||
|
||||
expect.soft(sources.get('Pytest').text).toContain(`
|
||||
# Click text=link
|
||||
page.locator("text=link").click()
|
||||
expect(page).to_have_url("about:blank#foo")`);
|
||||
|
||||
expect.soft(sources.get('C#').text).toContain(`
|
||||
// Click text=link
|
||||
await 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=link
|
||||
await page.locator('text=link').click();
|
||||
await page.waitForURL('about:blank#foo');`);
|
||||
|
||||
expect.soft(sources.get('Java').text).toContain(`
|
||||
// Click text=link
|
||||
page.locator("text=link").click();
|
||||
assertThat(page).hasURL("about:blank#foo");`);
|
||||
|
||||
expect.soft(sources.get('Python').text).toContain(`
|
||||
# Click text=link
|
||||
page.locator(\"text=link\").click()
|
||||
page.wait_for_url("about:blank#foo")`);
|
||||
|
||||
expect.soft(sources.get('Python Async').text).toContain(`
|
||||
# Click text=link
|
||||
await page.locator(\"text=link\").click()
|
||||
await page.wait_for_url("about:blank#foo")`);
|
||||
|
||||
expect.soft(sources.get('C#').text).toContain(`
|
||||
// Click text=link
|
||||
await page.Locator(\"text=link\").ClickAsync();
|
||||
await page.WaitForURLAsync(\"about:blank#foo\");`);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,23 +28,18 @@ test.describe('cli codegen', () => {
|
|||
const sources = await recorder.waitForOutput('JavaScript', `page.goto`);
|
||||
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Open new page
|
||||
const page = await context.newPage();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Open new page
|
||||
Page page = context.newPage();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Open new page
|
||||
page = context.new_page()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Open new page
|
||||
page = await context.new_page()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Open new page
|
||||
var 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 page
|
||||
const page1 = await context.newPage();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Open new page
|
||||
Page page1 = context.newPage();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Open new page
|
||||
page1 = context.new_page()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Open new page
|
||||
page1 = await context.new_page()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Open new page
|
||||
var 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.txt
|
||||
await page.locator('input[type="file"]').setInputFiles('file-to-upload.txt');`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Upload file-to-upload.txt
|
||||
page.locator("input[type=\\\"file\\\"]").setInputFiles(Paths.get("file-to-upload.txt"));`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Upload file-to-upload.txt
|
||||
page.locator(\"input[type=\\\"file\\\"]\").set_input_files(\"file-to-upload.txt\")`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Upload file-to-upload.txt
|
||||
await page.locator(\"input[type=\\\"file\\\"]\").set_input_files(\"file-to-upload.txt\")`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Upload file-to-upload.txt
|
||||
await 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.txt
|
||||
await 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.txt
|
||||
page.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.txt
|
||||
page.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.txt
|
||||
await 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.txt
|
||||
await 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 files
|
||||
await page.locator('input[type=\"file\"]').setInputFiles([]);`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Clear selected files
|
||||
page.locator("input[type=\\\"file\\\"]").setInputFiles(new Path[0]);`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Clear selected files
|
||||
page.locator(\"input[type=\\\"file\\\"]\").set_input_files([])`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Clear selected files
|
||||
await page.locator(\"input[type=\\\"file\\\"]\").set_input_files([])`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Clear selected files
|
||||
await 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=Download
|
||||
const [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=Download
|
||||
Download 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=Download
|
||||
with 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=Download
|
||||
async 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=Download
|
||||
var 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 me
|
||||
page.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 me
|
||||
page.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 me
|
||||
page.once(\"dialog\", lambda dialog: dialog.dismiss())
|
||||
page.locator(\"text=click me\").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=click me
|
||||
page.once(\"dialog\", lambda dialog: dialog.dismiss())
|
||||
await page.locator(\"text=click me\").click()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=click me
|
||||
void 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 page
|
||||
const page1 = await context.newPage();
|
||||
await page1.goto('about:blank?foo');`);
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Open new page
|
||||
page1 = await context.new_page()
|
||||
await page1.goto("about:blank?foo")`);
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Open new page
|
||||
var page1 = await context.NewPageAsync();
|
||||
await page1.GotoAsync("about:blank?foo");`);
|
||||
} else {
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Click text=link
|
||||
const [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');
|
||||
|
|
|
|||
|
|
@ -37,23 +37,18 @@ test.describe('cli codegen', () => {
|
|||
]);
|
||||
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Click text=Submit >> nth=0
|
||||
await page.locator('text=Submit').first().click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Submit >> nth=0
|
||||
page.locator("text=Submit").first.click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Submit >> nth=0
|
||||
await page.locator("text=Submit").first.click()`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Submit >> nth=0
|
||||
page.locator("text=Submit").first().click();`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Submit >> nth=0
|
||||
await 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=1
|
||||
await page.locator('text=Submit').nth(1).click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Submit >> nth=1
|
||||
page.locator("text=Submit").nth(1).click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Submit >> nth=1
|
||||
await page.locator("text=Submit").nth(1).click()`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Submit >> nth=1
|
||||
page.locator("text=Submit").nth(1).click();`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Submit >> nth=1
|
||||
await 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=Hello1
|
||||
await page.frameLocator('#frame1').locator('text=Hello1').click();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Hello1
|
||||
page.frameLocator("#frame1").locator("text=Hello1").click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Hello1
|
||||
page.frame_locator("#frame1").locator("text=Hello1").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Hello1
|
||||
await page.frame_locator("#frame1").locator("text=Hello1").click()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Hello1
|
||||
await page.FrameLocator("#frame1").Locator("text=Hello1").ClickAsync();`);
|
||||
|
||||
|
||||
|
|
@ -157,23 +142,18 @@ test.describe('cli codegen', () => {
|
|||
]);
|
||||
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Click text=Hello2
|
||||
await page.frameLocator('#frame1').frameLocator('iframe').locator('text=Hello2').click();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=Hello2
|
||||
page.frameLocator("#frame1").frameLocator("iframe").locator("text=Hello2").click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=Hello2
|
||||
page.frame_locator("#frame1").frame_locator("iframe").locator("text=Hello2").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=Hello2
|
||||
await page.frame_locator("#frame1").frame_locator("iframe").locator("text=Hello2").click()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=Hello2
|
||||
await 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=HelloNameOne
|
||||
await page.frame({
|
||||
name: 'one'
|
||||
}).locator('text=HelloNameOne').click();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=HelloNameOne
|
||||
page.frame("one").locator("text=HelloNameOne").click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=HelloNameOne
|
||||
page.frame(name=\"one\").locator(\"text=HelloNameOne\").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=HelloNameOne
|
||||
await page.frame(name=\"one\").locator(\"text=HelloNameOne\").click()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=HelloNameOne
|
||||
await page.Frame(\"one\").Locator(\"text=HelloNameOne\").ClickAsync();`);
|
||||
|
||||
|
||||
|
|
@ -211,25 +186,20 @@ test.describe('cli codegen', () => {
|
|||
]);
|
||||
|
||||
expect(sources.get('JavaScript').text).toContain(`
|
||||
// Click text=HelloNameAnonymous
|
||||
await page.frame({
|
||||
url: 'about:blank'
|
||||
}).locator('text=HelloNameAnonymous').click();`);
|
||||
|
||||
expect(sources.get('Java').text).toContain(`
|
||||
// Click text=HelloNameAnonymous
|
||||
page.frameByUrl("about:blank").locator("text=HelloNameAnonymous").click();`);
|
||||
|
||||
expect(sources.get('Python').text).toContain(`
|
||||
# Click text=HelloNameAnonymous
|
||||
page.frame(url=\"about:blank\").locator(\"text=HelloNameAnonymous\").click()`);
|
||||
|
||||
expect(sources.get('Python Async').text).toContain(`
|
||||
# Click text=HelloNameAnonymous
|
||||
await page.frame(url=\"about:blank\").locator(\"text=HelloNameAnonymous\").click()`);
|
||||
|
||||
expect(sources.get('C#').text).toContain(`
|
||||
// Click text=HelloNameAnonymous
|
||||
await page.FrameByUrl(\"about:blank\").Locator(\"text=HelloNameAnonymous\").ClickAsync();`);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,13 +101,10 @@ test('should save the codegen output to a file if specified', async ({ browserNa
|
|||
});
|
||||
const context = await browser.newContext();
|
||||
|
||||
// Open new page
|
||||
const page = await context.newPage();
|
||||
|
||||
// Go to ${emptyHTML}
|
||||
await page.goto('${emptyHTML}');
|
||||
|
||||
// Close page
|
||||
await page.close();
|
||||
|
||||
// ---------------------
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
`);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -97,13 +97,10 @@ async def run(playwright: Playwright) -> None:
|
|||
browser = await playwright.${browserName}.launch(${launchOptions(channel)})
|
||||
context = await browser.new_context()
|
||||
|
||||
# Open new page
|
||||
page = await context.new_page()
|
||||
|
||||
# Go to ${emptyHTML}
|
||||
await page.goto("${emptyHTML}")
|
||||
|
||||
# Close page
|
||||
await page.close()
|
||||
|
||||
# ---------------------
|
||||
|
|
|
|||
|
|
@ -87,13 +87,10 @@ def run(playwright: Playwright) -> None:
|
|||
browser = playwright.${browserName}.launch(${launchOptions(channel)})
|
||||
context = browser.new_context()
|
||||
|
||||
# Open new page
|
||||
page = context.new_page()
|
||||
|
||||
# Go to ${emptyHTML}
|
||||
page.goto("${emptyHTML}")
|
||||
|
||||
# Close page
|
||||
page.close()
|
||||
|
||||
# ---------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue