@serenity-js/playwright 3.42.2 → 3.43.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 +17 -0
- package/esm/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts +60 -2
- package/esm/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts.map +1 -1
- package/esm/screenplay/abilities/BrowseTheWebWithPlaywright.js +74 -2
- package/esm/screenplay/abilities/BrowseTheWebWithPlaywright.js.map +1 -1
- package/esm/screenplay/models/ElectronLaunchOptions.d.ts +55 -0
- package/esm/screenplay/models/ElectronLaunchOptions.d.ts.map +1 -0
- package/esm/screenplay/models/ElectronLaunchOptions.js +2 -0
- package/esm/screenplay/models/ElectronLaunchOptions.js.map +1 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts +3 -2
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts.map +1 -1
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js +6 -5
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js.map +1 -1
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithElectron.d.ts +52 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithElectron.d.ts.map +1 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithElectron.js +103 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithElectron.js.map +1 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts +1 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts.map +1 -1
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithPage.js +3 -0
- package/esm/screenplay/models/PlaywrightBrowsingSessionWithPage.js.map +1 -1
- package/esm/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.d.ts +52 -0
- package/esm/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.d.ts.map +1 -0
- package/esm/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.js +70 -0
- package/esm/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.js.map +1 -0
- package/esm/screenplay/models/index.d.ts +3 -0
- package/esm/screenplay/models/index.d.ts.map +1 -1
- package/esm/screenplay/models/index.js +3 -0
- package/esm/screenplay/models/index.js.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts +60 -2
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.d.ts.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js +73 -1
- package/lib/screenplay/abilities/BrowseTheWebWithPlaywright.js.map +1 -1
- package/lib/screenplay/models/ElectronLaunchOptions.d.ts +55 -0
- package/lib/screenplay/models/ElectronLaunchOptions.d.ts.map +1 -0
- package/lib/screenplay/models/ElectronLaunchOptions.js +3 -0
- package/lib/screenplay/models/ElectronLaunchOptions.js.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts +3 -2
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js +6 -5
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithBrowser.js.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithElectron.d.ts +52 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithElectron.d.ts.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithElectron.js +107 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithElectron.js.map +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts +1 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.d.ts.map +1 -1
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.js +3 -0
- package/lib/screenplay/models/PlaywrightBrowsingSessionWithPage.js.map +1 -1
- package/lib/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.d.ts +52 -0
- package/lib/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.d.ts.map +1 -0
- package/lib/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.js +107 -0
- package/lib/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +3 -0
- package/lib/screenplay/models/index.d.ts.map +1 -1
- package/lib/screenplay/models/index.js +3 -0
- package/lib/screenplay/models/index.js.map +1 -1
- package/package.json +13 -6
- package/src/screenplay/abilities/BrowseTheWebWithPlaywright.ts +112 -7
- package/src/screenplay/models/ElectronLaunchOptions.ts +55 -0
- package/src/screenplay/models/PlaywrightBrowsingSessionWithBrowser.ts +13 -8
- package/src/screenplay/models/PlaywrightBrowsingSessionWithElectron.ts +129 -0
- package/src/screenplay/models/PlaywrightBrowsingSessionWithPage.ts +4 -0
- package/src/screenplay/models/SelfLaunchingPlaywrightBrowsingSessionWithElectron.ts +85 -0
- package/src/screenplay/models/index.ts +3 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Discardable, Initialisable } from '@serenity-js/core';
|
|
2
|
+
import * as playwright from 'playwright-core';
|
|
3
|
+
|
|
4
|
+
import type { ExtraBrowserContextOptions } from '../../ExtraBrowserContextOptions.js';
|
|
5
|
+
import type { ElectronLaunchOptions } from './ElectronLaunchOptions.js';
|
|
6
|
+
import { PlaywrightBrowsingSessionWithElectron } from './PlaywrightBrowsingSessionWithElectron.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Self-launching implementation of [`PlaywrightBrowsingSession`](https://serenity-js.org/api/playwright/class/PlaywrightBrowsingSession/)
|
|
10
|
+
* for Electron applications.
|
|
11
|
+
*
|
|
12
|
+
* This class launches the Electron application on first use and closes it when discarded.
|
|
13
|
+
* Use this for test runners like Mocha or Jasmine that don't manage Electron lifecycle.
|
|
14
|
+
*
|
|
15
|
+
* ## Example
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
19
|
+
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright';
|
|
20
|
+
*
|
|
21
|
+
* const actor = actorCalled('Tester').whoCan(
|
|
22
|
+
* BrowseTheWebWithPlaywright.launchingElectronApp({
|
|
23
|
+
* args: ['path/to/main.js'],
|
|
24
|
+
* cwd: 'path/to/app',
|
|
25
|
+
* })
|
|
26
|
+
* );
|
|
27
|
+
*
|
|
28
|
+
* // The app is automatically closed when the actor is dismissed
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @group Models
|
|
32
|
+
*/
|
|
33
|
+
export class SelfLaunchingPlaywrightBrowsingSessionWithElectron
|
|
34
|
+
extends PlaywrightBrowsingSessionWithElectron
|
|
35
|
+
implements Initialisable, Discardable
|
|
36
|
+
{
|
|
37
|
+
constructor(
|
|
38
|
+
private readonly launchOptions: ElectronLaunchOptions,
|
|
39
|
+
extraBrowserContextOptions: Partial<ExtraBrowserContextOptions>,
|
|
40
|
+
selectors: playwright.Selectors,
|
|
41
|
+
) {
|
|
42
|
+
// setting electronApp to undefined since it's lazily initialised
|
|
43
|
+
super(undefined, extraBrowserContextOptions, selectors);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Launches the Electron application using the configured launch options.
|
|
48
|
+
*
|
|
49
|
+
* This method is idempotent - calling it multiple times will only launch
|
|
50
|
+
* the application once.
|
|
51
|
+
*/
|
|
52
|
+
async initialise(): Promise<void> {
|
|
53
|
+
if (this.electronApp) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.electronApp = await playwright._electron.launch(this.launchOptions);
|
|
58
|
+
this.currentBrowserPage = await this.registerCurrentPage();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns `true` if the Electron application has been launched.
|
|
63
|
+
*/
|
|
64
|
+
isInitialised(): boolean {
|
|
65
|
+
return this.electronApp !== undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Closes the Electron application that was launched by this session.
|
|
70
|
+
* Called when the ability is discarded.
|
|
71
|
+
*/
|
|
72
|
+
async closeElectronApp(): Promise<void> {
|
|
73
|
+
if (this.electronApp) {
|
|
74
|
+
await this.electronApp.close();
|
|
75
|
+
this.electronApp = undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async discard(): Promise<void> {
|
|
80
|
+
await this.closeElectronApp();
|
|
81
|
+
|
|
82
|
+
this.pages.clear();
|
|
83
|
+
this.currentBrowserPage = undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from './ElectronLaunchOptions.js';
|
|
1
2
|
export * from './locators/index.js';
|
|
2
3
|
export * from './PlaywrightBrowsingSession.js';
|
|
3
4
|
export * from './PlaywrightBrowsingSessionWithBrowser.js';
|
|
5
|
+
export * from './PlaywrightBrowsingSessionWithElectron.js';
|
|
4
6
|
export * from './PlaywrightBrowsingSessionWithPage.js';
|
|
5
7
|
export * from './PlaywrightCookie.js';
|
|
6
8
|
export * from './PlaywrightPage.js';
|
|
7
9
|
export * from './PlaywrightPageElement.js';
|
|
10
|
+
export * from './SelfLaunchingPlaywrightBrowsingSessionWithElectron.js';
|