mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: fix the docs validator (#86)
This commit is contained in:
parent
66d3dd8626
commit
991f4a9072
28
docs/api.md
28
docs/api.md
@ -160,7 +160,7 @@
|
||||
- [class: Keyboard](#class-keyboard)
|
||||
* [keyboard.down(key[, options])](#keyboarddownkey-options)
|
||||
* [keyboard.press(key[, options])](#keyboardpresskey-options)
|
||||
* [keyboard.sendCharacter(char)](#keyboardsendcharacterchar)
|
||||
* [keyboard.sendCharacters(text)](#keyboardsendcharacterstext)
|
||||
* [keyboard.type(text[, options])](#keyboardtypetext-options)
|
||||
* [keyboard.up(key)](#keyboardupkey)
|
||||
- [class: Mouse](#class-mouse)
|
||||
@ -1240,7 +1240,7 @@ List of all available devices is available in the source code: [DeviceDescriptor
|
||||
#### page.emulateMedia(options)
|
||||
- `options` <[Object]>
|
||||
- `type` <?[string]> Optional. Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null` disables CSS media emulation.
|
||||
- `colorScheme` <?[string]> Optional. Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`.
|
||||
- `colorScheme` <"dark"|"light"|"no-preference"> Optional. Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`.
|
||||
- returns: <[Promise]>
|
||||
|
||||
```js
|
||||
@ -2127,7 +2127,7 @@ function findFocusedNode(node) {
|
||||
|
||||
Keyboard provides an api for managing a virtual keyboard. The high level api is [`keyboard.type`](#keyboardtypetext-options), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
|
||||
|
||||
For finer control, you can use [`keyboard.down`](#keyboarddownkey-options), [`keyboard.up`](#keyboardupkey), and [`keyboard.sendCharacter`](#keyboardsendcharacterchar) to manually fire events as if they were generated from a real keyboard.
|
||||
For finer control, you can use [`keyboard.down`](#keyboarddownkey-options), [`keyboard.up`](#keyboardupkey), and [`keyboard.sendCharacters`](#keyboardsendcharacterstext) to manually fire events as if they were generated from a real keyboard.
|
||||
|
||||
An example of holding down `Shift` in order to select and delete some text:
|
||||
```js
|
||||
@ -2181,17 +2181,17 @@ If `key` is a single character and no modifier keys besides `Shift` are being he
|
||||
|
||||
Shortcut for [`keyboard.down`](#keyboarddownkey-options) and [`keyboard.up`](#keyboardupkey).
|
||||
|
||||
#### keyboard.sendCharacter(char)
|
||||
- `char` <[string]> Character to send into the page.
|
||||
#### keyboard.sendCharacters(text)
|
||||
- `text` <[string]> Characters to send into the page.
|
||||
- returns: <[Promise]>
|
||||
|
||||
Dispatches a `keypress` and `input` event. This does not send a `keydown` or `keyup` event.
|
||||
|
||||
```js
|
||||
page.keyboard.sendCharacter('嗨');
|
||||
page.keyboard.sendCharacters('嗨');
|
||||
```
|
||||
|
||||
> **NOTE** Modifier keys DO NOT effect `keyboard.sendCharacter`. Holding down `Shift` will not type the text in upper case.
|
||||
> **NOTE** Modifier keys DO NOT effect `keyboard.sendCharacters`. Holding down `Shift` will not type the text in upper case.
|
||||
|
||||
#### keyboard.type(text[, options])
|
||||
- `text` <[string]> A text to type into a focused element.
|
||||
@ -2240,6 +2240,10 @@ await page.mouse.up();
|
||||
- `button` <"left"|"right"|"middle"> Defaults to `left`.
|
||||
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
|
||||
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
|
||||
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
|
||||
- `relativePoint` <[Object]> Optional relative point
|
||||
- `x` <[number]> x coordinate
|
||||
- `y` <[number]> y coordinate
|
||||
- returns: <[Promise]>
|
||||
|
||||
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
|
||||
@ -2250,6 +2254,10 @@ Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownopt
|
||||
- `options` <[Object]>
|
||||
- `button` <"left"|"right"|"middle"> Defaults to `left`.
|
||||
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
|
||||
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
|
||||
- `relativePoint` <[Object]> Optional relative point
|
||||
- `x` <[number]> x coordinate
|
||||
- `y` <[number]> y coordinate
|
||||
- returns: <[Promise]>
|
||||
|
||||
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
|
||||
@ -2277,6 +2285,10 @@ Dispatches a `mousemove` event.
|
||||
- `options` <[Object]>
|
||||
- `button` <"left"|"right"|"middle"> Defaults to `left`.
|
||||
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
|
||||
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
|
||||
- `relativePoint` <[Object]> Optional relative point
|
||||
- `x` <[number]> x coordinate
|
||||
- `y` <[number]> y coordinate
|
||||
- returns: <[Promise]>
|
||||
|
||||
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
|
||||
@ -3134,10 +3146,12 @@ page.on('request', request => {
|
||||
```
|
||||
|
||||
#### interception.disable()
|
||||
- returns: <[Promise]>
|
||||
|
||||
Disables network request interception.
|
||||
|
||||
#### interception.enable()
|
||||
- returns: <[Promise]>
|
||||
|
||||
Once request interception is enabled, every request will stall unless it's continued, responded or aborted.
|
||||
An example of a naïve request interceptor that aborts all image requests:
|
||||
|
||||
@ -326,7 +326,7 @@ export class ElementHandle extends JSHandle {
|
||||
if (error)
|
||||
throw new Error(error);
|
||||
await this.focus();
|
||||
await this._page.keyboard.sendCharacter(value);
|
||||
await this._page.keyboard.sendCharacters(value);
|
||||
}
|
||||
|
||||
async uploadFile(...filePaths: string[]) {
|
||||
|
||||
@ -378,7 +378,7 @@ export class ElementHandle extends JSHandle {
|
||||
if (error)
|
||||
throw new Error(error);
|
||||
await this.focus();
|
||||
await this._frame._page.keyboard.sendCharacter(value);
|
||||
await this._frame._page.keyboard.sendCharacters(value);
|
||||
}
|
||||
|
||||
async _clickablePoint(): Promise<{ x: number; y: number; }> {
|
||||
|
||||
@ -123,7 +123,7 @@ export class Keyboard {
|
||||
await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.key, description.location);
|
||||
}
|
||||
|
||||
async sendCharacter(text: string) {
|
||||
async sendCharacters(text: string) {
|
||||
await this._raw.sendText(text);
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ export class Keyboard {
|
||||
} else {
|
||||
if (delay)
|
||||
await new Promise(f => setTimeout(f, delay));
|
||||
await this.sendCharacter(char);
|
||||
await this.sendCharacters(char);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/types.ts
12
src/types.ts
@ -5,12 +5,12 @@ type Boxed<Args extends any[], Handle> = { [Index in keyof Args]: Args[Index] |
|
||||
type PageFunction<Args extends any[], R = any> = string | ((...args: Args) => R | Promise<R>);
|
||||
type PageFunctionOn<On, Args extends any[], R = any> = string | ((on: On, ...args: Args) => R | Promise<R>);
|
||||
|
||||
export type Evaluate<Handle> = <Args extends any[], R>(fn: PageFunction<Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateHandle<Handle> = <Args extends any[]>(fn: PageFunction<Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
|
||||
export type $Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type $$Eval<Handle> = <Args extends any[], R>(selector: string, fn: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateOn<Handle> = <Args extends any[], R>(fn: PageFunctionOn<any, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateHandleOn<Handle> = <Args extends any[]>(fn: PageFunctionOn<any, Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
|
||||
export type Evaluate<Handle> = <Args extends any[], R>(pageFunction: PageFunction<Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateHandle<Handle> = <Args extends any[]>(pageFunction: PageFunction<Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
|
||||
export type $Eval<Handle> = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type $$Eval<Handle> = <Args extends any[], R>(selector: string, pageFunction: PageFunctionOn<Element[], Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateOn<Handle> = <Args extends any[], R>(pageFunction: PageFunctionOn<any, Args, R>, ...args: Boxed<Args, Handle>) => Promise<R>;
|
||||
export type EvaluateHandleOn<Handle> = <Args extends any[]>(pageFunction: PageFunctionOn<any, Args>, ...args: Boxed<Args, Handle>) => Promise<Handle>;
|
||||
|
||||
export interface EvaluationContext<Handle> {
|
||||
evaluate: Evaluate<Handle>;
|
||||
|
||||
@ -256,7 +256,7 @@ export class ElementHandle extends JSHandle {
|
||||
if (error)
|
||||
throw new Error(error);
|
||||
await this.focus();
|
||||
await this._page.keyboard.sendCharacter(value);
|
||||
await this._page.keyboard.sendCharacters(value);
|
||||
}
|
||||
|
||||
async focus() {
|
||||
|
||||
@ -76,10 +76,10 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {
|
||||
it('should send a character with sendCharacter', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
await page.focus('textarea');
|
||||
await page.keyboard.sendCharacter('嗨');
|
||||
await page.keyboard.sendCharacters('嗨');
|
||||
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨');
|
||||
await page.evaluate(() => window.addEventListener('keydown', e => e.preventDefault(), true));
|
||||
await page.keyboard.sendCharacter('a');
|
||||
await page.keyboard.sendCharacters('a');
|
||||
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('嗨a');
|
||||
});
|
||||
it.skip(FFOX)('should report shiftKey', async({page, server}) => {
|
||||
|
||||
@ -116,7 +116,7 @@ function checkSources(sources) {
|
||||
const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
||||
const name = symbol.getName();
|
||||
if (symbol.valueDeclaration.dotDotDotToken) {
|
||||
const innerType = serializeType(type.typeArguments[0], circular);
|
||||
const innerType = serializeType(type.typeArguments ? type.typeArguments[0] : type, circular);
|
||||
innerType.name = '...' + innerType.name;
|
||||
return Documentation.Member.createProperty('...' + name, innerType);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user