docs(dotnet): type specific addLocatorHandler handler (#29586)

This commit is contained in:
Max Schmitt 2024-02-22 23:53:09 +01:00 committed by GitHub
parent ac0787d0c8
commit adccd39b01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View File

@ -3344,12 +3344,19 @@ await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync();
Locator that triggers the handler. Locator that triggers the handler.
### param: Page.addLocatorHandler.handler ### param: Page.addLocatorHandler.handler
* langs: js, python, csharp * langs: js, python
* since: v1.42 * since: v1.42
- `handler` <[function]> - `handler` <[function]>
Function that should be run once [`param: locator`] appears. This function should get rid of the element that blocks actions like click. Function that should be run once [`param: locator`] appears. This function should get rid of the element that blocks actions like click.
### param: Page.addLocatorHandler.handler
* langs: csharp
* since: v1.42
- `handler` <[function](): [Promise<any>]>
Function that should be run once [`param: locator`] appears. This function should get rid of the element that blocks actions like click.
### param: Page.addLocatorHandler.handler ### param: Page.addLocatorHandler.handler
* langs: java * langs: java
* since: v1.42 * since: v1.42

View File

@ -709,6 +709,9 @@ function translateType(type, parent, generateNameCallback = t => t.name, optiona
if (type.expression === '[null]|[Error]') if (type.expression === '[null]|[Error]')
return 'void'; return 'void';
if (type.name == 'Promise' && type.templates?.[0].name === 'any')
return 'Task';
if (type.union) { if (type.union) {
if (type.union[0].name === 'null' && type.union.length === 2) if (type.union[0].name === 'null' && type.union.length === 2)
return translateType(type.union[1], parent, generateNameCallback, true, isReturnType); return translateType(type.union[1], parent, generateNameCallback, true, isReturnType);
@ -799,6 +802,8 @@ function translateType(type, parent, generateNameCallback = t => t.name, optiona
if (returnType === null) if (returnType === null)
throw new Error('Unexpected null as return type.'); throw new Error('Unexpected null as return type.');
if (!argsList)
return `Func<${returnType}>`;
return `Func<${argsList}, ${returnType}>`; return `Func<${argsList}, ${returnType}>`;
} }
} }

View File

@ -154,6 +154,12 @@ playwright.chromium.launch().then(async browser => {
return 'something random for no reason'; return 'something random for no reason';
}); });
await page.addLocatorHandler(page.locator(''), () => {});
await page.addLocatorHandler(page.locator(''), () => 42);
await page.addLocatorHandler(page.locator(''), async () => { });
await page.addLocatorHandler(page.locator(''), async () => 42);
await page.addLocatorHandler(page.locator(''), () => Promise.resolve(42));
await page.keyboard.type('Hello'); // Types instantly await page.keyboard.type('Hello'); // Types instantly
await page.keyboard.type('World', { delay: 100 }); // Types slower, like a user await page.keyboard.type('World', { delay: 100 }); // Types slower, like a user