@serenity-js/playwright 3.4.2 → 3.6.0
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 +28 -0
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts +61 -13
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js +60 -18
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSession.d.ts +14 -9
- package/lib/screenplay/models/PlaywrightBrowsingSession.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSession.js +11 -20
- package/lib/screenplay/models/PlaywrightBrowsingSession.js.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts +12 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js +27 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts +11 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.js +26 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.js.map +1 -0
- package/lib/screenplay/models/PlaywrightCookie.d.ts +2 -1
- package/lib/screenplay/models/PlaywrightCookie.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightCookie.js.map +1 -1
- package/lib/screenplay/models/PlaywrightModalDialogHandler.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightModalDialogHandler.js.map +1 -1
- package/lib/screenplay/models/PlaywrightPage.d.ts +7 -5
- package/lib/screenplay/models/PlaywrightPage.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightPage.js +3 -0
- package/lib/screenplay/models/PlaywrightPage.js.map +1 -1
- package/lib/screenplay/models/PlaywrightPageElement.d.ts +2 -1
- package/lib/screenplay/models/PlaywrightPageElement.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightPageElement.js.map +1 -1
- package/lib/screenplay/models/index.d.ts +2 -0
- package/lib/screenplay/models/index.d.ts.map +1 -1
- package/lib/screenplay/models/index.js +2 -0
- package/lib/screenplay/models/index.js.map +1 -1
- package/lib/screenplay/models/locators/PlaywrightLocator.d.ts +12 -2
- package/lib/screenplay/models/locators/PlaywrightLocator.d.ts.map +1 -1
- package/lib/screenplay/models/locators/PlaywrightLocator.js +5 -4
- package/lib/screenplay/models/locators/PlaywrightLocator.js.map +1 -1
- package/package.json +6 -6
- package/src/screenplay/abilities/BrowseTheWebWithPlaywright.ts +67 -22
- package/src/screenplay/models/PlaywrightBrowsingSession.ts +29 -30
- package/src/screenplay/models/PlaywrightBrowsingSessionWithBrowser.ts +33 -0
- package/src/screenplay/models/PlaywrightBrowsingSessionWithPage.ts +31 -0
- package/src/screenplay/models/PlaywrightCookie.ts +2 -1
- package/src/screenplay/models/PlaywrightModalDialogHandler.ts +2 -1
- package/src/screenplay/models/PlaywrightPage.ts +17 -6
- package/src/screenplay/models/PlaywrightPageElement.ts +3 -2
- package/src/screenplay/models/index.ts +2 -0
- package/src/screenplay/models/locators/PlaywrightLocator.ts +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightPageElement.js","sourceRoot":"","sources":["../../../src/screenplay/models/PlaywrightPageElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA+C;
|
|
1
|
+
{"version":3,"file":"PlaywrightPageElement.js","sourceRoot":"","sources":["../../../src/screenplay/models/PlaywrightPageElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA+C;AAE/C,0CAA6D;AAC7D,sEAAwD;AAExD,2CAA+C;A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CAAC;IAED,KAAK,CAAC,SAAS;QACX,IAAI;YACA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAE3C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC;YAC5C,IAAI,CAAE,SAAS,EAAE;gBACb,OAAO,KAAK,CAAC;aAChB;YAED,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACpD;QAAC,MAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CACJ;AAnMD,sDAmMC;AAED;;GAEG;AACH,MAAM,gCAAgC;IAClC,YAA6B,IAAyB;QAAzB,SAAI,GAAJ,IAAI,CAAqB;QAClD,IAAA,mBAAM,EAAC,aAAa,EAAE,IAAI,EAAE,IAAA,sBAAS,GAAE,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,UAAU;QACZ,qBAAqB;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACpB,CAAC,OAAoB,EAAE,EAAE;YACrB,OAAO,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC,EACD,IAAI,CAAC,IAAI,CACZ,CAAC;QACF,oBAAoB;IACxB,CAAC;CACJ"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './locators';
|
|
2
2
|
export * from './PlaywrightBrowsingSession';
|
|
3
|
+
export * from './PlaywrightBrowsingSessionWithBrowser';
|
|
4
|
+
export * from './PlaywrightBrowsingSessionWithPage';
|
|
3
5
|
export * from './PlaywrightCookie';
|
|
4
6
|
export * from './PlaywrightPage';
|
|
5
7
|
export * from './PlaywrightPageElement';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
|
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./locators"), exports);
|
|
18
18
|
__exportStar(require("./PlaywrightBrowsingSession"), exports);
|
|
19
|
+
__exportStar(require("./PlaywrightBrowsingSessionWithBrowser"), exports);
|
|
20
|
+
__exportStar(require("./PlaywrightBrowsingSessionWithPage"), exports);
|
|
19
21
|
__exportStar(require("./PlaywrightCookie"), exports);
|
|
20
22
|
__exportStar(require("./PlaywrightPage"), exports);
|
|
21
23
|
__exportStar(require("./PlaywrightPageElement"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8DAA4C;AAC5C,qDAAmC;AACnC,mDAAiC;AACjC,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8DAA4C;AAC5C,yEAAuD;AACvD,sEAAoD;AACpD,qDAAmC;AACnC,mDAAiC;AACjC,0DAAwC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PageElement, RootLocator, Selector } from '@serenity-js/web';
|
|
2
|
+
import { Locator } from '@serenity-js/web';
|
|
2
3
|
import type * as playwright from 'playwright-core';
|
|
3
|
-
import { PlaywrightRootLocator } from './PlaywrightRootLocator';
|
|
4
|
+
import type { PlaywrightRootLocator } from './PlaywrightRootLocator';
|
|
4
5
|
/**
|
|
5
6
|
* Playwright-specific implementation of {@apilink Locator}.
|
|
6
7
|
*
|
|
@@ -17,4 +18,13 @@ export declare class PlaywrightLocator extends Locator<playwright.Locator, strin
|
|
|
17
18
|
element(): PageElement<playwright.Locator>;
|
|
18
19
|
allElements(): Promise<Array<PageElement<playwright.Locator>>>;
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class PlaywrightExistingElementLocator extends PlaywrightLocator {
|
|
25
|
+
private readonly existingNativeElement;
|
|
26
|
+
constructor(parent: RootLocator<playwright.Locator>, selector: Selector, existingNativeElement: playwright.Locator);
|
|
27
|
+
nativeElement(): Promise<playwright.Locator>;
|
|
28
|
+
allNativeElements(): Promise<Array<playwright.Locator>>;
|
|
29
|
+
}
|
|
20
30
|
//# sourceMappingURL=PlaywrightLocator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightLocator.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/models/locators/PlaywrightLocator.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"PlaywrightLocator.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/models/locators/PlaywrightLocator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAmE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAInD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGlE,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EACvC,QAAQ,EAAE,QAAQ;IAMtB,SAAS,CAAC,cAAc,IAAI,MAAM;IA4B5B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAsB7B,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;IAM5C,iBAAiB,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAU7D,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;IAItE,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;IAIrE,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC;IAIpC,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;CAavE;AAED;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,iBAAiB;IAI/D,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAFtC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EACvC,QAAQ,EAAE,QAAQ,EACD,qBAAqB,EAAE,UAAU,CAAC,OAAO;IAKxD,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;IAI5C,iBAAiB,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;CAGhE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlaywrightLocator = void 0;
|
|
3
|
+
exports.PlaywrightExistingElementLocator = exports.PlaywrightLocator = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
5
|
const web_1 = require("@serenity-js/web");
|
|
6
6
|
const promised_1 = require("../../promised");
|
|
@@ -75,14 +75,14 @@ class PlaywrightLocator extends web_1.Locator {
|
|
|
75
75
|
}
|
|
76
76
|
async allElements() {
|
|
77
77
|
const elements = await this.allNativeElements();
|
|
78
|
-
return elements.map(childElement => new PlaywrightPageElement_1.PlaywrightPageElement(new
|
|
78
|
+
return elements.map(childElement => new PlaywrightPageElement_1.PlaywrightPageElement(new PlaywrightExistingElementLocator(this.parent, this.selector, childElement)));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
exports.PlaywrightLocator = PlaywrightLocator;
|
|
82
82
|
/**
|
|
83
|
-
* @
|
|
83
|
+
* @internal
|
|
84
84
|
*/
|
|
85
|
-
class
|
|
85
|
+
class PlaywrightExistingElementLocator extends PlaywrightLocator {
|
|
86
86
|
constructor(parent, selector, existingNativeElement) {
|
|
87
87
|
super(parent, selector);
|
|
88
88
|
this.existingNativeElement = existingNativeElement;
|
|
@@ -94,4 +94,5 @@ class ExistingElementLocator extends PlaywrightLocator {
|
|
|
94
94
|
return [this.existingNativeElement];
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
exports.PlaywrightExistingElementLocator = PlaywrightExistingElementLocator;
|
|
97
98
|
//# sourceMappingURL=PlaywrightLocator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaywrightLocator.js","sourceRoot":"","sources":["../../../../src/screenplay/models/locators/PlaywrightLocator.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;
|
|
1
|
+
{"version":3,"file":"PlaywrightLocator.js","sourceRoot":"","sources":["../../../../src/screenplay/models/locators/PlaywrightLocator.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAElD,0CAA4G;AAG5G,6CAA0C;AAC1C,oEAAiE;AAGjE;;;;GAIG;AACH,MAAa,iBAAkB,SAAQ,aAAmC;IAEtE,YACI,MAAuC,EACvC,Q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CAAC,EAAE,CAC/B,IAAI,6CAAqB,CACrB,IAAI,gCAAgC,CAChC,IAAI,CAAC,MAA+B,EACpC,IAAI,CAAC,QAAQ,EACb,YAAY,CACf,CACJ,CACJ,CAAC;IACN,CAAC;CACJ;AArGD,8CAqGC;AAED;;GAEG;AACH,MAAa,gCAAiC,SAAQ,iBAAiB;IACnE,YACI,MAAuC,EACvC,QAAkB,EACD,qBAAyC;QAE1D,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAFP,0BAAqB,GAArB,qBAAqB,CAAoB;IAG9D,CAAC;IAED,KAAK,CAAC,aAAa;QACf,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,iBAAiB;QACnB,OAAO,CAAE,IAAI,CAAC,qBAAqB,CAAE,CAAC;IAC1C,CAAC;CACJ;AAhBD,4EAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/playwright",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern library for Playwright",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"node": "^16.13 || ^18.12 || ^20"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@serenity-js/core": "3.
|
|
47
|
-
"@serenity-js/web": "3.
|
|
46
|
+
"@serenity-js/core": "3.6.0",
|
|
47
|
+
"@serenity-js/web": "3.6.0",
|
|
48
48
|
"playwright-core": "^1.35.1",
|
|
49
|
-
"tiny-types": "^1.
|
|
49
|
+
"tiny-types": "^1.20.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@integration/testing-tools": "3.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"mocha-multi": "^1.1.7",
|
|
58
58
|
"ts-node": "^10.9.1",
|
|
59
|
-
"typescript": "^5.
|
|
59
|
+
"typescript": "^5.1.6"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "970ac224860693ab70e813e176b7532241503b14"
|
|
62
62
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Discardable } from '@serenity-js/core';
|
|
2
|
-
import {
|
|
1
|
+
import type { Discardable } from '@serenity-js/core';
|
|
2
|
+
import { BrowseTheWeb } from '@serenity-js/web';
|
|
3
3
|
import type * as playwright from 'playwright-core';
|
|
4
4
|
|
|
5
|
-
import { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
6
|
-
import {
|
|
5
|
+
import type { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
6
|
+
import {
|
|
7
|
+
PlaywrightBrowsingSessionWithBrowser,
|
|
8
|
+
PlaywrightBrowsingSessionWithPage
|
|
9
|
+
} from '../models';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* This implementation of the {@apilink Ability|ability} to {@apilink BrowseTheWeb}
|
|
@@ -11,6 +14,14 @@ import { PlaywrightBrowsingSession } from '../models';
|
|
|
11
14
|
*
|
|
12
15
|
* ## Using Playwright to `BrowseTheWeb`
|
|
13
16
|
*
|
|
17
|
+
* In the example below, we configure the ability to {@apilink BrowseTheWebWithPlaywright} with a Playwright
|
|
18
|
+
* [`Browser`](https://playwright.dev/docs/api/class-browser) so that Serenity/JS {@apilink Actor|actors}
|
|
19
|
+
* can create a new [`BrowserContext`](https://playwright.dev/docs/api/class-browsercontext) and
|
|
20
|
+
* instantiate Playwright [`page`s](https://playwright.dev/docs/api/class-page) as and when needed.
|
|
21
|
+
*
|
|
22
|
+
* This configuration allows Serenity/JS to control the process of launching and shutting down browser instances
|
|
23
|
+
* and is useful when your test runner, e.g. [Cucumber.js](/api/cucumber), doesn't offer this functionality.
|
|
24
|
+
*
|
|
14
25
|
* ```ts
|
|
15
26
|
* import { actorCalled } from '@serenity-js/core'
|
|
16
27
|
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
@@ -33,6 +44,55 @@ import { PlaywrightBrowsingSession } from '../models';
|
|
|
33
44
|
* )
|
|
34
45
|
* ```
|
|
35
46
|
*
|
|
47
|
+
* ## Using `BrowseTheWeb` with an existing Playwright `page`
|
|
48
|
+
*
|
|
49
|
+
* Test runners like [Playwright Test](/api/playwright-test/) manage Playwright browsers for you
|
|
50
|
+
* and offer a [`page`](https://playwright.dev/docs/api/class-page) instance you can
|
|
51
|
+
* inject into the ability to {@apilink BrowseTheWebWithPlaywright}.
|
|
52
|
+
*
|
|
53
|
+
* Note that [Serenity/JS Playwright Test module](/api/playwright-test/)
|
|
54
|
+
* automatically configures all your {@apilink Actor|actors}
|
|
55
|
+
* with an ability to {@apilink BrowseTheWebWithPlaywright},
|
|
56
|
+
* so you don't need to do it by hand unless you want to override the {@apilink SerenityOptions|default configuration}.
|
|
57
|
+
*
|
|
58
|
+
* The example below demonstrates how to use the {@apilink BrowseTheWebWithPlaywright.usingPage} API and
|
|
59
|
+
* override the default {@apilink Cast} of actors.
|
|
60
|
+
*
|
|
61
|
+
* ```ts title="specs/example.spec.ts"
|
|
62
|
+
* import { describe, it, test } from '@playwright/playwright-test'
|
|
63
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
|
|
64
|
+
* import { By, Navigate, PageElement, Text } from '@serenity-js/web'
|
|
65
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
66
|
+
*
|
|
67
|
+
* const HomePage = {
|
|
68
|
+
* title: () =>
|
|
69
|
+
* PageElement.located(By.css('h1')).describedAs('title')
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* describe('Serenity/JS with Playwright', () => {
|
|
73
|
+
*
|
|
74
|
+
* test.use({
|
|
75
|
+
* actors: async ({ page, contextOptions }, use) => {
|
|
76
|
+
* await use(
|
|
77
|
+
* Cast.where((actorName: string) => {
|
|
78
|
+
* return actor.whoCan(
|
|
79
|
+
* BrowseTheWebWithPlaywright.usingPage(page),
|
|
80
|
+
* // ... add any other abilities
|
|
81
|
+
* )
|
|
82
|
+
* })
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
* })
|
|
86
|
+
*
|
|
87
|
+
* it('lets you reuse an existing page', async ({ actor }) => {
|
|
88
|
+
* await actor.attemptsTo(
|
|
89
|
+
* Navigate.to(`https://serenity-js.org`),
|
|
90
|
+
* Ensure.that(Text.of(HomePage.title()), equals('Serenity/JS')),
|
|
91
|
+
* )
|
|
92
|
+
* })
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
36
96
|
* ## Learn more
|
|
37
97
|
* - [Playwright website](https://playwright.dev/)
|
|
38
98
|
* - {@apilink BrowseTheWeb}
|
|
@@ -44,11 +104,11 @@ import { PlaywrightBrowsingSession } from '../models';
|
|
|
44
104
|
export class BrowseTheWebWithPlaywright extends BrowseTheWeb<playwright.Locator> implements Discardable {
|
|
45
105
|
|
|
46
106
|
static using(browser: playwright.Browser, options?: PlaywrightOptions): BrowseTheWebWithPlaywright {
|
|
47
|
-
return new BrowseTheWebWithPlaywright(browser, options);
|
|
107
|
+
return new BrowseTheWebWithPlaywright(new PlaywrightBrowsingSessionWithBrowser(browser, options));
|
|
48
108
|
}
|
|
49
109
|
|
|
50
|
-
|
|
51
|
-
|
|
110
|
+
static usingPage(page: playwright.Page, options?: PlaywrightOptions): BrowseTheWebWithPlaywright {
|
|
111
|
+
return new BrowseTheWebWithPlaywright(new PlaywrightBrowsingSessionWithPage(page, options));
|
|
52
112
|
}
|
|
53
113
|
|
|
54
114
|
/**
|
|
@@ -61,19 +121,4 @@ export class BrowseTheWebWithPlaywright extends BrowseTheWeb<playwright.Locator>
|
|
|
61
121
|
async discard(): Promise<void> {
|
|
62
122
|
await this.session.closeAllPages();
|
|
63
123
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Returns {@apilink BrowserCapabilities|basic meta-data} about the browser associated with this ability.
|
|
67
|
-
*
|
|
68
|
-
* **Please note** that since Playwright does not expose information about the operating system
|
|
69
|
-
* the tests are running on, **Serenity/JS assumes that the tests are running locally**
|
|
70
|
-
* and therefore returns the value of Node.js `process.platform` for `platformName`.
|
|
71
|
-
*/
|
|
72
|
-
async browserCapabilities(): Promise<BrowserCapabilities> {
|
|
73
|
-
return {
|
|
74
|
-
browserName: (this.browser as any)._initializer.name, // todo: raise a PR to Playwright to expose this information
|
|
75
|
-
platformName: process.platform, // todo: get the actual platform from Playwright
|
|
76
|
-
browserVersion: this.browser.version()
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
124
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CorrelationId } from '@serenity-js/core/lib/model';
|
|
2
|
-
import {
|
|
2
|
+
import type { BrowserCapabilities } from '@serenity-js/web';
|
|
3
|
+
import { BrowsingSession, type Cookie, type CookieData } from '@serenity-js/web';
|
|
3
4
|
import type * as playwright from 'playwright-core';
|
|
4
5
|
|
|
5
|
-
import { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
6
|
+
import { type PlaywrightOptions } from '../../PlaywrightOptions';
|
|
6
7
|
import { PlaywrightCookie, PlaywrightPage } from '../models';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -10,40 +11,22 @@ import { PlaywrightCookie, PlaywrightPage } from '../models';
|
|
|
10
11
|
*
|
|
11
12
|
* @group Models
|
|
12
13
|
*/
|
|
13
|
-
export class PlaywrightBrowsingSession extends BrowsingSession<PlaywrightPage> {
|
|
14
|
+
export abstract class PlaywrightBrowsingSession extends BrowsingSession<PlaywrightPage> {
|
|
14
15
|
|
|
15
16
|
private currentPlaywrightBrowserContext: playwright.BrowserContext;
|
|
16
17
|
|
|
17
|
-
constructor(
|
|
18
|
-
protected readonly browser: playwright.Browser,
|
|
19
|
-
protected readonly browserContextOptions: PlaywrightOptions,
|
|
20
|
-
) {
|
|
18
|
+
protected constructor(protected readonly browserContextOptions: PlaywrightOptions) {
|
|
21
19
|
super();
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
protected async registerCurrentPage(): Promise<PlaywrightPage> {
|
|
25
|
-
const context = await this.browserContext();
|
|
26
|
-
|
|
27
|
-
await context.newPage();
|
|
28
|
-
|
|
29
|
-
// calling context.newPage() triggers a callback registered via browserContext(),
|
|
30
|
-
// which wraps playwright.Page in PlaywrightPage and adds it to the list of pages
|
|
31
|
-
// returned by this.allPages()
|
|
32
|
-
|
|
33
|
-
const allPages = await this.allPages()
|
|
34
|
-
|
|
35
|
-
return allPages.at(-1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
22
|
/**
|
|
39
|
-
* @
|
|
23
|
+
* Returns {@apilink BrowserCapabilities|basic meta-data} about the browser associated with this ability.
|
|
24
|
+
*
|
|
25
|
+
* **Please note** that since Playwright does not expose information about the operating system
|
|
26
|
+
* the tests are running on, **Serenity/JS assumes that the tests are running locally**
|
|
27
|
+
* and therefore returns the value of Node.js `process.platform` for `platformName`.
|
|
40
28
|
*/
|
|
41
|
-
|
|
42
|
-
await super.closeAllPages();
|
|
43
|
-
|
|
44
|
-
const context = await this.browserContext();
|
|
45
|
-
await context.close();
|
|
46
|
-
}
|
|
29
|
+
public abstract browserCapabilities(): Promise<BrowserCapabilities>;
|
|
47
30
|
|
|
48
31
|
async cookie(name: string): Promise<Cookie> {
|
|
49
32
|
const context = await this.browserContext();
|
|
@@ -61,9 +44,23 @@ export class PlaywrightBrowsingSession extends BrowsingSession<PlaywrightPage> {
|
|
|
61
44
|
await context.clearCookies();
|
|
62
45
|
}
|
|
63
46
|
|
|
64
|
-
|
|
47
|
+
protected override async registerCurrentPage(): Promise<PlaywrightPage> {
|
|
48
|
+
const context = await this.browserContext();
|
|
49
|
+
|
|
50
|
+
await context.newPage();
|
|
51
|
+
|
|
52
|
+
// calling context.newPage() triggers a callback registered via browserContext(),
|
|
53
|
+
// which wraps playwright.Page in PlaywrightPage and adds it to the list of pages
|
|
54
|
+
// returned by this.allPages()
|
|
55
|
+
|
|
56
|
+
const allPages = await this.allPages()
|
|
57
|
+
|
|
58
|
+
return allPages.at(-1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected async browserContext(): Promise<playwright.BrowserContext> {
|
|
65
62
|
if (! this.currentPlaywrightBrowserContext) {
|
|
66
|
-
this.currentPlaywrightBrowserContext = await this.
|
|
63
|
+
this.currentPlaywrightBrowserContext = await this.createBrowserContext(this.browserContextOptions);
|
|
67
64
|
|
|
68
65
|
this.currentPlaywrightBrowserContext.on('page', async page => {
|
|
69
66
|
this.register(
|
|
@@ -82,4 +79,6 @@ export class PlaywrightBrowsingSession extends BrowsingSession<PlaywrightPage> {
|
|
|
82
79
|
|
|
83
80
|
return this.currentPlaywrightBrowserContext;
|
|
84
81
|
}
|
|
82
|
+
|
|
83
|
+
protected abstract createBrowserContext(options: PlaywrightOptions): Promise<playwright.BrowserContext>;
|
|
85
84
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BrowserCapabilities } from '@serenity-js/web';
|
|
2
|
+
import type * as playwright from 'playwright-core';
|
|
3
|
+
|
|
4
|
+
import type { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
5
|
+
import { PlaywrightBrowsingSession } from './PlaywrightBrowsingSession';
|
|
6
|
+
|
|
7
|
+
export class PlaywrightBrowsingSessionWithBrowser extends PlaywrightBrowsingSession {
|
|
8
|
+
constructor(
|
|
9
|
+
protected readonly browser: playwright.Browser,
|
|
10
|
+
browserContextOptions: PlaywrightOptions,
|
|
11
|
+
) {
|
|
12
|
+
super(browserContextOptions);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override createBrowserContext(options: PlaywrightOptions): Promise<playwright.BrowserContext> {
|
|
16
|
+
return this.browser.newContext(this.browserContextOptions);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override async closeAllPages(): Promise<void> {
|
|
20
|
+
await super.closeAllPages();
|
|
21
|
+
|
|
22
|
+
const context = await this.browserContext();
|
|
23
|
+
await context.close();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override async browserCapabilities(): Promise<BrowserCapabilities> {
|
|
27
|
+
return {
|
|
28
|
+
browserName: (this.browser as any)._initializer.name, // todo: raise a PR to Playwright to expose this information
|
|
29
|
+
platformName: process.platform, // todo: get the actual platform from Playwright
|
|
30
|
+
browserVersion: this.browser.version()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CorrelationId } from '@serenity-js/core/lib/model';
|
|
2
|
+
import type { BrowserCapabilities } from '@serenity-js/web';
|
|
3
|
+
import type * as playwright from 'playwright-core';
|
|
4
|
+
|
|
5
|
+
import type { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
6
|
+
import { PlaywrightBrowsingSession } from './PlaywrightBrowsingSession';
|
|
7
|
+
import { PlaywrightPage } from './PlaywrightPage';
|
|
8
|
+
|
|
9
|
+
export class PlaywrightBrowsingSessionWithPage extends PlaywrightBrowsingSession {
|
|
10
|
+
constructor(
|
|
11
|
+
protected readonly page: playwright.Page,
|
|
12
|
+
browserContextOptions: PlaywrightOptions,
|
|
13
|
+
) {
|
|
14
|
+
super(browserContextOptions);
|
|
15
|
+
this.currentBrowserPage = new PlaywrightPage(this, this.page, this.browserContextOptions, CorrelationId.create());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected override async createBrowserContext(options: PlaywrightOptions): Promise<playwright.BrowserContext> {
|
|
19
|
+
return this.page.context();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override async browserCapabilities(): Promise<BrowserCapabilities> {
|
|
23
|
+
const browser = await this.page.context().browser();
|
|
24
|
+
return {
|
|
25
|
+
browserName: (browser as any)._initializer.name, // todo: raise a PR to Playwright to expose this information
|
|
26
|
+
platformName: process.platform, // todo: get the actual platform from Playwright
|
|
27
|
+
browserVersion: browser.version()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Timestamp } from '@serenity-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import type { CookieData} from '@serenity-js/web';
|
|
3
|
+
import { Cookie, CookieMissingError } from '@serenity-js/web';
|
|
3
4
|
import type * as playwright from 'playwright-core';
|
|
4
5
|
import { ensure, isDefined } from 'tiny-types';
|
|
5
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ModalDialog} from '@serenity-js/web';
|
|
2
|
+
import { AbsentModalDialog, AcceptedModalDialog, DismissedModalDialog, ModalDialogHandler } from '@serenity-js/web';
|
|
2
3
|
import type * as playwright from 'playwright-core';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { LogicError, QuestionAdapter } from '@serenity-js/core';
|
|
1
|
+
import { LogicError, type QuestionAdapter } from '@serenity-js/core';
|
|
2
2
|
import { asyncMap } from '@serenity-js/core/lib/io';
|
|
3
|
-
import { CorrelationId } from '@serenity-js/core/lib/model';
|
|
4
|
-
import { Cookie, CookieData,
|
|
3
|
+
import type { CorrelationId } from '@serenity-js/core/lib/model';
|
|
4
|
+
import type { Cookie, CookieData, PageElement, Selector } from '@serenity-js/web';
|
|
5
|
+
import { ByDeepCss, Key, Page, PageElements } from '@serenity-js/web';
|
|
5
6
|
import type * as playwright from 'playwright-core';
|
|
6
7
|
import { URL } from 'url';
|
|
7
8
|
|
|
8
|
-
import { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
9
|
+
import type { PlaywrightOptions } from '../../PlaywrightOptions';
|
|
9
10
|
import { promised } from '../promised';
|
|
10
|
-
import { PlaywrightLocator, PlaywrightRootLocator } from './locators';
|
|
11
|
-
import { PlaywrightBrowsingSession } from './PlaywrightBrowsingSession';
|
|
11
|
+
import { PlaywrightExistingElementLocator, PlaywrightLocator, PlaywrightRootLocator } from './locators';
|
|
12
|
+
import type { PlaywrightBrowsingSession } from './PlaywrightBrowsingSession';
|
|
12
13
|
import { PlaywrightModalDialogHandler } from './PlaywrightModalDialogHandler';
|
|
13
14
|
import { PlaywrightPageElement } from './PlaywrightPageElement';
|
|
14
15
|
|
|
@@ -39,6 +40,16 @@ export class PlaywrightPage extends Page<playwright.Locator> {
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
createPageElement(nativeElement: playwright.Locator): PageElement<playwright.Locator> {
|
|
44
|
+
return new PlaywrightPageElement(
|
|
45
|
+
new PlaywrightExistingElementLocator(
|
|
46
|
+
this.rootLocator,
|
|
47
|
+
new ByDeepCss((nativeElement as any)._selector),
|
|
48
|
+
nativeElement,
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
locate(selector: Selector): PageElement<playwright.Locator> {
|
|
43
54
|
return new PlaywrightPageElement(
|
|
44
55
|
new PlaywrightLocator(
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { LogicError } from '@serenity-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import type { SwitchableOrigin } from '@serenity-js/web';
|
|
3
|
+
import { PageElement, SelectOption } from '@serenity-js/web';
|
|
3
4
|
import * as scripts from '@serenity-js/web/lib/scripts';
|
|
4
5
|
import type * as playwright from 'playwright-core';
|
|
5
6
|
import { ensure, isDefined } from 'tiny-types';
|
|
6
7
|
|
|
7
|
-
import { PlaywrightLocator } from './locators';
|
|
8
|
+
import type { PlaywrightLocator } from './locators';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Playwright-specific implementation of {@apilink PageElement}.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './locators';
|
|
2
2
|
export * from './PlaywrightBrowsingSession';
|
|
3
|
+
export * from './PlaywrightBrowsingSessionWithBrowser';
|
|
4
|
+
export * from './PlaywrightBrowsingSessionWithPage';
|
|
3
5
|
export * from './PlaywrightCookie';
|
|
4
6
|
export * from './PlaywrightPage';
|
|
5
7
|
export * from './PlaywrightPageElement';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { f, LogicError } from '@serenity-js/core';
|
|
2
|
-
import {
|
|
2
|
+
import type { PageElement, RootLocator, Selector } from '@serenity-js/web';
|
|
3
|
+
import { ByCss, ByCssContainingText, ByDeepCss, ById, ByTagName, ByXPath, Locator } from '@serenity-js/web';
|
|
3
4
|
import type * as playwright from 'playwright-core';
|
|
4
5
|
|
|
5
6
|
import { promised } from '../../promised';
|
|
6
7
|
import { PlaywrightPageElement } from '../PlaywrightPageElement';
|
|
7
|
-
import { PlaywrightRootLocator } from './PlaywrightRootLocator';
|
|
8
|
+
import type { PlaywrightRootLocator } from './PlaywrightRootLocator';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Playwright-specific implementation of {@apilink Locator}.
|
|
@@ -104,7 +105,7 @@ export class PlaywrightLocator extends Locator<playwright.Locator, string> {
|
|
|
104
105
|
|
|
105
106
|
return elements.map(childElement =>
|
|
106
107
|
new PlaywrightPageElement(
|
|
107
|
-
new
|
|
108
|
+
new PlaywrightExistingElementLocator(
|
|
108
109
|
this.parent as PlaywrightRootLocator,
|
|
109
110
|
this.selector,
|
|
110
111
|
childElement,
|
|
@@ -115,9 +116,9 @@ export class PlaywrightLocator extends Locator<playwright.Locator, string> {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
|
-
* @
|
|
119
|
+
* @internal
|
|
119
120
|
*/
|
|
120
|
-
class
|
|
121
|
+
export class PlaywrightExistingElementLocator extends PlaywrightLocator {
|
|
121
122
|
constructor(
|
|
122
123
|
parent: RootLocator<playwright.Locator>,
|
|
123
124
|
selector: Selector,
|