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 · all subjects

api testing/authentication

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.

storageState() saves authentication state

Call storageState() on an APIRequestContext to retrieve the storage state (cookies and local storage). Can be passed to path option to save to a file. Storage state is interchangeable between BrowserContext and APIRequestContext.

Example: Store authentication state from API and reuse in browser

```js const requestContext = await request.newContext({ httpCredentials: { username: 'user', password: 'passwd' } }); await requestContext.get(`https://api.example.com/login`); // Save storage state into the file. await requestContext.storageState({ path: 'state.json' }); // Create a new context with the saved storage state. const context = await browser.newContext({ storageState: 'state.json' }); ``` This shows how to authenticate via API and save the state to reuse in browser contexts.

Example: API request with HTTP credentials

```js const requestContext = await request.newContext({ httpCredentials: { username: 'user', password: 'passwd' } }); ``` Use httpCredentials option when creating an APIRequestContext to provide basic authentication credentials.

HTTP Authentication configuration in playwright.config.ts

Configure HTTP Authentication globally in playwright.config.ts using the httpCredentials option in the use section: { use: { httpCredentials: { username: 'bill', password: 'pa55w0rd' } } }

Give your agent this brain