new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

apirequestcontext

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

APIRequestContext class introduction

APIRequestContext is an API used for Web API testing. It can trigger API endpoints, configure micro-services, prepare environment or service for e2e tests. It is available via BrowserContext.request or Page.request (which return the same instance), or can be created standalone via APIRequest.newContext(). Introduced in v1.16.

APIRequestContext cookie management with browser context

When APIRequestContext is returned by BrowserContext.request or Page.request, it uses the same cookie jar as its BrowserContext. Outgoing API requests automatically include the context's cookies in the Cookie header without manual intervention. Set-Cookie headers in API responses are written back to the BrowserContext, so subsequent page navigations and API calls pick them up. Logging in via the API logs in the browser, and vice versa.

APIRequestContext isolated instance without shared cookies

To create an APIRequestContext that does not share cookies with the browser, create an isolated context via APIRequest.newContext(). Such APIRequestContext object will have its own isolated cookie storage.

APIRequestContext usage example with GitHub API

Complete example showing how to use APIRequestContext to create and delete a GitHub repository. Python async version: imports playwright modules, creates browser and context with base_url, gets api_request_context from context.request, makes POST request to create repo with Authorization header, asserts response.ok and checks response.json()['name'], makes DELETE request to delete repo, asserts response.ok and checks response.body(). Python sync version follows same pattern without async/await.

Give your agent this brain