Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dotnet/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Regardless of the authentication strategy you choose, you are likely to store au

We recommend to create `playwright/.auth` directory and add it to your `.gitignore`. Your authentication routine will produce authenticated browser state and save it to a file in this `playwright/.auth` directory. Later on, tests will reuse this state and start already authenticated.

:::danger

The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account. We strongly discourage checking them into private or public repositories.
:::

<Tabs
groupId="bash-flavor"
defaultValue="bash"
Expand Down
5 changes: 5 additions & 0 deletions java/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Regardless of the authentication strategy you choose, you are likely to store au

We recommend to create `playwright/.auth` directory and add it to your `.gitignore`. Your authentication routine will produce authenticated browser state and save it to a file in this `playwright/.auth` directory. Later on, tests will reuse this state and start already authenticated.

:::danger

The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account. We strongly discourage checking them into private or public repositories.
:::

<Tabs
groupId="bash-flavor"
defaultValue="bash"
Expand Down
8 changes: 1 addition & 7 deletions nodejs/docs/api/class-testcase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ testCase.titlePath();

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.10</font><x-search>testCase.annotations</x-search>

The list of annotations applicable to the current test. Includes:
* annotations defined on the test or suite via [test()](/api/class-test.mdx#test-call) and [test.describe()](/api/class-test.mdx#test-describe);
* annotations implicitly added by methods [test.skip()](/api/class-test.mdx#test-skip), [test.fixme()](/api/class-test.mdx#test-fixme) and [test.fail()](/api/class-test.mdx#test-fail) prior to test execution.

Annotations are available during test execution through [testInfo.annotations](/api/class-testinfo.mdx#test-info-annotations).

Learn more about [test annotations](../test-annotations.mdx).
[testResult.annotations](/api/class-testresult.mdx#test-result-annotations) of the last test run.

**Usage**

Expand Down
7 changes: 4 additions & 3 deletions nodejs/docs/api/class-testresult.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ A result of a single [TestCase] run.

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.52</font><x-search>testResult.annotations</x-search>

The list of annotations appended during test execution. Includes:
* annotations implicitly added by methods [test.skip()](/api/class-test.mdx#test-skip), [test.fixme()](/api/class-test.mdx#test-fixme) and [test.fail()](/api/class-test.mdx#test-fail) during test execution;
* annotations appended to [testInfo.annotations](/api/class-testinfo.mdx#test-info-annotations).
The list of annotations applicable to the current test. Includes:
* annotations defined on the test or suite via [test()](/api/class-test.mdx#test-call) and [test.describe()](/api/class-test.mdx#test-describe);
* annotations implicitly added by methods [test.skip()](/api/class-test.mdx#test-skip), [test.fixme()](/api/class-test.mdx#test-fixme) and [test.fail()](/api/class-test.mdx#test-fail);
* annotations appended to [testInfo.annotations](/api/class-testinfo.mdx#test-info-annotations) during the test execution.

Annotations are available during test execution through [testInfo.annotations](/api/class-testinfo.mdx#test-info-annotations).

Expand Down
5 changes: 5 additions & 0 deletions nodejs/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Regardless of the authentication strategy you choose, you are likely to store au

We recommend to create `playwright/.auth` directory and add it to your `.gitignore`. Your authentication routine will produce authenticated browser state and save it to a file in this `playwright/.auth` directory. Later on, tests will reuse this state and start already authenticated.

:::danger

The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account. We strongly discourage checking them into private or public repositories.
:::

<Tabs
groupId="bash-flavor"
defaultValue="bash"
Expand Down
84 changes: 6 additions & 78 deletions nodejs/docs/pom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ We will create a `PlaywrightDevPage` helper class to encapsulate common operatio

<Tabs
groupId="js-flavor"
defaultValue="ts"
defaultValue="test"
values={[
{label: 'TypeScript', value: 'ts'},
{label: 'JavaScript', value: 'js'},
{label: 'Test', value: 'test'},
{label: 'Library', value: 'library'}
]
}>
<TabItem value="ts">
<TabItem value="test">

```js title="playwright-dev-page.ts"
import { expect, type Locator, type Page } from '@playwright/test';
Expand Down Expand Up @@ -67,45 +66,6 @@ export class PlaywrightDevPage {
}
```

</TabItem>
<TabItem value="js">

```js title="playwright-dev-page.js"
const { expect } = require('@playwright/test');

exports.PlaywrightDevPage = class PlaywrightDevPage {

/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
this.page = page;
this.getStartedLink = page.locator('a', { hasText: 'Get started' });
this.gettingStartedHeader = page.locator('h1', { hasText: 'Installation' });
this.pomLink = page.locator('li', {
hasText: 'Guides',
}).locator('a', {
hasText: 'Page Object Model',
});
this.tocList = page.locator('article div.markdown ul > li > a');
}

async goto() {
await this.page.goto('https://playwright.dev');
}

async getStarted() {
await this.getStartedLink.first().click();
await expect(this.gettingStartedHeader).toBeVisible();
}

async pageObjectModel() {
await this.getStarted();
await this.pomLink.click();
}
};
```

</TabItem>
<TabItem value="library">

Expand Down Expand Up @@ -145,14 +105,13 @@ Now we can use the `PlaywrightDevPage` class in our tests.

<Tabs
groupId="js-flavor"
defaultValue="ts"
defaultValue="test"
values={[
{label: 'TypeScript', value: 'ts'},
{label: 'JavaScript', value: 'js'},
{label: 'Test', value: 'test'},
{label: 'Library', value: 'library'}
]
}>
<TabItem value="ts">
<TabItem value="test">

```js title="example.spec.ts"
import { test, expect } from '@playwright/test';
Expand Down Expand Up @@ -182,37 +141,6 @@ test('should show Page Object Model article', async ({ page }) => {
});
```

</TabItem>
<TabItem value="js">

```js title="example.spec.js"
const { test, expect } = require('@playwright/test');
const { PlaywrightDevPage } = require('./playwright-dev-page');

test('getting started should contain table of contents', async ({ page }) => {
const playwrightDev = new PlaywrightDevPage(page);
await playwrightDev.goto();
await playwrightDev.getStarted();
await expect(playwrightDev.tocList).toHaveText([
`How to install Playwright`,
`What's Installed`,
`How to run the example test`,
`How to open the HTML test report`,
`Write tests using web first assertions, page fixtures and locators`,
`Run single test, multiple tests, headed mode`,
`Generate tests with Codegen`,
`See a trace of your tests`
]);
});

test('should show Page Object Model article', async ({ page }) => {
const playwrightDev = new PlaywrightDevPage(page);
await playwrightDev.goto();
await playwrightDev.pageObjectModel();
await expect(page.locator('article')).toContainText('Page Object Model is a common pattern');
});
```

</TabItem>
<TabItem value="library">

Expand Down
9 changes: 7 additions & 2 deletions nodejs/docs/test-assertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ In this example we add a custom `toHaveAmount` function. Custom matcher should r

```js title="fixtures.ts"
import { expect as baseExpect } from '@playwright/test';
import type { Page, Locator } from '@playwright/test';
import type { Locator } from '@playwright/test';

export { test } from '@playwright/test';

Expand All @@ -264,13 +264,18 @@ export const expect = baseExpect.extend({
let pass: boolean;
let matcherResult: any;
try {
await baseExpect(locator).toHaveAttribute('data-amount', String(expected), options);
const expectation = this.isNot ? baseExpect(locator).not : baseExpect(locator);
await expectation.toHaveAttribute('data-amount', String(expected), options);
pass = true;
} catch (e: any) {
matcherResult = e.matcherResult;
pass = false;
}

if (this.isNot) {
pass =!pass;
}

const message = pass
? () => this.utils.matcherHint(assertionName, undefined, undefined, { isNot: this.isNot }) +
'\n\n' +
Expand Down
5 changes: 5 additions & 0 deletions python/docs/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Regardless of the authentication strategy you choose, you are likely to store au

We recommend to create `playwright/.auth` directory and add it to your `.gitignore`. Your authentication routine will produce authenticated browser state and save it to a file in this `playwright/.auth` directory. Later on, tests will reuse this state and start already authenticated.

:::danger

The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account. We strongly discourage checking them into private or public repositories.
:::

<Tabs
groupId="bash-flavor"
defaultValue="bash"
Expand Down
Loading