@serenity-js/playwright 3.14.2 → 3.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +10 -9
- package/lib/PlaywrightOptions.d.ts +1 -2
- package/lib/PlaywrightOptions.d.ts.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts +52 -0
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js +52 -0
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js.map +1 -1
- package/package.json +6 -6
- package/src/PlaywrightOptions.ts +1 -2
- package/src/screenplay/abilities/BrowseTheWebWithPlaywright.ts +52 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.15.1](https://github.com/serenity-js/serenity-js/compare/v3.15.0...v3.15.1) (2024-01-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **deps:** update playwright dependencies to v1.41.0 ([bb2dc99](https://github.com/serenity-js/serenity-js/commit/bb2dc99bf8c94536a0863c9c60d5461a9b3dfe19))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.15.0](https://github.com/serenity-js/serenity-js/compare/v3.14.2...v3.15.0) (2024-01-12)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @serenity-js/playwright
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [3.14.2](https://github.com/serenity-js/serenity-js/compare/v3.14.1...v3.14.2) (2023-12-12)
|
|
7
26
|
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ of complex software systems faster, more collaborative and easier to scale.
|
|
|
12
12
|
- [Serenity/JS web testing tutorial](https://serenity-js.org/handbook/web-testing/your-first-web-scenario)
|
|
13
13
|
- [Serenity/JS Handbook](https://serenity-js.org/handbook) and [Getting Started guides](https://serenity-js.org/handbook/getting-started/)
|
|
14
14
|
- [API documentation](https://serenity-js.org/api/core)
|
|
15
|
-
- [Serenity/JS Project Templates on GitHub](https://serenity-js.org/handbook/getting-started
|
|
15
|
+
- [Serenity/JS Project Templates on GitHub](https://serenity-js.org/handbook/getting-started/project-templates/)
|
|
16
16
|
|
|
17
17
|
👋 Join the Serenity/JS Community!
|
|
18
18
|
- Meet other Serenity/JS developers and maintainers on the [Serenity/JS Community chat channel](https://matrix.to/#/#serenity-js:gitter.im),
|
|
@@ -48,11 +48,9 @@ and review the [Serenity/JS Cucumber and Playwright Project Template](https://gi
|
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
import { Ensure, equals } from '@serenity-js/assertions'
|
|
51
|
-
import { actorCalled, Actor,
|
|
52
|
-
import { ConsoleReporter } from '@serenity-js/console-reporter'
|
|
51
|
+
import { actorCalled, Actor, Cast, configure, Duration } from '@serenity-js/core'
|
|
53
52
|
import { BrowseTheWebWithPlaywright, PlaywrightOptions } from '@serenity-js/playwright'
|
|
54
|
-
import {
|
|
55
|
-
import { By, Navigate, PageElement, Photographer, TakePhotosOfFailures, Text } from '@serenity-js/web'
|
|
53
|
+
import { By, Navigate, PageElement, TakePhotosOfFailures, Text } from '@serenity-js/web'
|
|
56
54
|
|
|
57
55
|
import { describe, it, beforeAll, afterAll } from 'mocha'
|
|
58
56
|
import * as playwright from 'playwright'
|
|
@@ -101,10 +99,13 @@ describe('Serenity/JS', () => {
|
|
|
101
99
|
defaultTimeout: Duration.ofMilliseconds(750).inMilliseconds(),
|
|
102
100
|
}),
|
|
103
101
|
crew: [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
[ '@serenity-js/console-reporter', { theme: 'auto' } ],
|
|
103
|
+
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: 'target/site/serenity' } ],
|
|
104
|
+
[ '@serenity-js/web:Photographer', {
|
|
105
|
+
strategy: 'TakePhotosOfFailures',
|
|
106
|
+
// strategy: 'TakePhotosOfInteractions',
|
|
107
|
+
} ],
|
|
108
|
+
[ '@serenity-js/serenity-bdd', { specDirectory: 'spec' } ],
|
|
108
109
|
]
|
|
109
110
|
})
|
|
110
111
|
})
|
|
@@ -3,8 +3,7 @@ import type * as playwright from 'playwright-core';
|
|
|
3
3
|
* Playwright-specific options used to configure the ability to {@apilink BrowseTheWebWithPlaywright}
|
|
4
4
|
*
|
|
5
5
|
* ## Learn more
|
|
6
|
-
*
|
|
7
|
-
* - [Playwright `BrowserContextOptions`](https://github.com/microsoft/playwright/blob/bd5eddd62e2009a5fe3e270d8fc30bf29cef1296/packages/playwright-core/types/types.d.ts#L15956)
|
|
6
|
+
* - [Playwright `Browser.newContext` options](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
8
7
|
*
|
|
9
8
|
* @group Configuration
|
|
10
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightOptions.d.ts","sourceRoot":"","sources":["../src/PlaywrightOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"PlaywrightOptions.d.ts","sourceRoot":"","sources":["../src/PlaywrightOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAkB,SAAQ,UAAU,CAAC,qBAAqB;IAEvE;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;;;;OASG;IACH,0BAA0B,CAAC,EAAE,MAAM,GAAC,kBAAkB,GAAC,aAAa,GAAC,QAAQ,CAAC;IAE9E;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -87,7 +87,59 @@ import type { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
|
87
87
|
* })
|
|
88
88
|
* ```
|
|
89
89
|
*
|
|
90
|
+
* ## Configuring Playwright
|
|
91
|
+
*
|
|
92
|
+
* If you're using Serenity/JS with [Playwright Test](/handbook/test-runners/playwright-test/),
|
|
93
|
+
* Serenity/JS will automatically pick up your configuration from the [`playwright.config.ts`](https://playwright.dev/docs/test-configuration) file.
|
|
94
|
+
*
|
|
95
|
+
* With other [test runners](/handbook/test-runners/), you can configure Playwright by:
|
|
96
|
+
* - providing the browser-level configuration when calling [`BrowserType.launch`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch),
|
|
97
|
+
* - providing the browser context-level {@link PlaywrightOptions} when initialising the ability to `BrowseTheWebWithPlaywright`.
|
|
98
|
+
*
|
|
99
|
+
* The code snippet below demonstrates how to configure the browser and some popular browser context options,
|
|
100
|
+
* such as
|
|
101
|
+
* [`viewport` size](https://playwright.dev/docs/api/class-browser#browser-new-context-option-viewport),
|
|
102
|
+
* [`geolocation`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-geolocation),
|
|
103
|
+
* and [`permissions`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-permissions),
|
|
104
|
+
* but you can use it to configure any other option available in Playwright, like
|
|
105
|
+
* [`userAgent`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-user-agent)
|
|
106
|
+
* or [`storageState`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-storage-state).
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
110
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
111
|
+
* import { Navigate } from '@serenity-js/web'
|
|
112
|
+
* import { Browser, chromium } from 'playwright'
|
|
113
|
+
*
|
|
114
|
+
* // specify browser launch options
|
|
115
|
+
* const browser = await chromium.launch({
|
|
116
|
+
* headless: true
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* await actorCalled('Wendy')
|
|
120
|
+
* .whoCan(BrowseTheWebWithPlaywright.using(browser, {
|
|
121
|
+
* // specify browser context options
|
|
122
|
+
* viewport: { width: 1600, height: 1200 },
|
|
123
|
+
* geolocation: { longitude: 51.50084271042897, latitude: -0.12462540129500639 },
|
|
124
|
+
* permissions: [ 'geolocation' ],
|
|
125
|
+
*
|
|
126
|
+
* defaultNavigationTimeout: 30_000,
|
|
127
|
+
* defaultTimeout: 10_000
|
|
128
|
+
*
|
|
129
|
+
* // ... and so on
|
|
130
|
+
* }))
|
|
131
|
+
* .attemptsTo(
|
|
132
|
+
* Navigate.to(`https://serenity-js.org`),
|
|
133
|
+
* // ...
|
|
134
|
+
* )
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* Note that in addition to all the standard Playwright BrowserContextOptions, you can also provide several others defined in Serenity/JS {@apilink PlaywrightOptions}, such as:
|
|
138
|
+
* - `defaultNavigationTimeout`, which changes the default maximum navigation timeout for the browser context,
|
|
139
|
+
* - `defaultTimeout`, which changes the default maximum time for all Playwright methods accepting the `timeout` option.
|
|
140
|
+
*
|
|
90
141
|
* ## Learn more
|
|
142
|
+
* - [Full list of Playwright `BrowserContextOptions`](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
91
143
|
* - [Playwright website](https://playwright.dev/)
|
|
92
144
|
* - {@apilink BrowseTheWeb}
|
|
93
145
|
* - {@apilink Ability}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowseTheWebWithPlaywright.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithPlaywright.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAMjE
|
|
1
|
+
{"version":3,"file":"BrowseTheWebWithPlaywright.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithPlaywright.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAMjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgJG;AACH,qBAAa,0BAA2B,SAAQ,YAAY,CAAC,UAAU,CAAC,OAAO,CAAE,YAAW,WAAW;IAEnG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,0BAA0B;IAIlG,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,0BAA0B;IAIhG;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC"}
|
|
@@ -112,7 +112,59 @@ const models_1 = require("../models");
|
|
|
112
112
|
* })
|
|
113
113
|
* ```
|
|
114
114
|
*
|
|
115
|
+
* ## Configuring Playwright
|
|
116
|
+
*
|
|
117
|
+
* If you're using Serenity/JS with [Playwright Test](/handbook/test-runners/playwright-test/),
|
|
118
|
+
* Serenity/JS will automatically pick up your configuration from the [`playwright.config.ts`](https://playwright.dev/docs/test-configuration) file.
|
|
119
|
+
*
|
|
120
|
+
* With other [test runners](/handbook/test-runners/), you can configure Playwright by:
|
|
121
|
+
* - providing the browser-level configuration when calling [`BrowserType.launch`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch),
|
|
122
|
+
* - providing the browser context-level {@link PlaywrightOptions} when initialising the ability to `BrowseTheWebWithPlaywright`.
|
|
123
|
+
*
|
|
124
|
+
* The code snippet below demonstrates how to configure the browser and some popular browser context options,
|
|
125
|
+
* such as
|
|
126
|
+
* [`viewport` size](https://playwright.dev/docs/api/class-browser#browser-new-context-option-viewport),
|
|
127
|
+
* [`geolocation`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-geolocation),
|
|
128
|
+
* and [`permissions`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-permissions),
|
|
129
|
+
* but you can use it to configure any other option available in Playwright, like
|
|
130
|
+
* [`userAgent`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-user-agent)
|
|
131
|
+
* or [`storageState`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-storage-state).
|
|
132
|
+
*
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
135
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
136
|
+
* import { Navigate } from '@serenity-js/web'
|
|
137
|
+
* import { Browser, chromium } from 'playwright'
|
|
138
|
+
*
|
|
139
|
+
* // specify browser launch options
|
|
140
|
+
* const browser = await chromium.launch({
|
|
141
|
+
* headless: true
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* await actorCalled('Wendy')
|
|
145
|
+
* .whoCan(BrowseTheWebWithPlaywright.using(browser, {
|
|
146
|
+
* // specify browser context options
|
|
147
|
+
* viewport: { width: 1600, height: 1200 },
|
|
148
|
+
* geolocation: { longitude: 51.50084271042897, latitude: -0.12462540129500639 },
|
|
149
|
+
* permissions: [ 'geolocation' ],
|
|
150
|
+
*
|
|
151
|
+
* defaultNavigationTimeout: 30_000,
|
|
152
|
+
* defaultTimeout: 10_000
|
|
153
|
+
*
|
|
154
|
+
* // ... and so on
|
|
155
|
+
* }))
|
|
156
|
+
* .attemptsTo(
|
|
157
|
+
* Navigate.to(`https://serenity-js.org`),
|
|
158
|
+
* // ...
|
|
159
|
+
* )
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* Note that in addition to all the standard Playwright BrowserContextOptions, you can also provide several others defined in Serenity/JS {@apilink PlaywrightOptions}, such as:
|
|
163
|
+
* - `defaultNavigationTimeout`, which changes the default maximum navigation timeout for the browser context,
|
|
164
|
+
* - `defaultTimeout`, which changes the default maximum time for all Playwright methods accepting the `timeout` option.
|
|
165
|
+
*
|
|
115
166
|
* ## Learn more
|
|
167
|
+
* - [Full list of Playwright `BrowserContextOptions`](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
116
168
|
* - [Playwright website](https://playwright.dev/)
|
|
117
169
|
* - {@apilink BrowseTheWeb}
|
|
118
170
|
* - {@apilink Ability}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowseTheWebWithPlaywright.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithPlaywright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAgD;AAChD,4DAA8C;AAG9C,sCAGmB;AAEnB
|
|
1
|
+
{"version":3,"file":"BrowseTheWebWithPlaywright.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithPlaywright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAgD;AAChD,4DAA8C;AAG9C,sCAGmB;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgJG;AACH,MAAa,0BAA2B,SAAQ,kBAAgC;IAE5E,MAAM,CAAC,KAAK,CAAC,OAA2B,EAAE,OAA2B;QACjE,OAAO,IAAI,0BAA0B,CAAC,IAAI,6CAAoC,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5H,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAqB,EAAE,OAA2B;QAC/D,OAAO,IAAI,0BAA0B,CAAC,IAAI,0CAAiC,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IACtH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC;CACJ;AApBD,gEAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/playwright",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.1",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern library for Playwright",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"node": "^16.13 || ^18.12 || ^20"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@serenity-js/core": "3.
|
|
48
|
-
"@serenity-js/web": "3.
|
|
49
|
-
"playwright-core": "1.
|
|
47
|
+
"@serenity-js/core": "3.15.1",
|
|
48
|
+
"@serenity-js/web": "3.15.1",
|
|
49
|
+
"playwright-core": "1.41.0",
|
|
50
50
|
"tiny-types": "1.21.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@integration/testing-tools": "3.0.0",
|
|
54
54
|
"@types/chai": "4.3.11",
|
|
55
55
|
"@types/mocha": "10.0.6",
|
|
56
|
-
"c8": "
|
|
56
|
+
"c8": "9.1.0",
|
|
57
57
|
"mocha": "10.2.0",
|
|
58
58
|
"mocha-multi": "1.1.7",
|
|
59
59
|
"ts-node": "10.9.2",
|
|
60
60
|
"typescript": "5.1.6"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4df79de3820acd9fb18d76843feb0468c55c8e7f"
|
|
63
63
|
}
|
package/src/PlaywrightOptions.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type * as playwright from 'playwright-core';
|
|
|
4
4
|
* Playwright-specific options used to configure the ability to {@apilink BrowseTheWebWithPlaywright}
|
|
5
5
|
*
|
|
6
6
|
* ## Learn more
|
|
7
|
-
*
|
|
8
|
-
* - [Playwright `BrowserContextOptions`](https://github.com/microsoft/playwright/blob/bd5eddd62e2009a5fe3e270d8fc30bf29cef1296/packages/playwright-core/types/types.d.ts#L15956)
|
|
7
|
+
* - [Playwright `Browser.newContext` options](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
9
8
|
*
|
|
10
9
|
* @group Configuration
|
|
11
10
|
*/
|
|
@@ -93,7 +93,59 @@ import {
|
|
|
93
93
|
* })
|
|
94
94
|
* ```
|
|
95
95
|
*
|
|
96
|
+
* ## Configuring Playwright
|
|
97
|
+
*
|
|
98
|
+
* If you're using Serenity/JS with [Playwright Test](/handbook/test-runners/playwright-test/),
|
|
99
|
+
* Serenity/JS will automatically pick up your configuration from the [`playwright.config.ts`](https://playwright.dev/docs/test-configuration) file.
|
|
100
|
+
*
|
|
101
|
+
* With other [test runners](/handbook/test-runners/), you can configure Playwright by:
|
|
102
|
+
* - providing the browser-level configuration when calling [`BrowserType.launch`](https://playwright.dev/docs/api/class-browsertype#browser-type-launch),
|
|
103
|
+
* - providing the browser context-level {@link PlaywrightOptions} when initialising the ability to `BrowseTheWebWithPlaywright`.
|
|
104
|
+
*
|
|
105
|
+
* The code snippet below demonstrates how to configure the browser and some popular browser context options,
|
|
106
|
+
* such as
|
|
107
|
+
* [`viewport` size](https://playwright.dev/docs/api/class-browser#browser-new-context-option-viewport),
|
|
108
|
+
* [`geolocation`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-geolocation),
|
|
109
|
+
* and [`permissions`](https://playwright.dev/docs/api/class-browser#browser-new-page-option-permissions),
|
|
110
|
+
* but you can use it to configure any other option available in Playwright, like
|
|
111
|
+
* [`userAgent`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-user-agent)
|
|
112
|
+
* or [`storageState`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-storage-state).
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
116
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
117
|
+
* import { Navigate } from '@serenity-js/web'
|
|
118
|
+
* import { Browser, chromium } from 'playwright'
|
|
119
|
+
*
|
|
120
|
+
* // specify browser launch options
|
|
121
|
+
* const browser = await chromium.launch({
|
|
122
|
+
* headless: true
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* await actorCalled('Wendy')
|
|
126
|
+
* .whoCan(BrowseTheWebWithPlaywright.using(browser, {
|
|
127
|
+
* // specify browser context options
|
|
128
|
+
* viewport: { width: 1600, height: 1200 },
|
|
129
|
+
* geolocation: { longitude: 51.50084271042897, latitude: -0.12462540129500639 },
|
|
130
|
+
* permissions: [ 'geolocation' ],
|
|
131
|
+
*
|
|
132
|
+
* defaultNavigationTimeout: 30_000,
|
|
133
|
+
* defaultTimeout: 10_000
|
|
134
|
+
*
|
|
135
|
+
* // ... and so on
|
|
136
|
+
* }))
|
|
137
|
+
* .attemptsTo(
|
|
138
|
+
* Navigate.to(`https://serenity-js.org`),
|
|
139
|
+
* // ...
|
|
140
|
+
* )
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* Note that in addition to all the standard Playwright BrowserContextOptions, you can also provide several others defined in Serenity/JS {@apilink PlaywrightOptions}, such as:
|
|
144
|
+
* - `defaultNavigationTimeout`, which changes the default maximum navigation timeout for the browser context,
|
|
145
|
+
* - `defaultTimeout`, which changes the default maximum time for all Playwright methods accepting the `timeout` option.
|
|
146
|
+
*
|
|
96
147
|
* ## Learn more
|
|
148
|
+
* - [Full list of Playwright `BrowserContextOptions`](https://playwright.dev/docs/api/class-browser#browser-new-context)
|
|
97
149
|
* - [Playwright website](https://playwright.dev/)
|
|
98
150
|
* - {@apilink BrowseTheWeb}
|
|
99
151
|
* - {@apilink Ability}
|