mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-24 06:49:04 +03:00
docs(dotnet): type specific addLocatorHandler handler (#29586)
This commit is contained in:
parent
ac0787d0c8
commit
adccd39b01
@ -3344,12 +3344,19 @@ await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync();
|
||||
Locator that triggers the handler.
|
||||
|
||||
### param: Page.addLocatorHandler.handler
|
||||
* langs: js, python, csharp
|
||||
* langs: js, python
|
||||
* since: v1.42
|
||||
- `handler` <[function]>
|
||||
|
||||
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
|
||||
* langs: java
|
||||
* since: v1.42
|
||||
|
@ -709,6 +709,9 @@ function translateType(type, parent, generateNameCallback = t => t.name, optiona
|
||||
if (type.expression === '[null]|[Error]')
|
||||
return 'void';
|
||||
|
||||
if (type.name == 'Promise' && type.templates?.[0].name === 'any')
|
||||
return 'Task';
|
||||
|
||||
if (type.union) {
|
||||
if (type.union[0].name === 'null' && type.union.length === 2)
|
||||
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)
|
||||
throw new Error('Unexpected null as return type.');
|
||||
|
||||
if (!argsList)
|
||||
return `Func<${returnType}>`;
|
||||
return `Func<${argsList}, ${returnType}>`;
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,12 @@ playwright.chromium.launch().then(async browser => {
|
||||
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('World', { delay: 100 }); // Types slower, like a user
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user