@allwright.dev/core 0.0.43 → 0.0.45
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/dist/bootstrap.d.ts +2 -0
- package/dist/bootstrap.js +63 -18
- package/dist/config.js +73 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/mobile.d.ts +2 -0
- package/dist/mobile.js +103 -0
- package/dist/runtime.js +3 -0
- package/dist/types.d.ts +86 -7
- package/package.json +1 -1
package/dist/bootstrap.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function ensureRuntimeReady(serverAddr: string): Promise<string>;
|
|
2
2
|
export declare function shutdownManagedServer(): Promise<void>;
|
|
3
|
+
export declare function ensurePluginsInstalled(pluginIds: string[]): Promise<void>;
|
|
4
|
+
export declare function invokePlugin<TResponse>(pluginId: string, request: unknown): Promise<TResponse>;
|
package/dist/bootstrap.js
CHANGED
|
@@ -12,7 +12,7 @@ const ALLWRIGHT_HOME_ENV_VAR = "ALLWRIGHT_HOME";
|
|
|
12
12
|
const ALLWRIGHT_REPOSITORY_ENV_VAR = "ALLWRIGHT_REPOSITORY";
|
|
13
13
|
const ALLWRIGHT_VERSION_ENV_VAR = "ALLWRIGHT_VERSION";
|
|
14
14
|
const DEFAULT_RELEASE_REPOSITORY = "allwright-dev/allwright";
|
|
15
|
-
const DEFAULT_RELEASE_VERSION = "0.0.
|
|
15
|
+
const DEFAULT_RELEASE_VERSION = "0.0.45";
|
|
16
16
|
const STARTUP_TIMEOUT_MS = 20_000;
|
|
17
17
|
const PING_TIMEOUT_MS = 1_000;
|
|
18
18
|
const PROTO_ROOT = fileURLToPath(new URL("../proto/", import.meta.url));
|
|
@@ -50,7 +50,7 @@ export async function ensureRuntimeReady(serverAddr) {
|
|
|
50
50
|
managedServerSpawnError = null;
|
|
51
51
|
}
|
|
52
52
|
const cliPath = await ensureCliAvailable(expectedVersion);
|
|
53
|
-
|
|
53
|
+
ensurePluginsInstalledWithCli(cliPath, expectedVersion, ["web"]);
|
|
54
54
|
let resolvedServerAddr = serverAddr;
|
|
55
55
|
if (status && status.version !== expectedVersion) {
|
|
56
56
|
resolvedServerAddr = await allocateManagedServerAddr(serverAddr);
|
|
@@ -169,29 +169,63 @@ async function installCli() {
|
|
|
169
169
|
fs.rmSync(assetPath, { force: true });
|
|
170
170
|
return cliPath;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
export async function ensurePluginsInstalled(pluginIds) {
|
|
173
|
+
const expectedVersion = expectedRuntimeVersion();
|
|
174
|
+
const cliPath = await ensureCliAvailable(expectedVersion);
|
|
175
|
+
ensurePluginsInstalledWithCli(cliPath, expectedVersion, pluginIds);
|
|
176
|
+
}
|
|
177
|
+
export async function invokePlugin(pluginId, request) {
|
|
178
|
+
const expectedVersion = expectedRuntimeVersion();
|
|
179
|
+
const cliPath = await ensureCliAvailable(expectedVersion);
|
|
180
|
+
const requestJson = JSON.stringify(request);
|
|
181
|
+
const result = spawnSync(cliPath, ["plugin", "invoke", pluginId, "--request-json", requestJson], {
|
|
178
182
|
encoding: "utf8",
|
|
179
183
|
stdio: ["ignore", "pipe", "pipe"],
|
|
180
184
|
});
|
|
181
185
|
if (result.error) {
|
|
182
|
-
throw new Error(`failed to
|
|
186
|
+
throw new Error(`failed to invoke allwright ${pluginId} plugin with ${cliPath}: ${result.error.message}`);
|
|
183
187
|
}
|
|
184
|
-
if (result.status !== 0
|
|
188
|
+
if (result.status !== 0) {
|
|
185
189
|
const details = [result.stdout, result.stderr]
|
|
186
190
|
.map((value) => value?.trim())
|
|
187
191
|
.filter((value) => !!value)
|
|
188
192
|
.join("\n");
|
|
189
193
|
throw new Error(details
|
|
190
|
-
? `allwright
|
|
191
|
-
:
|
|
194
|
+
? `allwright ${pluginId} plugin invocation failed:\n${details}`
|
|
195
|
+
: `allwright ${pluginId} plugin invocation failed`);
|
|
192
196
|
}
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
try {
|
|
198
|
+
return JSON.parse(result.stdout);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
throw new Error(`failed to decode allwright ${pluginId} plugin response: ${error instanceof Error ? error.message : String(error)}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function ensurePluginsInstalledWithCli(cliPath, expectedVersion, pluginIds) {
|
|
205
|
+
for (const pluginId of new Set(pluginIds.map((value) => value.trim()).filter(Boolean))) {
|
|
206
|
+
const pluginPath = path.join(allwrightHome(), "plugins", pluginId, "lib", pluginLibraryFilename(pluginId));
|
|
207
|
+
if (isFile(pluginPath) && installedPluginVersion(pluginId) === expectedVersion) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const result = spawnSync(cliPath, ["plugin", "install", pluginId, "--version", expectedVersion], {
|
|
211
|
+
encoding: "utf8",
|
|
212
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
213
|
+
});
|
|
214
|
+
if (result.error) {
|
|
215
|
+
throw new Error(`failed to install allwright ${pluginId} plugin with ${cliPath}: ${result.error.message}`);
|
|
216
|
+
}
|
|
217
|
+
if (result.status !== 0 || !isFile(pluginPath)) {
|
|
218
|
+
const details = [result.stdout, result.stderr]
|
|
219
|
+
.map((value) => value?.trim())
|
|
220
|
+
.filter((value) => !!value)
|
|
221
|
+
.join("\n");
|
|
222
|
+
throw new Error(details
|
|
223
|
+
? `allwright attempted to install the \`${pluginId}\` plugin automatically, but the install did not complete successfully:\n${details}`
|
|
224
|
+
: `allwright attempted to install the \`${pluginId}\` plugin automatically, but the install did not complete successfully`);
|
|
225
|
+
}
|
|
226
|
+
if (installedPluginVersion(pluginId) !== expectedVersion) {
|
|
227
|
+
throw new Error(`allwright attempted to install the \`${pluginId}\` plugin automatically, but version ${expectedVersion} is still not active`);
|
|
228
|
+
}
|
|
195
229
|
}
|
|
196
230
|
}
|
|
197
231
|
async function resolveReleaseTag() {
|
|
@@ -421,14 +455,25 @@ function findExtractedCli(extractRoot) {
|
|
|
421
455
|
}
|
|
422
456
|
return null;
|
|
423
457
|
}
|
|
424
|
-
function
|
|
458
|
+
function pluginLibraryFilename(pluginId) {
|
|
459
|
+
const stem = pluginLibraryStem(pluginId);
|
|
425
460
|
if (process.platform === "darwin") {
|
|
426
|
-
return
|
|
461
|
+
return `lib${stem}.dylib`;
|
|
427
462
|
}
|
|
428
463
|
if (process.platform === "win32") {
|
|
429
|
-
return
|
|
464
|
+
return `${stem}.dll`;
|
|
465
|
+
}
|
|
466
|
+
return `lib${stem}.so`;
|
|
467
|
+
}
|
|
468
|
+
function pluginLibraryStem(pluginId) {
|
|
469
|
+
switch (pluginId) {
|
|
470
|
+
case "web":
|
|
471
|
+
return "allwright_surface_web";
|
|
472
|
+
case "mobile-android":
|
|
473
|
+
return "allwright_surface_mobile_android";
|
|
474
|
+
default:
|
|
475
|
+
throw new Error(`automatic install is not supported for allwright plugin \`${pluginId}\``);
|
|
430
476
|
}
|
|
431
|
-
return "liballwright_surface_web.so";
|
|
432
477
|
}
|
|
433
478
|
function autoInstallEnabled() {
|
|
434
479
|
const raw = process.env[ALLWRIGHT_AUTO_INSTALL_ENV_VAR]?.trim().toLowerCase();
|
package/dist/config.js
CHANGED
|
@@ -40,9 +40,12 @@ export function resolveConfig(options = {}) {
|
|
|
40
40
|
throw new Error(`allwright config suite "${suiteName}" was not found in ${configFilePath ?? "the resolved config file"}`);
|
|
41
41
|
}
|
|
42
42
|
const serverAddr = suiteConfig?.server?.addr ?? fileConfig.server?.addr;
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
const web = resolveWebSurface(fileConfig.web, suiteConfig?.web);
|
|
44
|
+
const mobile = resolveMobileSurface(fileConfig.mobile, suiteConfig?.mobile);
|
|
45
|
+
const desktop = resolveDesktopSurface(fileConfig.desktop, suiteConfig?.desktop);
|
|
46
|
+
const browserName = web?.browserName ?? defaultBrowserNameForResolvedSurfaces(mobile, desktop);
|
|
47
|
+
const browserBinary = web?.browserBinary;
|
|
48
|
+
const launchOptions = web?.launchOptions ?? {};
|
|
46
49
|
const expect = {
|
|
47
50
|
...(fileConfig.expect ?? {}),
|
|
48
51
|
...(suiteConfig?.expect ?? {}),
|
|
@@ -55,6 +58,9 @@ export function resolveConfig(options = {}) {
|
|
|
55
58
|
browserBinary,
|
|
56
59
|
launchOptions: browserBinary ? { ...launchOptions, browserBinary } : launchOptions,
|
|
57
60
|
expect,
|
|
61
|
+
web,
|
|
62
|
+
mobile,
|
|
63
|
+
desktop,
|
|
58
64
|
};
|
|
59
65
|
}
|
|
60
66
|
function mergeLaunchOptions(base, override) {
|
|
@@ -71,11 +77,74 @@ function validateConfigShape(value, source) {
|
|
|
71
77
|
if (config.schemaVersion !== undefined && config.schemaVersion !== 1) {
|
|
72
78
|
throw new Error(`allwright config ${source} has unsupported schemaVersion ${String(config.schemaVersion)}; expected 1`);
|
|
73
79
|
}
|
|
74
|
-
const browserName = config.browser?.name;
|
|
80
|
+
const browserName = ((config.web?.browser)?.name);
|
|
75
81
|
if (browserName !== undefined && browserName !== "chromium" && browserName !== "firefox") {
|
|
76
82
|
throw new Error(`allwright config ${source} has unsupported browser.name ${String(browserName)}; use "chromium" or "firefox"`);
|
|
77
83
|
}
|
|
78
84
|
}
|
|
85
|
+
function resolveMobileSurface(base, override) {
|
|
86
|
+
return {
|
|
87
|
+
android: resolveMobileTarget(base?.android, override?.android),
|
|
88
|
+
ios: resolveMobileTarget(base?.ios, override?.ios),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function resolveDesktopSurface(base, override) {
|
|
92
|
+
return {
|
|
93
|
+
mac: resolveDesktopTarget(base?.mac, override?.mac),
|
|
94
|
+
windows: resolveDesktopTarget(base?.windows, override?.windows),
|
|
95
|
+
linux: resolveDesktopTarget(base?.linux, override?.linux),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function resolveWebSurface(base, override) {
|
|
99
|
+
const browser = override?.browser ?? base?.browser;
|
|
100
|
+
const browserName = override?.browser?.name ?? base?.browser?.name;
|
|
101
|
+
const browserBinary = override?.browser?.binary ?? base?.browser?.binary;
|
|
102
|
+
const launchOptions = mergeLaunchOptions(base?.browser?.launchOptions, override?.browser?.launchOptions);
|
|
103
|
+
if (!browser && !browserName && !browserBinary && !Object.keys(launchOptions).length) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
browserName,
|
|
108
|
+
browserBinary,
|
|
109
|
+
launchOptions: browserBinary ? { ...launchOptions, browserBinary } : launchOptions,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function resolveMobileTarget(base, override) {
|
|
113
|
+
const app = mergeAppConfig(base?.app, override?.app);
|
|
114
|
+
const resolved = {
|
|
115
|
+
device: override?.device ?? base?.device,
|
|
116
|
+
appId: app?.id,
|
|
117
|
+
appBinary: app?.binary,
|
|
118
|
+
appActivity: app?.activity,
|
|
119
|
+
};
|
|
120
|
+
return hasResolvedValues(resolved) ? resolved : undefined;
|
|
121
|
+
}
|
|
122
|
+
function resolveDesktopTarget(base, override) {
|
|
123
|
+
const app = mergeAppConfig(base?.app, override?.app);
|
|
124
|
+
const resolved = {
|
|
125
|
+
appId: app?.id,
|
|
126
|
+
appBinary: app?.binary,
|
|
127
|
+
appActivity: app?.activity,
|
|
128
|
+
};
|
|
129
|
+
return hasResolvedValues(resolved) ? resolved : undefined;
|
|
130
|
+
}
|
|
131
|
+
function mergeAppConfig(base, override) {
|
|
132
|
+
const resolved = {
|
|
133
|
+
id: override?.id ?? base?.id,
|
|
134
|
+
binary: override?.binary ?? base?.binary,
|
|
135
|
+
activity: override?.activity ?? base?.activity,
|
|
136
|
+
};
|
|
137
|
+
return hasResolvedValues(resolved) ? resolved : undefined;
|
|
138
|
+
}
|
|
139
|
+
function hasResolvedValues(value) {
|
|
140
|
+
return Object.values(value).some((entry) => entry !== undefined && entry !== null && entry !== "");
|
|
141
|
+
}
|
|
142
|
+
function defaultBrowserNameForResolvedSurfaces(mobile, desktop) {
|
|
143
|
+
if (mobile.android || mobile.ios || desktop.mac || desktop.windows || desktop.linux) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
return "chromium";
|
|
147
|
+
}
|
|
79
148
|
function parseConfigContents(raw, source) {
|
|
80
149
|
const extension = path.extname(source).toLowerCase();
|
|
81
150
|
if (extension === ".json") {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { BrowserImpl, BrowserTypeImpl } from "./browser.js";
|
|
2
2
|
import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
|
|
3
|
+
import { mobile } from "./mobile.js";
|
|
3
4
|
import { PageImpl } from "./page.js";
|
|
4
5
|
import { setServerAddr, shutdown } from "./runtime.js";
|
|
5
6
|
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
6
7
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
7
|
-
export type { AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, Locator, LocatorInfo, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
8
|
+
export type { AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidPage, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
8
9
|
export declare const chromium: BrowserType;
|
|
9
10
|
export declare const firefox: BrowserType;
|
|
11
|
+
export { mobile };
|
|
10
12
|
export type Tab = Page;
|
|
11
13
|
export declare function ping(): Promise<string>;
|
|
12
14
|
export declare function launchChrome(options?: LaunchOptions): Promise<Browser>;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BrowserImpl, BrowserTypeImpl } from "./browser.js";
|
|
2
2
|
import { formatActionError } from "./errors.js";
|
|
3
3
|
import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
|
|
4
|
+
import { mobile } from "./mobile.js";
|
|
4
5
|
import { PageImpl } from "./page.js";
|
|
5
6
|
import { createBrowserSessionHandle, getRuntime, launchConfiguredBrowser as launchConfiguredBrowserWithResolver, ping as runtimePing, resolveLaunchBrowserArgs, setServerAddr, shutdown, } from "./runtime.js";
|
|
6
7
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
7
8
|
export const chromium = new BrowserTypeImpl("chromium");
|
|
8
9
|
export const firefox = new BrowserTypeImpl("firefox");
|
|
10
|
+
export { mobile };
|
|
9
11
|
export async function ping() {
|
|
10
12
|
return runtimePing();
|
|
11
13
|
}
|
package/dist/mobile.d.ts
ADDED
package/dist/mobile.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ensurePluginsInstalled, invokePlugin } from "./bootstrap.js";
|
|
2
|
+
function timeoutMsOf(options) {
|
|
3
|
+
return options?.timeoutMs;
|
|
4
|
+
}
|
|
5
|
+
async function invokeAndroidExpected(commandName, request) {
|
|
6
|
+
const envelope = await invokePlugin("mobile-android", request);
|
|
7
|
+
if (!envelope.ok) {
|
|
8
|
+
throw new Error(envelope.error ?? `mobile-android plugin ${commandName} failed`);
|
|
9
|
+
}
|
|
10
|
+
if (envelope.result === undefined) {
|
|
11
|
+
throw new Error(`mobile-android plugin ${commandName} returned no result`);
|
|
12
|
+
}
|
|
13
|
+
return envelope.result;
|
|
14
|
+
}
|
|
15
|
+
class MobileAndroidPageImpl {
|
|
16
|
+
browserSession;
|
|
17
|
+
pageSession;
|
|
18
|
+
constructor(browserSession, pageSession) {
|
|
19
|
+
this.browserSession = browserSession;
|
|
20
|
+
this.pageSession = pageSession;
|
|
21
|
+
}
|
|
22
|
+
get sessionId() {
|
|
23
|
+
return this.pageSession.page_id;
|
|
24
|
+
}
|
|
25
|
+
async click(selector, options = {}) {
|
|
26
|
+
const result = await invokeAndroidExpected("click", {
|
|
27
|
+
command: "click_element",
|
|
28
|
+
browser_session: this.browserSession,
|
|
29
|
+
page_session: this.pageSession,
|
|
30
|
+
selector,
|
|
31
|
+
timeout_ms: timeoutMsOf(options),
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
selector: result.selector,
|
|
35
|
+
note: result.note,
|
|
36
|
+
bidiSessionId: result.session_id,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async fill(selector, value, options = {}) {
|
|
40
|
+
const result = await invokeAndroidExpected("fill", {
|
|
41
|
+
command: "fill_element",
|
|
42
|
+
browser_session: this.browserSession,
|
|
43
|
+
page_session: this.pageSession,
|
|
44
|
+
selector,
|
|
45
|
+
value,
|
|
46
|
+
timeout_ms: timeoutMsOf(options),
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
selector: result.selector,
|
|
50
|
+
value: result.value,
|
|
51
|
+
note: result.note,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class MobileAndroidDeviceImpl {
|
|
56
|
+
connectInfoRaw;
|
|
57
|
+
#initialPage;
|
|
58
|
+
constructor(connectInfoRaw) {
|
|
59
|
+
this.connectInfoRaw = connectInfoRaw;
|
|
60
|
+
this.#initialPage = new MobileAndroidPageImpl(this.connectInfoRaw.browser_session, this.connectInfoRaw.initial_page.page_session);
|
|
61
|
+
}
|
|
62
|
+
get sessionId() {
|
|
63
|
+
return this.connectInfoRaw.browser_session.automation.session_id;
|
|
64
|
+
}
|
|
65
|
+
page() {
|
|
66
|
+
return this.#initialPage;
|
|
67
|
+
}
|
|
68
|
+
initialPage() {
|
|
69
|
+
return this.#initialPage;
|
|
70
|
+
}
|
|
71
|
+
async launch(options = {}) {
|
|
72
|
+
const page = await invokeAndroidExpected("launch", {
|
|
73
|
+
command: "launch_app",
|
|
74
|
+
browser_session: this.connectInfoRaw.browser_session,
|
|
75
|
+
options: {
|
|
76
|
+
apk_path: options.apkPath,
|
|
77
|
+
app_id: options.appId,
|
|
78
|
+
launch_activity: options.launchActivity,
|
|
79
|
+
stop_before_launch: options.stopBeforeLaunch ?? false,
|
|
80
|
+
timeout_ms: timeoutMsOf(options),
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
this.#initialPage = new MobileAndroidPageImpl(this.connectInfoRaw.browser_session, page.page_session);
|
|
84
|
+
return this.#initialPage;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class MobileAndroidSurfaceImpl {
|
|
88
|
+
async connect(options = {}) {
|
|
89
|
+
await ensurePluginsInstalled(["mobile-android"]);
|
|
90
|
+
const connectInfo = await invokeAndroidExpected("connect", {
|
|
91
|
+
command: "connect",
|
|
92
|
+
platform: "android",
|
|
93
|
+
device: options.device,
|
|
94
|
+
adb_endpoint: options.adbEndpoint,
|
|
95
|
+
preserve_app_state: options.preserveAppState ?? false,
|
|
96
|
+
timeout_ms: timeoutMsOf(options),
|
|
97
|
+
});
|
|
98
|
+
return new MobileAndroidDeviceImpl(connectInfo);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export const mobile = {
|
|
102
|
+
android: new MobileAndroidSurfaceImpl(),
|
|
103
|
+
};
|
package/dist/runtime.js
CHANGED
|
@@ -57,6 +57,9 @@ export async function createBrowserSessionHandle(runtime) {
|
|
|
57
57
|
return { stream, queue };
|
|
58
58
|
}
|
|
59
59
|
export async function launchConfiguredBrowser(config, launchBrowserKind) {
|
|
60
|
+
if (!config.browserName) {
|
|
61
|
+
throw new Error("resolved config does not define web.browser.name and includes only non-web surfaces");
|
|
62
|
+
}
|
|
60
63
|
return launchBrowserKind(config.browserName, {
|
|
61
64
|
...config.launchOptions,
|
|
62
65
|
browserBinary: config.browserBinary ?? config.launchOptions.browserBinary,
|
package/dist/types.d.ts
CHANGED
|
@@ -114,6 +114,35 @@ export interface Page extends PageInfo {
|
|
|
114
114
|
ping(message?: string): Promise<string>;
|
|
115
115
|
pageInfo(): PageInfo;
|
|
116
116
|
}
|
|
117
|
+
export interface MobileAndroidConnectOptions {
|
|
118
|
+
device?: string;
|
|
119
|
+
adbEndpoint?: string;
|
|
120
|
+
preserveAppState?: boolean;
|
|
121
|
+
timeoutMs?: number;
|
|
122
|
+
}
|
|
123
|
+
export interface MobileAndroidLaunchOptions {
|
|
124
|
+
apkPath?: string;
|
|
125
|
+
appId?: string;
|
|
126
|
+
launchActivity?: string;
|
|
127
|
+
stopBeforeLaunch?: boolean;
|
|
128
|
+
timeoutMs?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface MobileAndroidPage {
|
|
131
|
+
readonly sessionId: string;
|
|
132
|
+
click(selector: string, options?: CommandOptions): Promise<ClickResult>;
|
|
133
|
+
fill(selector: string, value: string, options?: CommandOptions): Promise<FillResult>;
|
|
134
|
+
}
|
|
135
|
+
export interface MobileAndroidDevice {
|
|
136
|
+
readonly sessionId: string;
|
|
137
|
+
page(): MobileAndroidPage;
|
|
138
|
+
initialPage(): MobileAndroidPage;
|
|
139
|
+
launch(options?: MobileAndroidLaunchOptions): Promise<MobileAndroidPage>;
|
|
140
|
+
}
|
|
141
|
+
export interface MobileSurfaceNamespace {
|
|
142
|
+
android: {
|
|
143
|
+
connect(options?: MobileAndroidConnectOptions): Promise<MobileAndroidDevice>;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
117
146
|
export interface Locator {
|
|
118
147
|
readonly page: Page;
|
|
119
148
|
readonly selector: string;
|
|
@@ -134,11 +163,9 @@ export interface AllwrightConfig {
|
|
|
134
163
|
server?: {
|
|
135
164
|
addr?: string;
|
|
136
165
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
launchOptions?: LaunchOptions;
|
|
141
|
-
};
|
|
166
|
+
web?: WebConfig;
|
|
167
|
+
mobile?: MobileConfig;
|
|
168
|
+
desktop?: DesktopConfig;
|
|
142
169
|
expect?: RetryConfig;
|
|
143
170
|
suites?: Record<string, AllwrightSuiteConfig>;
|
|
144
171
|
}
|
|
@@ -146,25 +173,77 @@ export interface AllwrightSuiteConfig {
|
|
|
146
173
|
server?: {
|
|
147
174
|
addr?: string;
|
|
148
175
|
};
|
|
176
|
+
web?: WebConfig;
|
|
177
|
+
mobile?: MobileConfig;
|
|
178
|
+
desktop?: DesktopConfig;
|
|
179
|
+
expect?: RetryConfig;
|
|
180
|
+
}
|
|
181
|
+
export interface WebConfig {
|
|
149
182
|
browser?: {
|
|
150
183
|
name?: BrowserKind;
|
|
151
184
|
binary?: string;
|
|
152
185
|
launchOptions?: LaunchOptions;
|
|
153
186
|
};
|
|
154
|
-
|
|
187
|
+
}
|
|
188
|
+
export interface SurfaceAppConfig {
|
|
189
|
+
id?: string;
|
|
190
|
+
binary?: string;
|
|
191
|
+
activity?: string;
|
|
192
|
+
}
|
|
193
|
+
export interface SurfaceMobileTargetConfig {
|
|
194
|
+
device?: string;
|
|
195
|
+
app?: SurfaceAppConfig;
|
|
196
|
+
}
|
|
197
|
+
export interface SurfaceDesktopTargetConfig {
|
|
198
|
+
app?: SurfaceAppConfig;
|
|
199
|
+
}
|
|
200
|
+
export interface MobileConfig {
|
|
201
|
+
android?: SurfaceMobileTargetConfig;
|
|
202
|
+
ios?: SurfaceMobileTargetConfig;
|
|
203
|
+
}
|
|
204
|
+
export interface DesktopConfig {
|
|
205
|
+
mac?: SurfaceDesktopTargetConfig;
|
|
206
|
+
windows?: SurfaceDesktopTargetConfig;
|
|
207
|
+
linux?: SurfaceDesktopTargetConfig;
|
|
155
208
|
}
|
|
156
209
|
export interface RetryConfig {
|
|
157
210
|
timeoutMs?: number;
|
|
158
211
|
intervalMs?: number;
|
|
159
212
|
}
|
|
213
|
+
export interface ResolvedWebSurfaceConfig {
|
|
214
|
+
browserName?: BrowserKind;
|
|
215
|
+
browserBinary?: string;
|
|
216
|
+
launchOptions: LaunchOptions;
|
|
217
|
+
}
|
|
218
|
+
export interface ResolvedMobileTargetConfig {
|
|
219
|
+
device?: string;
|
|
220
|
+
appId?: string;
|
|
221
|
+
appBinary?: string;
|
|
222
|
+
appActivity?: string;
|
|
223
|
+
}
|
|
224
|
+
export interface ResolvedDesktopTargetConfig {
|
|
225
|
+
appId?: string;
|
|
226
|
+
appBinary?: string;
|
|
227
|
+
appActivity?: string;
|
|
228
|
+
}
|
|
160
229
|
export interface ResolvedAllwrightConfig {
|
|
161
230
|
configFilePath: string | null;
|
|
162
231
|
suiteName: string | null;
|
|
163
232
|
serverAddr?: string;
|
|
164
|
-
browserName
|
|
233
|
+
browserName?: BrowserKind;
|
|
165
234
|
browserBinary?: string;
|
|
166
235
|
launchOptions: LaunchOptions;
|
|
167
236
|
expect: RetryConfig;
|
|
237
|
+
web?: ResolvedWebSurfaceConfig;
|
|
238
|
+
mobile: {
|
|
239
|
+
android?: ResolvedMobileTargetConfig;
|
|
240
|
+
ios?: ResolvedMobileTargetConfig;
|
|
241
|
+
};
|
|
242
|
+
desktop: {
|
|
243
|
+
mac?: ResolvedDesktopTargetConfig;
|
|
244
|
+
windows?: ResolvedDesktopTargetConfig;
|
|
245
|
+
linux?: ResolvedDesktopTargetConfig;
|
|
246
|
+
};
|
|
168
247
|
}
|
|
169
248
|
export interface ResolveConfigOptions {
|
|
170
249
|
cwd?: string;
|