YouTip LogoYouTip

Network Input Api

Playwright Network and Input API |

This appendix lists APIs related to network requests, keyboard, mouse, and touch.


Request Class

Method Description
request.url() Request URL
request.method() Request method (GET/POST, etc.)
request.headers() Request headers
request.postData() Body data of POST request
request.postDataJSON() JSON body of POST request
request.postDataBuffer() Buffer body of POST request
request.isNavigationRequest() Whether the request is a navigation request
request.frame() Frame that initiated the request
request.redirectedFrom() Source Request of the redirect
request.redirectedTo() Target Request of the redirect
request.failure() Request failure information (returns null if no failure)
request.timing() Request timing information

Response Class

Method Description
response.url() Response URL
response.status() HTTP status code
response.statusText() Status text
response.headers() Response headers
response.body() Response body (Buffer)
response.text() Response body (text)
response.json() Response body (JSON)
response.ok() Whether status code is in range 200–299
response.request() Corresponding Request object
response.frame() Frame that initiated the request

Route Class

Method Description
route.abort(errorCode?) Abort the request
route.continue(options?) Continue the request with modifications
route.fulfill(options?) Return a custom response
route.fetch(options?) Actually send the request and get the response
route.request() Get the corresponding Request

WebSocket Class

Method/Event Description
webSocket.url() WebSocket URL
webSocket.isClosed() Whether the WebSocket is closed
webSocket.on('framereceived', handler) Frame received event
webSocket.on('framesent', handler) Frame sent event
webSocket.on('close', handler) Close event

APIRequestContext Class

Method Description
request.get(url, options?) Send a GET request
request.post(url, options?) Send a POST request
request.put(url, options?) Send a PUT request
request.patch(url, options?) Send a PATCH request
request.delete(url, options?) Send a DELETE request
request.head(url, options?) Send a HEAD request
request.fetch(urlOrRequest, options?) Send a request (generic)
request.storageState(options?) Get storage state
request.dispose() Release resources

APIResponse Class

Method Description
response.status() HTTP status code
response.statusText() Status text
response.headers() Response headers
response.body() Body (Buffer)
response.text() Body (text)
response.json() Body (JSON)
response.ok() Whether status code is in range 200–299
response.url() Final URL of the response
response.dispose() Release resources

Keyboard Class

Method Description
keyboard.press(key) Press and release a key
keyboard.down(key) Press a key without releasing
keyboard.up(key) Release a key
keyboard.type(text, options?) Type text character by character
keyboard.insertText(text) Insert text directly

Mouse Class

Method Description
mouse.click(x, y, options?) Click at coordinates
mouse.dblclick(x, y, options?) Double-click at coordinates
mouse.move(x, y, options?) Move mouse to coordinates
mouse.down(options?) Press mouse button
mouse.up(options?) Release mouse button
mouse.wheel(deltaX, deltaY) Scroll the wheel

Touchscreen Class

Method Description
touchscreen.tap(x, y) Touch tap
← Playwright Other ApiPlaywright Page Api β†’