codeceptjs 4.2.0 → 4.2.1-beta.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/README.md +2 -0
- package/bin/codecept.js +11 -0
- package/docs/agents.md +26 -1
- package/docs/ai.md +57 -0
- package/docs/alternative-browsers.md +175 -148
- package/docs/assertions.md +74 -0
- package/docs/bootstrap.md +2 -0
- package/docs/commands.md +45 -0
- package/docs/configuration.md +37 -0
- package/docs/debugging.md +1 -1
- package/docs/helpers/ApiDataFactory.md +20 -20
- package/docs/helpers/Appium.md +1615 -670
- package/docs/helpers/Decision.md +146 -0
- package/docs/helpers/GraphQL.md +31 -31
- package/docs/helpers/GraphQLDataFactory.md +20 -20
- package/docs/helpers/Kitesurf.md +1808 -25
- package/docs/helpers/Lightpanda.md +139 -0
- package/docs/helpers/Obscura.md +1799 -74
- package/docs/helpers/Playwright.md +490 -428
- package/docs/helpers/Puppeteer.md +317 -255
- package/docs/helpers/REST.md +43 -43
- package/docs/helpers/WebDriver.md +237 -175
- package/docs/installation.md +16 -0
- package/docs/mcp.md +7 -1
- package/docs/parallel.md +35 -1
- package/docs/plugins/pause.md +2 -1
- package/docs/plugins/sitemap.md +48 -0
- package/docs/plugins.md +4 -0
- package/lib/ai.js +81 -2
- package/lib/codecept.js +32 -2
- package/lib/command/init.js +22 -0
- package/lib/command/initAgent.js +78 -0
- package/lib/command/run-multiple.js +3 -0
- package/lib/command/run-workers.js +10 -3
- package/lib/command/run.js +3 -2
- package/lib/command/utils.js +15 -0
- package/lib/command/workers/runTests.js +10 -10
- package/lib/container.js +4 -2
- package/lib/effects.js +19 -1
- package/lib/helper/CDPBrowser.js +349 -1384
- package/lib/helper/Decision.js +256 -0
- package/lib/helper/Kitesurf.js +3 -21
- package/lib/helper/Lightpanda.js +137 -0
- package/lib/helper/Obscura.js +21 -238
- package/lib/helper/Playwright.js +6 -4
- package/lib/helper/Puppeteer.js +12 -7
- package/lib/helper/WebDriver.js +2 -1
- package/lib/listener/result.js +4 -0
- package/lib/mocha/bdd.js +19 -1
- package/lib/plugin/junitReporter.js +4 -1
- package/lib/plugin/pause.js +4 -1
- package/lib/plugin/sitemap.js +228 -0
- package/lib/recorder.js +19 -18
- package/lib/result.js +16 -0
- package/lib/step/base.js +12 -0
- package/lib/utils.js +2 -10
- package/lib/webServer.js +193 -0
- package/lib/workers.js +118 -31
- package/package.json +4 -2
- package/typings/index.d.ts +60 -7
- package/typings/promiseBasedTypes.d.ts +772 -824
- package/typings/types.d.ts +866 -833
- package/docs/helpers/CDPBrowser.md +0 -2138
|
@@ -1193,16 +1193,16 @@ declare namespace CodeceptJS {
|
|
|
1193
1193
|
*
|
|
1194
1194
|
* This helper should be configured in codecept.conf.js
|
|
1195
1195
|
* @property [url = http://localhost] - base url of website to be tested.
|
|
1196
|
-
* @property [endpoint = http://127.0.0.1:9222] - Chrome DevTools Protocol endpoint
|
|
1197
|
-
* @property [headers = {}] - headers sent
|
|
1198
|
-
* @property [input = auto] - how
|
|
1199
|
-
* @property [xpathPolyfill = auto] -
|
|
1200
|
-
* @property [capabilities = {}] -
|
|
1201
|
-
* @property [waitForTimeout = 5] - default wait*
|
|
1202
|
-
* @property [waitForAction
|
|
1203
|
-
* @property [pollInterval = 25] - interval
|
|
1204
|
-
* @property [getPageTimeout = 30] - maximum time
|
|
1205
|
-
* @property [waitForNavigation = load] - when
|
|
1196
|
+
* @property [endpoint = http://127.0.0.1:9222] - Chrome DevTools Protocol endpoint: an `http(s)://` address or a `ws(s)://` debugger URL.
|
|
1197
|
+
* @property [headers = {}] - headers sent when connecting to the endpoint, e.g. for authenticated remote browsers.
|
|
1198
|
+
* @property [input = auto] - how actions are dispatched: `cdp` (real mouse and keyboard events) or `synthetic` (DOM events). `auto` picks `cdp` when the browser renders layout.
|
|
1199
|
+
* @property [xpathPolyfill = auto] - inject an XPath polyfill for browsers with incomplete XPath support. `auto` detects when it is needed.
|
|
1200
|
+
* @property [capabilities = {}] - browser capabilities (`layout`, `xpath`, `screenshot`, `innerText`) to use instead of detecting them at runtime.
|
|
1201
|
+
* @property [waitForTimeout = 5] - default timeout for wait* actions, in seconds.
|
|
1202
|
+
* @property [waitForAction] - fixed delay after each action, in milliseconds. When unset, actions wait only for the navigation they trigger.
|
|
1203
|
+
* @property [pollInterval = 25] - interval between checks while waiting, in milliseconds.
|
|
1204
|
+
* @property [getPageTimeout = 30] - maximum time to wait for a page to load, in seconds.
|
|
1205
|
+
* @property [waitForNavigation = load] - when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
|
|
1206
1206
|
*/
|
|
1207
1207
|
type CDPBrowserConfig = {
|
|
1208
1208
|
url?: string;
|
|
@@ -1226,6 +1226,8 @@ declare namespace CodeceptJS {
|
|
|
1226
1226
|
* script evaluation, and simple in-page element interaction (installed lazily through the
|
|
1227
1227
|
* `window.__codecept` client script). It does not launch a browser itself — point `endpoint` at an
|
|
1228
1228
|
* already-running Chrome (or any CDP-compatible browser) started with `--remote-debugging-port`.
|
|
1229
|
+
* Subclasses for browsers shipped as a standalone binary opt into launching and reaping their own
|
|
1230
|
+
* server process through `_manageServer`.
|
|
1229
1231
|
*
|
|
1230
1232
|
* ## Example
|
|
1231
1233
|
*
|
|
@@ -1248,416 +1250,160 @@ declare namespace CodeceptJS {
|
|
|
1248
1250
|
class CDPBrowserTs {
|
|
1249
1251
|
constructor(config: CDPBrowserConfig);
|
|
1250
1252
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
+
* Opts a subclass into managing its own browser server process. Called from a subclass
|
|
1254
|
+
* constructor with the raw user config and a server descriptor:
|
|
1255
|
+
*
|
|
1256
|
+
* - `name` — binary name looked up on `PATH`, also used in messages
|
|
1257
|
+
* - `envVar` — environment variable that may point at the binary
|
|
1258
|
+
* - `args(port)` — arguments the binary is spawned with to serve CDP on `port`
|
|
1259
|
+
* - `env` — extra environment variables for the spawned process
|
|
1260
|
+
* - `releases` — URL shown when no binary can be resolved
|
|
1261
|
+
*
|
|
1262
|
+
* An explicit `endpoint` in the user config always wins: the helper stays in ATTACH mode and
|
|
1263
|
+
* never spawns or kills anything. Otherwise the helper becomes SELF-MANAGED and the default
|
|
1264
|
+
* `endpoint` is cleared until `_resolveSelfManaged` sets the real one.
|
|
1265
|
+
* @param config - the config object the helper was constructed with.
|
|
1266
|
+
* @param server - the server descriptor described above.
|
|
1253
1267
|
*/
|
|
1254
|
-
|
|
1268
|
+
protected _manageServer(config: any, server: any): Promise<any>;
|
|
1255
1269
|
/**
|
|
1256
|
-
* Resolves
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1270
|
+
* Resolves how to reach a SELF-MANAGED browser, trying, in order: spawn a binary
|
|
1271
|
+
* (`binaryPath` config, then the descriptor's `envVar`, then its `name` on `PATH`) on
|
|
1272
|
+
* `options.port` or a free port, courtesy-attach to `http://127.0.0.1:9222` if something already
|
|
1273
|
+
* answers there (never killed by this helper), or throw a loud, actionable error. Sets
|
|
1274
|
+
* `this.options.endpoint` as a side effect.
|
|
1260
1275
|
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1276
|
+
* A spawn failure (e.g. a bad binary) is delivered asynchronously by Node as an `error` event;
|
|
1277
|
+
* it is recorded on `this.serverError` and surfaced as a rejection from `_waitForServer` instead
|
|
1278
|
+
* of crashing the process as an uncaught exception.
|
|
1264
1279
|
*/
|
|
1265
|
-
protected
|
|
1280
|
+
protected _resolveSelfManaged(): Promise<any>;
|
|
1266
1281
|
/**
|
|
1267
|
-
* Resolves the
|
|
1282
|
+
* Resolves the binary to spawn, in priority order: `options.binaryPath`, then the server
|
|
1283
|
+
* descriptor's environment variable, then its name on `PATH`. The `PATH` lookup walks the
|
|
1284
|
+
* directories itself instead of shelling out to `which`, which does not exist on Windows: on
|
|
1285
|
+
* Windows every `PATHEXT` suffix is tried, so a `.exe` on `PATH` is found too.
|
|
1268
1286
|
*/
|
|
1269
|
-
protected
|
|
1270
|
-
/**
|
|
1271
|
-
* Hook executed before each test. Ensures a live `CDPConnection` exists (connecting lazily on
|
|
1272
|
-
* first use, and reconnecting if a previous connection was closed), then creates a fresh
|
|
1273
|
-
* `about:blank` target and attaches to it with `Target.attachToTarget`, storing `this.targetId`
|
|
1274
|
-
* and `this.sessionId`. `Page` and `Runtime` domains are enabled on the new session, and engine
|
|
1275
|
-
* capabilities are probed here (against `about:blank`, uncontended) rather than only lazily on
|
|
1276
|
-
* the first real page — see `_probeCapabilities`.
|
|
1277
|
-
*
|
|
1278
|
-
* Also resets `_navStartWaiters` and `_lastMainFrameNav`: both are scoped to a single
|
|
1279
|
-
* `sessionId`/`targetId`, which are about to change, so anything left over from the previous test
|
|
1280
|
-
* (e.g. an action-settle waiter still armed because its test threw between arming and settling)
|
|
1281
|
-
* can never legitimately resolve against the new session — better to drop it here than leave it
|
|
1282
|
-
* waiting for the rest of the run.
|
|
1283
|
-
*/
|
|
1284
|
-
protected _before(): Promise<any>;
|
|
1285
|
-
/**
|
|
1286
|
-
* Lazily installs a single, persistent `Page.lifecycleEvent` listener on the underlying
|
|
1287
|
-
* `CDPConnection` and drains it into whichever `_waitForLoadEvent` calls are currently pending,
|
|
1288
|
-
* matched by `loaderId`. Installed once per helper instance (the connection outlives individual
|
|
1289
|
-
* tests), never removed — `CDPConnection` has no listener-removal API, so a single persistent
|
|
1290
|
-
* dispatcher (rather than one listener per navigation) is what keeps this leak-free.
|
|
1291
|
-
*
|
|
1292
|
-
* Also, for the main frame (`params.frameId === this.targetId`, which holds for a page target's
|
|
1293
|
-
* own top-level frame) only:
|
|
1294
|
-
* - Drains `_navStartWaiters` (armed by `_armActionSettle`, before an action, for `_waitForAction`'s
|
|
1295
|
-
* event-aware settle) on an `'init'` event — confirmed via a raw probe (against both Obscura and
|
|
1296
|
-
* Chrome, through the actual CLI path) to be the earliest signal CDP emits when a new top-level
|
|
1297
|
-
* navigation begins. Arming happens *before* the action is dispatched, not after: the same probe
|
|
1298
|
-
* found `'init'` can arrive while the action's own CDP round trip is still in flight, sometimes
|
|
1299
|
-
* only a millisecond or two after it started — a listener installed only once the action's
|
|
1300
|
-
* promise resolves can already be too late, not merely unlucky.
|
|
1301
|
-
* - Maintains `_lastMainFrameNav`, a rolling `{loaderId, events}` record of every lifecycle event
|
|
1302
|
-
* name seen for the current main-frame navigation (reset whenever `loaderId` changes). On a
|
|
1303
|
-
* fast/local navigation, the same raw probe found the *entire* sequence — `init` through
|
|
1304
|
-
* `networkIdle` — arriving as one batch while the triggering action's own round trip was still
|
|
1305
|
-
* in flight. Without this cache, `_waitForAction` would correctly detect that a navigation
|
|
1306
|
-
* started, then arm a *fresh* wait for the `load` event specifically — which, in that common
|
|
1307
|
-
* case, had already fired and will never fire again, paying the full grace-window-plus-poll cost
|
|
1308
|
-
* of `_waitForPageLoad` on every single navigating action instead of settling immediately.
|
|
1309
|
-
*/
|
|
1310
|
-
protected _ensureLifecycleListener(): Promise<any>;
|
|
1311
|
-
/**
|
|
1312
|
-
* Starts waiting for a `Page.lifecycleEvent` named `eventName` for the given `loaderId` on the
|
|
1313
|
-
* current session. `loaderId` (from the `Page.navigate` response) discriminates the awaited
|
|
1314
|
-
* navigation from any other in-flight or stale lifecycle events (e.g. the `about:blank` target
|
|
1315
|
-
* created in `_before`), which is essential since Chrome emits the target's initial `about:blank`
|
|
1316
|
-
* lifecycle sequence asynchronously, sometimes after this listener is already installed.
|
|
1317
|
-
*
|
|
1318
|
-
* Returns a `{promise, cancel}` pair rather than a bare promise: `_waitForPageLoad` races this
|
|
1319
|
-
* against a readyState poll, and whichever side loses must be actively torn down (not just have
|
|
1320
|
-
* its rejection swallowed) — an abandoned-but-still-pending wait would sit in `_pageLoadWaiters`
|
|
1321
|
-
* for the full timeout on every single navigation, for no purpose.
|
|
1322
|
-
* @param loaderId - the loader id of the navigation to wait for, from `Page.navigate`'s response.
|
|
1323
|
-
* @param eventName - the `Page.lifecycleEvent` name to wait for (e.g. `load`, `DOMContentLoaded`, `networkIdle`).
|
|
1324
|
-
* @param timeoutSec - maximum time to wait, in seconds.
|
|
1325
|
-
*/
|
|
1326
|
-
protected _waitForLoadEvent(loaderId: string, eventName: string, timeoutSec: number): Promise<any>;
|
|
1327
|
-
/**
|
|
1328
|
-
* Arms the event-aware settle's navigation-start listener. Must be called *before* the action
|
|
1329
|
-
* that might trigger a navigation is dispatched, not after — see `_ensureLifecycleListener` for
|
|
1330
|
-
* why. Returns `null` when `options.waitForAction` was set explicitly, since `_waitForAction`
|
|
1331
|
-
* ignores the armed listener entirely in that case (a literal fixed sleep, as before this round).
|
|
1332
|
-
*
|
|
1333
|
-
* No timeout here: `_waitForAction` applies the grace window itself, starting from when *it*
|
|
1334
|
-
* runs (after the action's own dispatch already resolved), racing this already-armed listener
|
|
1335
|
-
* against a fresh timer instead of one that started ticking before the action even began.
|
|
1336
|
-
*/
|
|
1337
|
-
protected _armActionSettle(): Promise<any>;
|
|
1338
|
-
/**
|
|
1339
|
-
* Waits for a page to finish loading after `Page.navigate`/`Page.reload`, per `options.waitForNavigation`.
|
|
1340
|
-
*
|
|
1341
|
-
* Purely event-driven for the first `PAGE_LOAD_GRACE_MS`: only the push-based
|
|
1342
|
-
* `Page.lifecycleEvent` signal (matched by `loaderId`) is awaited, issuing zero `_evaluate` calls
|
|
1343
|
-
* — this matters because an `_evaluate` sent while the page's own JavaScript is still busy (e.g.
|
|
1344
|
-
* a real-world page doing post-load hydration/analytics work) can queue behind it for hundreds of
|
|
1345
|
-
* ms to multiple seconds, measured directly against a JS-heavy page. Only if the grace window
|
|
1346
|
-
* elapses without the event (an engine that doesn't emit it, or a genuinely slow navigation) does
|
|
1347
|
-
* the `document.readyState` poll (via `_poll`) start, racing the still-pending lifecycle wait —
|
|
1348
|
-
* both bounded by the same `options.getPageTimeout`, so a lifecycle-less engine costs at most
|
|
1349
|
-
* `PAGE_LOAD_GRACE_MS` more than the poll alone would have, never double the timeout. No
|
|
1350
|
-
* `loaderId` (e.g. from `Page.reload`, which returns none) skips straight to the poll.
|
|
1351
|
-
*
|
|
1352
|
-
* Whichever side ultimately loses is actively cancelled, not merely abandoned — an abandoned poll
|
|
1353
|
-
* or lifecycle wait would otherwise keep running (issuing readyState `_evaluate` calls every
|
|
1354
|
-
* `pollInterval`, or holding a `_pageLoadWaiters` entry) for up to the full timeout on every
|
|
1355
|
-
* navigation, competing for the same CDP connection with real work.
|
|
1356
|
-
* @param loaderId - loader id from the triggering `Page.navigate` response, if any.
|
|
1357
|
-
* @param timeoutMessage - error message used if the readyState poll times out.
|
|
1358
|
-
*/
|
|
1359
|
-
protected _waitForPageLoad(loaderId: string | null, timeoutMessage: string): Promise<void>;
|
|
1360
|
-
/**
|
|
1361
|
-
* Hook executed after each test. Closes the target opened in `_before` via `Target.closeTarget`
|
|
1362
|
-
* and clears `this.targetId`/`this.sessionId`. The underlying `CDPConnection` is left open so it
|
|
1363
|
-
* can be reused by the next test.
|
|
1364
|
-
*/
|
|
1365
|
-
protected _after(): Promise<any>;
|
|
1287
|
+
protected _resolveBinary(): Promise<any>;
|
|
1366
1288
|
/**
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1289
|
+
* Picks a free TCP port on 127.0.0.1 by briefly listening on port 0 and reading back the
|
|
1290
|
+
* OS-assigned port. Used when `options.port` isn't explicitly set, so multiple `run-workers`
|
|
1291
|
+
* workers never collide on the same port.
|
|
1292
|
+
* @returns a free port.
|
|
1370
1293
|
*/
|
|
1371
|
-
protected
|
|
1294
|
+
protected _findFreePort(): Promise<number>;
|
|
1372
1295
|
/**
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
* (`returnByValue: true`). If the expression throws, the browser-side exception description
|
|
1376
|
-
* (or fallback text) is re-thrown as a JS `Error`.
|
|
1377
|
-
* @param expression - a JavaScript expression (or IIFE) to run in the page context.
|
|
1378
|
-
* @returns the evaluated value, or `undefined` if the expression has no result.
|
|
1379
|
-
*/
|
|
1380
|
-
protected _evaluate(expression: string): Promise<any>;
|
|
1381
|
-
/**
|
|
1382
|
-
* Ensures the in-page client (`window.__codecept`, installed from `cdpBrowserClient.js`) is
|
|
1383
|
-
* present on the current page, installing it (and the XPath polyfill, if needed) exactly once.
|
|
1384
|
-
* Safe to call repeatedly; it is a no-op once the client is detected.
|
|
1385
|
-
*/
|
|
1386
|
-
protected _ensureClient(): Promise<any>;
|
|
1387
|
-
/**
|
|
1388
|
-
* Installs the in-page client unconditionally — no `typeof window.__codecept` presence check.
|
|
1389
|
-
* Used by callers that already know, from a sentinel value returned alongside a failed action,
|
|
1390
|
-
* that the client is missing on the current page, so re-checking would just be a redundant
|
|
1391
|
-
* contended round trip.
|
|
1392
|
-
*
|
|
1393
|
-
* The 171KB XPath polyfill is only injected alongside the client when `needsXPath` is true (the
|
|
1394
|
-
* default, for callers without candidate information) *and* the engine actually needs it
|
|
1395
|
-
* (`capabilities.xpath === 'polyfill'`, cached from `_before`'s probe). Callers that know their
|
|
1396
|
-
* candidates never resolve to an `xpath` strategy (e.g. `_runSelected`, once it has inspected
|
|
1397
|
-
* `candidates`/`within`) can pass `false` to skip that inject — the client is still told, via the
|
|
1398
|
-
* `xpathNeedsPolyfill` flag baked in at install time, that the *engine* will eventually need it,
|
|
1399
|
-
* so a later call that does hit an xpath candidate gets a clean `'__NO_XPATH__'` miss signal
|
|
1400
|
-
* (from `window.__codecept.run`) instead of silently falling through to a broken native
|
|
1401
|
-
* `document.evaluate` — `_runSelected` reacts to that sentinel by injecting the polyfill and
|
|
1402
|
-
* retrying once, mirroring the `'__NO_CLIENT__'` handling right next to it.
|
|
1403
|
-
*/
|
|
1404
|
-
protected _installClient(needsXPath?: boolean): Promise<any>;
|
|
1405
|
-
/**
|
|
1406
|
-
* Whether any candidate strategy — in `candidates` itself, or in any of the `within` scoping
|
|
1407
|
-
* `layers` searched before it — is an `xpath` locator. Used to decide, before the client is even
|
|
1408
|
-
* installed, whether the XPath polyfill needs to be bundled into that install or can be deferred.
|
|
1409
|
-
*/
|
|
1410
|
-
protected _candidatesNeedXPath(candidates: { type: string; value: string; }[], layers: { type: string; value: string; }[][]): Promise<any>;
|
|
1411
|
-
/**
|
|
1412
|
-
* Determines whether the bundled XPath polyfill must be injected before the in-page client is
|
|
1413
|
-
* installed. Honors an explicit `options.xpathPolyfill` boolean; otherwise reuses a previously
|
|
1414
|
-
* probed `capabilities.xpath`, or probes the page's native `document.evaluate`. The probe appends
|
|
1415
|
-
* two throwaway elements distinguished only by text content and asserts that a text-value XPath
|
|
1416
|
-
* predicate (`normalize-space(string(.))=...`, the basis of every fuzzy/clickable locator) resolves
|
|
1417
|
-
* to exactly the matching one — merely checking that `document.evaluate` runs without throwing is
|
|
1418
|
-
* not enough, since some engines execute a text-value predicate without actually filtering by it,
|
|
1419
|
-
* silently returning every candidate node instead of none or one. The result is cached on
|
|
1420
|
-
* `capabilities.xpath` (`'native'` or `'polyfill'`).
|
|
1421
|
-
* @returns `true` if the polyfill should be injected.
|
|
1422
|
-
*/
|
|
1423
|
-
protected _needsXPathPolyfill(): Promise<boolean>;
|
|
1424
|
-
/**
|
|
1425
|
-
* Determines whether `see`/`dontSee`/`waitForText` should read whole-page text through the
|
|
1426
|
-
* client's own visibility-aware `visibleText()` walker instead of the native
|
|
1427
|
-
* `document.body.innerText`. Probes once per page by appending a `display:none` element and a
|
|
1428
|
-
* `<script>` element, each with distinguishing text, and checking that native `innerText`
|
|
1429
|
-
* excludes both — some engines return an `innerText` that does not honor computed visibility or
|
|
1430
|
-
* exclude script/style content, even when `getComputedStyle`/layout are otherwise reliable. The
|
|
1431
|
-
* result is cached on `capabilities.innerText` (`'native'` or `'computed'`).
|
|
1432
|
-
* @returns `true` if the `visibleText()` fallback should be used.
|
|
1433
|
-
*/
|
|
1434
|
-
protected _needsVisibleTextFallback(): Promise<boolean>;
|
|
1435
|
-
/**
|
|
1436
|
-
* Probes and caches capabilities that depend on the actual browser *engine* rather than any
|
|
1437
|
-
* particular page's content: `capabilities.layout` (via `getComputedStyle`), `capabilities.screenshot`
|
|
1438
|
-
* (inferred from `layout`), `capabilities.xpath` (via `_needsXPathPolyfill`), and
|
|
1439
|
-
* `capabilities.innerText` (via `_needsVisibleTextFallback`). Already-known capabilities
|
|
1440
|
-
* (pre-seeded through `options.capabilities`, or probed earlier) are never re-probed — so, across
|
|
1441
|
-
* a whole run, this issues a handful of `_evaluate` calls exactly once and is a no-op afterward.
|
|
1442
|
-
*
|
|
1443
|
-
* Called from `_before`, against the fresh `about:blank` target created there, specifically so
|
|
1444
|
-
* these probes run before any real navigation — measured directly (a full stall ledger against
|
|
1445
|
-
* `github.com`) that running them on the first *real* page instead can cost seconds each, since
|
|
1446
|
-
* every one is an `_evaluate` competing with that page's own JavaScript for the V8 isolate.
|
|
1447
|
-
* `about:blank` has no such competition. Also called (cheaply, already cached by then) from
|
|
1448
|
-
* `amOnPage`, so a helper that skips `_before` for some reason still probes correctly.
|
|
1449
|
-
*
|
|
1450
|
-
* The `xpath`/`innerText` probes determine *whether* their respective fallback is needed; they
|
|
1451
|
-
* do not install anything — injection stays deferred to `_ensureClient`'s reactive install and
|
|
1452
|
-
* `_textSource`'s own read, matching `amOnPage` no longer eagerly installing the client.
|
|
1453
|
-
*/
|
|
1454
|
-
protected _probeCapabilities(): Promise<any>;
|
|
1455
|
-
/**
|
|
1456
|
-
* Delegates a find-and-act call to `window.__codecept.run(candidates, action, payload)`. This is
|
|
1457
|
-
* the primary extension point used by helpers built on top of this class for element queries and
|
|
1458
|
-
* interactions.
|
|
1459
|
-
*
|
|
1460
|
-
* A per-call `context` locator, when given, is resolved and layered on top of any active
|
|
1461
|
-
* `within` block (searched inside it, not instead of it), so `context` narrows the search
|
|
1462
|
-
* without breaking out of a surrounding `within`.
|
|
1463
|
-
* @param candidates - locator strategies to try, in order, until one matches at least one element.
|
|
1464
|
-
* @param action - name of the action to run against the matched elements (e.g. `count`, `click`, `fill`).
|
|
1465
|
-
* @param [payload] - extra data the action needs (e.g. `{ value }` for `fill`).
|
|
1466
|
-
* @param [context = null] - element to search in, narrowing the candidates below it.
|
|
1467
|
-
* @returns number of matched elements and the action's result.
|
|
1468
|
-
*/
|
|
1469
|
-
protected _run(candidates: { type: 'css' | 'xpath'; value: string; }[], action: string, payload?: any, context?: CodeceptJS.LocatorOrString): Promise<{ found: number; result: any; }>;
|
|
1470
|
-
/**
|
|
1471
|
-
* Same as `_run`, but takes an explicit selection descriptor instead of reading one from
|
|
1472
|
-
* `store.currentStep`/`options.strict`. Used internally by `CDPElementHandle` to address one
|
|
1473
|
-
* specific element out of a candidate set by its 1-based index.
|
|
1474
|
-
*
|
|
1475
|
-
* The in-page client's presence is checked in the same round-trip as the action itself: the
|
|
1476
|
-
* evaluated expression resolves to a sentinel string when `window.__codecept` is missing (e.g.
|
|
1477
|
-
* right after a navigation the registered script didn't reach), in which case the client is
|
|
1478
|
-
* installed and the call is retried exactly once. Separately, if the client is already present
|
|
1479
|
-
* but reports (via its own `'__NO_XPATH__'` sentinel) that this call needs the XPath polyfill and
|
|
1480
|
-
* it was not bundled into that earlier install, the polyfill is injected and the call is retried
|
|
1481
|
-
* once more — see `_installClient`.
|
|
1482
|
-
* @param selection - `{index}` or `{strict: true}`, mirroring `_selectionDescriptor`.
|
|
1483
|
-
*/
|
|
1484
|
-
protected _runSelected(candidates: { type: 'css' | 'xpath'; value: string; }[], action: string, payload: any | null, selection: any | null, context?: CodeceptJS.LocatorOrString): Promise<{ found: number; result: any; }>;
|
|
1485
|
-
/**
|
|
1486
|
-
* Builds the `{index, strict}` element-selection descriptor from the current step's options
|
|
1487
|
-
* (`store.currentStep.opts`) and `options.strict`, mirroring the semantics of
|
|
1488
|
-
* `lib/helper/extras/elementSelection.js` (used by Puppeteer/WebDriver): a per-step
|
|
1489
|
-
* `elementIndex` (numeric, or the `'first'`/`'last'` aliases) always takes precedence and
|
|
1490
|
-
* disables strict mode for that step; otherwise `exact`/`strictMode` per-step options
|
|
1491
|
-
* override `options.strict` to enable or cancel strict mode.
|
|
1492
|
-
*/
|
|
1493
|
-
protected _selectionDescriptor(): Promise<any>;
|
|
1494
|
-
/**
|
|
1495
|
-
* A short, human-readable label built from `candidates`, used in `_run`'s elementIndex/strict
|
|
1496
|
-
* error messages when no locator string is otherwise available.
|
|
1497
|
-
*/
|
|
1498
|
-
protected _candidatesLabel(candidates: { type: 'css' | 'xpath'; value: string; }[]): Promise<any>;
|
|
1499
|
-
/**
|
|
1500
|
-
* Starts a `within` block, scoping every subsequent `_run` call (and therefore every element
|
|
1501
|
-
* lookup performed by this helper) to the descendants of the element matched by `locator`.
|
|
1502
|
-
* Verifies the element exists (against the full document, i.e. unscoped) before narrowing.
|
|
1503
|
-
* @param locator - element located by CSS|XPath|strict locator.
|
|
1296
|
+
* Probes a `/json/version`-style URL with a short timeout, used for the courtesy-attach check.
|
|
1297
|
+
* @returns true if the URL answered.
|
|
1504
1298
|
*/
|
|
1505
|
-
|
|
1299
|
+
protected _probeUp(url: string): Promise<boolean>;
|
|
1506
1300
|
/**
|
|
1507
|
-
*
|
|
1301
|
+
* Polls `http://127.0.0.1:<port>/json/version` until the spawned server responds,
|
|
1302
|
+
* `this.serverError` is set by the process' `error` event, or `options.serverStartTimeout`
|
|
1303
|
+
* elapses. The process typically comes up within tens of milliseconds — a 20ms retry interval
|
|
1304
|
+
* keeps the wasted tail after the server is actually ready small, since this cost is paid once
|
|
1305
|
+
* per run and counts directly toward real-world startup latency.
|
|
1508
1306
|
*/
|
|
1509
|
-
|
|
1307
|
+
protected _waitForServer(): Promise<any>;
|
|
1510
1308
|
/**
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1514
|
-
* @param timeoutSec - maximum time to poll, in seconds.
|
|
1515
|
-
* @param message - error message used when the timeout is reached.
|
|
1516
|
-
* @param [cancelToken] - when `cancelled` becomes `true` (set by the caller from outside), polling stops early with an error instead of continuing to `timeoutSec`. Used by `_waitForPageLoad` to tear down the losing side of a race instead of leaving it running.
|
|
1517
|
-
* @returns the truthy value returned by `fn`.
|
|
1309
|
+
* In SELF-MANAGED mode, resolves and spawns the browser server (or courtesy-attaches to an
|
|
1310
|
+
* already-running one on :9222) exactly once via `_resolveSelfManaged`. Then resolves the CDP
|
|
1311
|
+
* endpoint and opens the underlying `CDPConnection`, storing it on `this.cdp`.
|
|
1518
1312
|
*/
|
|
1519
|
-
protected
|
|
1313
|
+
protected _connect(): Promise<any>;
|
|
1520
1314
|
/**
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1523
|
-
*
|
|
1315
|
+
* Hook executed after all tests are run. Closes the underlying `CDPConnection` (and its
|
|
1316
|
+
* WebSocket) and clears `this.cdp`, then kills the server process spawned by
|
|
1317
|
+
* `_resolveSelfManaged`, if any (`this.serverProcess` is never set when attaching). Must leave no
|
|
1318
|
+
* open sockets, pending timers or child processes behind, so the process can exit on its own.
|
|
1319
|
+
*
|
|
1320
|
+
* The kill runs in a `finally` so the process is always reaped even if closing the CDP
|
|
1321
|
+
* connection throws. It sends `SIGTERM` first and waits for the process to exit; a process that
|
|
1322
|
+
* ignores `SIGTERM` is escalated to `SIGKILL` after 5s. The promise only resolves once the child
|
|
1323
|
+
* has actually exited (confirmed via the `exit` event, not merely once `SIGKILL` was sent — the
|
|
1324
|
+
* kernel needs a moment to reap it), with a final safety-net timeout so a stuck child can never
|
|
1325
|
+
* keep the event loop alive even if that confirmation is somehow lost.
|
|
1524
1326
|
*/
|
|
1525
|
-
protected
|
|
1327
|
+
protected _finishTest(): Promise<any>;
|
|
1526
1328
|
/**
|
|
1527
|
-
* Opens a web page in
|
|
1329
|
+
* Opens a web page in a browser. Requires relative or absolute url.
|
|
1330
|
+
* If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
1528
1331
|
*
|
|
1529
1332
|
* ```js
|
|
1530
1333
|
* I.amOnPage('/'); // opens main page of website
|
|
1531
1334
|
* I.amOnPage('https://github.com'); // opens github
|
|
1532
1335
|
* I.amOnPage('/login'); // opens a login page
|
|
1533
1336
|
* ```
|
|
1534
|
-
*
|
|
1535
|
-
* Navigates via `Page.navigate`, then waits (up to `options.getPageTimeout` seconds) for the page
|
|
1536
|
-
* to finish loading, preferring the push-based `Page.lifecycleEvent` signal (per
|
|
1537
|
-
* `options.waitForNavigation`) over polling `document.readyState`. Capabilities are (re-)probed
|
|
1538
|
-
* (a no-op after the first page, since they're cached for the helper's lifetime).
|
|
1539
|
-
*
|
|
1540
|
-
* The in-page client is deliberately *not* eagerly (re-)installed here — navigation discards any
|
|
1541
|
-
* previously injected script, but installing it is deferred to the first actual action after
|
|
1542
|
-
* this call, via `_runSelected`'s sentinel-and-retry. This keeps `amOnPage` itself down to the
|
|
1543
|
-
* navigate command plus the push-based wait: no `_evaluate` call is issued on this hot path,
|
|
1544
|
-
* which matters most right when the page's own JavaScript may still be busy (measured directly:
|
|
1545
|
-
* an `_evaluate` sent in that window can queue behind it for hundreds of ms to multiple seconds
|
|
1546
|
-
* on a JS-heavy real-world page, regardless of how small the evaluated expression is).
|
|
1547
1337
|
* @param url - url path or global url.
|
|
1548
1338
|
*/
|
|
1549
|
-
amOnPage(url: string): Promise<
|
|
1339
|
+
amOnPage(url: string): Promise<any>;
|
|
1550
1340
|
/**
|
|
1551
|
-
*
|
|
1341
|
+
* Reload the current page.
|
|
1552
1342
|
*
|
|
1553
1343
|
* ```js
|
|
1554
1344
|
* I.refreshPage();
|
|
1555
1345
|
* ```
|
|
1556
|
-
*
|
|
1557
|
-
* Triggers `Page.reload` and waits (up to `options.getPageTimeout` seconds) for
|
|
1558
|
-
* `document.readyState` to reach `'complete'`.
|
|
1559
1346
|
*/
|
|
1560
|
-
refreshPage(): Promise<
|
|
1347
|
+
refreshPage(): Promise<any>;
|
|
1561
1348
|
/**
|
|
1562
|
-
* Executes
|
|
1349
|
+
* Executes sync script on a page.
|
|
1350
|
+
* Pass arguments to function as additional parameters.
|
|
1351
|
+
* Will return execution result to a test.
|
|
1352
|
+
* In this case you should use async function and await to receive results.
|
|
1563
1353
|
*
|
|
1564
|
-
*
|
|
1565
|
-
* not reference variables from the outer (Node.js) scope — pass any needed data as arguments
|
|
1566
|
-
* instead. A string is evaluated as-is.
|
|
1354
|
+
* Example with jQuery DatePicker:
|
|
1567
1355
|
*
|
|
1568
1356
|
* ```js
|
|
1569
|
-
*
|
|
1570
|
-
*
|
|
1357
|
+
* // change date of jQuery DatePicker
|
|
1358
|
+
* I.executeScript(function() {
|
|
1359
|
+
* // now we are inside browser context
|
|
1360
|
+
* $('date').datetimepicker('setDate', new Date());
|
|
1361
|
+
* });
|
|
1571
1362
|
* ```
|
|
1363
|
+
* Can return values. Don't forget to use `await` to get them.
|
|
1572
1364
|
*
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1365
|
+
* ```js
|
|
1366
|
+
* let date = await I.executeScript(function(el) {
|
|
1367
|
+
* // only basic types can be returned
|
|
1368
|
+
* return $(el).datetimepicker('getDate').toString();
|
|
1369
|
+
* }, '#date'); // passing jquery selector
|
|
1370
|
+
* ```
|
|
1371
|
+
* @param fn - function to be executed in browser context.
|
|
1372
|
+
* @param args - to be passed to function.
|
|
1373
|
+
* @returns script return value
|
|
1577
1374
|
*/
|
|
1578
1375
|
executeScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
|
|
1579
1376
|
/**
|
|
1580
|
-
*
|
|
1377
|
+
* Get current URL from browser.
|
|
1378
|
+
* Resumes test execution, so should be used inside an async function.
|
|
1581
1379
|
*
|
|
1582
1380
|
* ```js
|
|
1583
1381
|
* let url = await I.grabCurrentUrl();
|
|
1584
1382
|
* console.log(`Current URL is [${url}]`);
|
|
1585
1383
|
* ```
|
|
1586
|
-
* @returns current URL
|
|
1384
|
+
* @returns current URL
|
|
1587
1385
|
*/
|
|
1588
1386
|
grabCurrentUrl(): Promise<string>;
|
|
1589
1387
|
/**
|
|
1590
|
-
* Retrieves a page title.
|
|
1388
|
+
* Retrieves a page title and returns it to test.
|
|
1389
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1591
1390
|
*
|
|
1592
1391
|
* ```js
|
|
1593
1392
|
* let title = await I.grabTitle();
|
|
1594
1393
|
* ```
|
|
1595
|
-
* @returns title
|
|
1394
|
+
* @returns title
|
|
1596
1395
|
*/
|
|
1597
1396
|
grabTitle(): Promise<string>;
|
|
1598
1397
|
/**
|
|
1599
|
-
* Retrieves
|
|
1398
|
+
* Retrieves page source and returns it to test.
|
|
1399
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1600
1400
|
*
|
|
1601
1401
|
* ```js
|
|
1602
1402
|
* let pageSource = await I.grabSource();
|
|
1603
1403
|
* ```
|
|
1604
|
-
* @returns source code
|
|
1404
|
+
* @returns source code
|
|
1605
1405
|
*/
|
|
1606
1406
|
grabSource(): Promise<string>;
|
|
1607
|
-
/**
|
|
1608
|
-
* Builds the list of `{type, value}` candidates `_run` should try, in order, for a given
|
|
1609
|
-
* locator and `kind`. A strict locator (CSS/XPath/object form) resolves to a single candidate.
|
|
1610
|
-
* A fuzzy (plain-text) locator is expanded into a strategy-specific list of XPath expressions
|
|
1611
|
-
* mirroring the click/field/checkbox matching used by other browser helpers (matching by
|
|
1612
|
-
* visible text, label, name, placeholder, ARIA attributes, etc.), falling back to treating the
|
|
1613
|
-
* raw text as a CSS selector.
|
|
1614
|
-
*
|
|
1615
|
-
* A role locator (`{role, text, exact}`) resolves to a single `role`-type candidate, resolved
|
|
1616
|
-
* in-page by the client's implicit ARIA role mapping (native elements) plus explicit `role`
|
|
1617
|
-
* attributes, filtered by accessible name/text when `text` is given.
|
|
1618
|
-
* @param locator - element located by CSS|XPath|strict locator, or plain fuzzy text.
|
|
1619
|
-
* @param [kind = 'element'] - matching strategy to use when `locator` is fuzzy.
|
|
1620
|
-
*/
|
|
1621
|
-
protected _candidates(locator: CodeceptJS.LocatorOrString, kind?: 'element' | 'clickable' | 'field' | 'checkable'): Promise<any>;
|
|
1622
|
-
/**
|
|
1623
|
-
* Resolves the text to search `see`/`dontSee`/`waitForText` against, when no explicit `context`
|
|
1624
|
-
* locator is given. An explicit `context` is always resolved through `_run`, so it is implicitly
|
|
1625
|
-
* scoped to the active `within` block, if any. Without a `context`, this reads the `within` root's
|
|
1626
|
-
* text when a `within` block is active, or the whole page's text otherwise — via native
|
|
1627
|
-
* `document.body.innerText`, or the client's `visibleText()` walker when
|
|
1628
|
-
* `_needsVisibleTextFallback` determines native `innerText` is not trustworthy.
|
|
1629
|
-
*/
|
|
1630
|
-
protected _textSource(context: CodeceptJS.LocatorOrString): Promise<string>;
|
|
1631
|
-
/**
|
|
1632
|
-
* Runs the in-page `containsText` check against the whole page (no `context`/`within` scoping —
|
|
1633
|
-
* those stay on `_textSource`'s per-element path, already small). Returns only `{found, snippet}`
|
|
1634
|
-
* instead of the full haystack: on a page with a large body, serializing that whole string across
|
|
1635
|
-
* the CDP wire (and, on engines where `capabilities.innerText` requires the `visibleText()`
|
|
1636
|
-
* walker, holding it in memory) is avoidable work `see`/`dontSee`/`waitForText` don't actually
|
|
1637
|
-
* need on their common, non-throwing path.
|
|
1638
|
-
*
|
|
1639
|
-
* Also folds the client's install into the very same round trip when it is still missing, instead
|
|
1640
|
-
* of a separate presence-check evaluate followed by an install evaluate before the check itself
|
|
1641
|
-
* can even run — mirroring `_runSelected`'s sentinel-retry design, but collapsed into one evaluate
|
|
1642
|
-
* since the install source itself is known and cacheable up front. That install is client-only,
|
|
1643
|
-
* never the 171KB XPath polyfill: `containsText` never calls `document.evaluate`, so bundling it
|
|
1644
|
-
* here would be pure waste for a scenario that never resolves an xpath locator. The client is
|
|
1645
|
-
* still told, via `installCodeceptClient`'s `xpathNeedsPolyfill` flag, whether the *engine*
|
|
1646
|
-
* (`capabilities.xpath`, cached by `_before`'s `about:blank` probe) will eventually need it, so a
|
|
1647
|
-
* later xpath-resolving action on the same page gets a clean `'__NO_XPATH__'` miss signal from
|
|
1648
|
-
* `window.__codecept.run` instead of silently hitting a broken native `document.evaluate` —
|
|
1649
|
-
* `_runSelected` reacts to that sentinel already. The bootstrap source is built once and reused
|
|
1650
|
-
* for the life of the instance, since whether the engine needs the polyfill never changes.
|
|
1651
|
-
*/
|
|
1652
|
-
protected _runTextCheck(text: string, opts: any): Promise<{ found: boolean; snippet: string | null; }>;
|
|
1653
|
-
/**
|
|
1654
|
-
* Shared implementation for `see`/`dontSee`. Without a `context` locator and outside any `within`
|
|
1655
|
-
* block, checks presence via `_runTextCheck`'s fast, boolean-only round trip; the full haystack is
|
|
1656
|
-
* only fetched (one extra, rare evaluate) when the assertion is about to fail, to build the same
|
|
1657
|
-
* `stringIncludes` error as before this optimization. With a `context` or inside `within`, this is
|
|
1658
|
-
* unchanged from before — already a small, per-element read, not the identified cost.
|
|
1659
|
-
*/
|
|
1660
|
-
protected _checkText(text: string, context: CodeceptJS.LocatorOrString, negate: boolean): Promise<void>;
|
|
1661
1407
|
/**
|
|
1662
1408
|
* Checks that a page contains a visible text.
|
|
1663
1409
|
* Use context parameter to narrow down the search.
|
|
@@ -1670,7 +1416,7 @@ declare namespace CodeceptJS {
|
|
|
1670
1416
|
* @param text - expected on page.
|
|
1671
1417
|
* @param [context = null] - (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1672
1418
|
*/
|
|
1673
|
-
see(text: string, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1419
|
+
see(text: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1674
1420
|
/**
|
|
1675
1421
|
* Opposite to `see`. Checks that a text is not present on a page.
|
|
1676
1422
|
* Use context parameter to narrow down the search.
|
|
@@ -1680,9 +1426,9 @@ declare namespace CodeceptJS {
|
|
|
1680
1426
|
* I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
1681
1427
|
* ```
|
|
1682
1428
|
* @param text - which is not present.
|
|
1683
|
-
* @param [context = null] - (optional) element located by CSS|XPath|strict locator in which to
|
|
1429
|
+
* @param [context = null] - (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
1684
1430
|
*/
|
|
1685
|
-
dontSee(text: string, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1431
|
+
dontSee(text: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1686
1432
|
/**
|
|
1687
1433
|
* Checks that the current page contains the given string in its raw source code.
|
|
1688
1434
|
*
|
|
@@ -1691,12 +1437,16 @@ declare namespace CodeceptJS {
|
|
|
1691
1437
|
* ```
|
|
1692
1438
|
* @param text - value to check.
|
|
1693
1439
|
*/
|
|
1694
|
-
seeInSource(text: string): Promise<
|
|
1440
|
+
seeInSource(text: string): Promise<any>;
|
|
1695
1441
|
/**
|
|
1696
|
-
* Checks that the current page does not
|
|
1697
|
-
*
|
|
1442
|
+
* Checks that the current page does not contains the given string in its raw source code.
|
|
1443
|
+
*
|
|
1444
|
+
* ```js
|
|
1445
|
+
* I.dontSeeInSource('<!--'); // no comments in source
|
|
1446
|
+
* ```
|
|
1447
|
+
* @param value - to check.
|
|
1698
1448
|
*/
|
|
1699
|
-
dontSeeInSource(
|
|
1449
|
+
dontSeeInSource(value: string): Promise<any>;
|
|
1700
1450
|
/**
|
|
1701
1451
|
* Checks that current url contains a provided fragment.
|
|
1702
1452
|
*
|
|
@@ -1705,12 +1455,12 @@ declare namespace CodeceptJS {
|
|
|
1705
1455
|
* ```
|
|
1706
1456
|
* @param url - a fragment to check
|
|
1707
1457
|
*/
|
|
1708
|
-
seeInCurrentUrl(url: string): Promise<
|
|
1458
|
+
seeInCurrentUrl(url: string): Promise<any>;
|
|
1709
1459
|
/**
|
|
1710
1460
|
* Checks that current url does not contain a provided fragment.
|
|
1711
1461
|
* @param url - value to check.
|
|
1712
1462
|
*/
|
|
1713
|
-
dontSeeInCurrentUrl(url: string): Promise<
|
|
1463
|
+
dontSeeInCurrentUrl(url: string): Promise<any>;
|
|
1714
1464
|
/**
|
|
1715
1465
|
* Checks that title contains text.
|
|
1716
1466
|
*
|
|
@@ -1719,9 +1469,9 @@ declare namespace CodeceptJS {
|
|
|
1719
1469
|
* ```
|
|
1720
1470
|
* @param text - text value to check.
|
|
1721
1471
|
*/
|
|
1722
|
-
seeInTitle(text: string): Promise<
|
|
1472
|
+
seeInTitle(text: string): Promise<any>;
|
|
1723
1473
|
/**
|
|
1724
|
-
* Checks that a given Element is present in the DOM
|
|
1474
|
+
* Checks that a given Element is present in the DOM
|
|
1725
1475
|
* Element is located by CSS or XPath.
|
|
1726
1476
|
*
|
|
1727
1477
|
* ```js
|
|
@@ -1729,43 +1479,47 @@ declare namespace CodeceptJS {
|
|
|
1729
1479
|
* ```
|
|
1730
1480
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1731
1481
|
*/
|
|
1732
|
-
seeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<
|
|
1482
|
+
seeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1733
1483
|
/**
|
|
1734
1484
|
* Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
1735
1485
|
*
|
|
1736
1486
|
* ```js
|
|
1737
1487
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1738
1488
|
* ```
|
|
1739
|
-
* @param locator - located by CSS|XPath|
|
|
1740
|
-
*/
|
|
1741
|
-
dontSeeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<void>;
|
|
1742
|
-
/**
|
|
1743
|
-
* Throws if the current page has no real layout engine (`capabilities.layout === 'none'`),
|
|
1744
|
-
* used to guard visibility-dependent assertions that cannot be evaluated without one.
|
|
1745
|
-
* @param action - name of the calling assertion, used in the error message.
|
|
1489
|
+
* @param locator - located by CSS|XPath|Strict locator.
|
|
1746
1490
|
*/
|
|
1747
|
-
|
|
1491
|
+
dontSeeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1748
1492
|
/**
|
|
1749
|
-
* Checks that a given Element is visible
|
|
1493
|
+
* Checks that a given Element is visible
|
|
1750
1494
|
* Element is located by CSS or XPath.
|
|
1751
1495
|
*
|
|
1496
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1497
|
+
*
|
|
1752
1498
|
* ```js
|
|
1753
1499
|
* I.seeElement('#modal');
|
|
1500
|
+
* I.seeElement('#modal', '#container');
|
|
1501
|
+
* // using ARIA role locator
|
|
1502
|
+
* I.seeElement({role: 'dialog'});
|
|
1754
1503
|
* ```
|
|
1504
|
+
*
|
|
1505
|
+
* > ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators](/locators#aria-locators).
|
|
1755
1506
|
* @param locator - located by CSS|XPath|strict locator.
|
|
1756
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1507
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1757
1508
|
*/
|
|
1758
|
-
seeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1509
|
+
seeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1759
1510
|
/**
|
|
1760
|
-
* Opposite to `seeElement`. Checks that element is not visible
|
|
1511
|
+
* Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
1512
|
+
*
|
|
1513
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1761
1514
|
*
|
|
1762
1515
|
* ```js
|
|
1763
1516
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
1517
|
+
* I.dontSeeElement('.modal', '#container');
|
|
1764
1518
|
* ```
|
|
1765
|
-
* @param locator - located by CSS|XPath|
|
|
1766
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1519
|
+
* @param locator - located by CSS|XPath|Strict locator.
|
|
1520
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1767
1521
|
*/
|
|
1768
|
-
dontSeeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1522
|
+
dontSeeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1769
1523
|
/**
|
|
1770
1524
|
* Verifies that the specified checkbox is checked.
|
|
1771
1525
|
*
|
|
@@ -1774,19 +1528,20 @@ declare namespace CodeceptJS {
|
|
|
1774
1528
|
* I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1775
1529
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1776
1530
|
* ```
|
|
1777
|
-
* @param
|
|
1531
|
+
* @param field - located by label|name|CSS|XPath|strict locator.
|
|
1778
1532
|
*/
|
|
1779
|
-
seeCheckboxIsChecked(
|
|
1533
|
+
seeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1780
1534
|
/**
|
|
1781
1535
|
* Verifies that the specified checkbox is not checked.
|
|
1782
1536
|
*
|
|
1783
1537
|
* ```js
|
|
1784
1538
|
* I.dontSeeCheckboxIsChecked('#agree'); // located by ID
|
|
1785
1539
|
* I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
1540
|
+
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1786
1541
|
* ```
|
|
1787
|
-
* @param
|
|
1542
|
+
* @param field - located by label|name|CSS|XPath|strict locator.
|
|
1788
1543
|
*/
|
|
1789
|
-
dontSeeCheckboxIsChecked(
|
|
1544
|
+
dontSeeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1790
1545
|
/**
|
|
1791
1546
|
* Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
1792
1547
|
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
@@ -1796,49 +1551,42 @@ declare namespace CodeceptJS {
|
|
|
1796
1551
|
* ```
|
|
1797
1552
|
* If multiple elements found returns first element.
|
|
1798
1553
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1799
|
-
* @returns
|
|
1554
|
+
* @returns attribute value
|
|
1800
1555
|
*/
|
|
1801
1556
|
grabTextFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
|
|
1802
1557
|
/**
|
|
1803
|
-
* Retrieves all texts from
|
|
1558
|
+
* Retrieves all texts from an element located by CSS or XPath and returns it to test.
|
|
1804
1559
|
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1805
1560
|
*
|
|
1806
1561
|
* ```js
|
|
1807
1562
|
* let pins = await I.grabTextFromAll('#pin li');
|
|
1808
1563
|
* ```
|
|
1809
1564
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1810
|
-
* @returns
|
|
1565
|
+
* @returns attribute value
|
|
1811
1566
|
*/
|
|
1812
1567
|
grabTextFromAll(locator: CodeceptJS.LocatorOrString): Promise<string[]>;
|
|
1813
1568
|
/**
|
|
1814
|
-
*
|
|
1815
|
-
*
|
|
1816
|
-
* `candidates` and picking the matching index, since `CDPBrowser` never keeps a persistent
|
|
1817
|
-
* handle to a DOM node on the Node side.
|
|
1569
|
+
* Grab WebElements for given locator
|
|
1570
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1818
1571
|
*
|
|
1819
1572
|
* ```js
|
|
1820
|
-
* const
|
|
1573
|
+
* const webElements = await I.grabWebElements('#button');
|
|
1821
1574
|
* ```
|
|
1822
1575
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1823
|
-
* @returns
|
|
1576
|
+
* @returns WebElement of being used Web helper
|
|
1824
1577
|
*/
|
|
1825
|
-
grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<
|
|
1578
|
+
grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1826
1579
|
/**
|
|
1827
|
-
*
|
|
1580
|
+
* Grab WebElement for given locator
|
|
1581
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1828
1582
|
*
|
|
1829
1583
|
* ```js
|
|
1830
|
-
* const
|
|
1584
|
+
* const webElement = await I.grabWebElement('#button');
|
|
1831
1585
|
* ```
|
|
1832
1586
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1833
|
-
* @returns
|
|
1834
|
-
*/
|
|
1835
|
-
grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<object>;
|
|
1836
|
-
/**
|
|
1837
|
-
* Resolves whether the `texts` action should read via the client's `visibleText()` walker
|
|
1838
|
-
* (probed once via `_needsVisibleTextFallback` and cached on `capabilities.innerText`) instead
|
|
1839
|
-
* of each element's native `innerText`, then runs it.
|
|
1587
|
+
* @returns WebElement of being used Web helper
|
|
1840
1588
|
*/
|
|
1841
|
-
|
|
1589
|
+
grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1842
1590
|
/**
|
|
1843
1591
|
* Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
1844
1592
|
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
@@ -1852,14 +1600,14 @@ declare namespace CodeceptJS {
|
|
|
1852
1600
|
*/
|
|
1853
1601
|
grabValueFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
|
|
1854
1602
|
/**
|
|
1855
|
-
* Retrieves an array of
|
|
1603
|
+
* Retrieves an array of value from a form located by CSS or XPath and returns it to test.
|
|
1856
1604
|
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1857
1605
|
*
|
|
1858
1606
|
* ```js
|
|
1859
1607
|
* let inputs = await I.grabValueFromAll('//form/input');
|
|
1860
1608
|
* ```
|
|
1861
1609
|
* @param locator - field located by label|name|CSS|XPath|strict locator.
|
|
1862
|
-
* @returns
|
|
1610
|
+
* @returns attribute value
|
|
1863
1611
|
*/
|
|
1864
1612
|
grabValueFromAll(locator: CodeceptJS.LocatorOrString): Promise<string[]>;
|
|
1865
1613
|
/**
|
|
@@ -1884,7 +1632,7 @@ declare namespace CodeceptJS {
|
|
|
1884
1632
|
* ```
|
|
1885
1633
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
1886
1634
|
* @param attr - attribute name.
|
|
1887
|
-
* @returns
|
|
1635
|
+
* @returns attribute value
|
|
1888
1636
|
*/
|
|
1889
1637
|
grabAttributeFromAll(locator: CodeceptJS.LocatorOrString, attr: string): Promise<string[]>;
|
|
1890
1638
|
/**
|
|
@@ -1904,13 +1652,13 @@ declare namespace CodeceptJS {
|
|
|
1904
1652
|
* For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
1905
1653
|
* For images, the "alt" attribute and inner text of any parent links are searched.
|
|
1906
1654
|
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
* element with a zero-size bounding box (e.g. `display: none`) has no valid coordinate to click and throws;
|
|
1911
|
-
* use `forceClick` to dispatch a synthetic click on such elements instead.
|
|
1655
|
+
* If no locator is provided, defaults to clicking the body element (`'//body'`).
|
|
1656
|
+
*
|
|
1657
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1912
1658
|
*
|
|
1913
1659
|
* ```js
|
|
1660
|
+
* // click body element (default)
|
|
1661
|
+
* I.click();
|
|
1914
1662
|
* // simple link
|
|
1915
1663
|
* I.click('Logout');
|
|
1916
1664
|
* // button of form
|
|
@@ -1919,22 +1667,30 @@ declare namespace CodeceptJS {
|
|
|
1919
1667
|
* I.click('#form input[type=submit]');
|
|
1920
1668
|
* // XPath
|
|
1921
1669
|
* I.click('//form/*[@type=submit]');
|
|
1670
|
+
* // link in context
|
|
1671
|
+
* I.click('Logout', '#nav');
|
|
1922
1672
|
* // using strict locator
|
|
1923
1673
|
* I.click({css: 'nav a.login'});
|
|
1674
|
+
* // using ARIA role locator
|
|
1675
|
+
* I.click({role: 'button', name: 'Submit'});
|
|
1924
1676
|
* ```
|
|
1925
|
-
*
|
|
1677
|
+
*
|
|
1678
|
+
* > ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators](/locators#aria-locators).
|
|
1679
|
+
* @param [locator = '//body'] - (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1926
1680
|
* @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1927
1681
|
*/
|
|
1928
|
-
click(locator
|
|
1682
|
+
click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
|
|
1929
1683
|
/**
|
|
1930
1684
|
* Perform an emulated click on a link or a button, given by a locator.
|
|
1931
|
-
* Unlike
|
|
1932
|
-
*
|
|
1685
|
+
* Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
1686
|
+
* This works on hidden, animated or inactive elements as well.
|
|
1933
1687
|
*
|
|
1934
1688
|
* If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
1935
1689
|
* For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
1936
1690
|
* For images, the "alt" attribute and inner text of any parent links are searched.
|
|
1937
1691
|
*
|
|
1692
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1693
|
+
*
|
|
1938
1694
|
* ```js
|
|
1939
1695
|
* // simple link
|
|
1940
1696
|
* I.forceClick('Logout');
|
|
@@ -1944,46 +1700,21 @@ declare namespace CodeceptJS {
|
|
|
1944
1700
|
* I.forceClick('#form input[type=submit]');
|
|
1945
1701
|
* // XPath
|
|
1946
1702
|
* I.forceClick('//form/*[@type=submit]');
|
|
1703
|
+
* // link in context
|
|
1704
|
+
* I.forceClick('Logout', '#nav');
|
|
1947
1705
|
* // using strict locator
|
|
1948
1706
|
* I.forceClick({css: 'nav a.login'});
|
|
1949
1707
|
* ```
|
|
1950
1708
|
* @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1951
1709
|
* @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1952
1710
|
*/
|
|
1953
|
-
forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1954
|
-
/**
|
|
1955
|
-
* Settles after an interaction (click, key press, etc.) before the next step runs, using the
|
|
1956
|
-
* listener `_armActionSettle` started *before* the interaction was dispatched (`armed`; a fresh
|
|
1957
|
-
* one is armed here too, as a safety net, if a call site forgot to — but arming this late can
|
|
1958
|
-
* only miss a navigation that already started during the action's own dispatch, exactly the race
|
|
1959
|
-
* this design exists to avoid, so every call site should pass its own pre-armed `armed`, not rely
|
|
1960
|
-
* on this fallback).
|
|
1961
|
-
*
|
|
1962
|
-
* If `options.waitForAction` was set explicitly in the config, honors it literally as a fixed
|
|
1963
|
-
* pacing sleep, exactly as before this round — an explicit value is a deliberate choice
|
|
1964
|
-
* (slow-motion debugging, a known-slow app) this never second-guesses.
|
|
1965
|
-
*
|
|
1966
|
-
* Otherwise, event-aware: races the armed listener against a *fresh* `ACTION_SETTLE_GRACE_MS`
|
|
1967
|
-
* window (started now, not when it was armed — the action's own dispatch already ran concurrently
|
|
1968
|
-
* with the arm, so this is genuinely bounded extra time, not a guess). If nothing declares a
|
|
1969
|
-
* navigation, returns immediately once the window elapses — the common case for most actions
|
|
1970
|
-
* (typing, toggling a checkbox, focusing a field) — instead of a fixed `options.waitForAction`
|
|
1971
|
-
* (100ms by default) sleep on every single action regardless of whether anything is happening.
|
|
1972
|
-
*
|
|
1973
|
-
* If a navigation *did* start, `_lastMainFrameNav` (see `_ensureLifecycleListener`) is checked
|
|
1974
|
-
* first: on a fast/local page, the entire lifecycle sequence through the target event has
|
|
1975
|
-
* typically already arrived in the same batch that announced the navigation started, in which
|
|
1976
|
-
* case this returns immediately. Only a navigation still genuinely in flight falls through to
|
|
1977
|
-
* `_waitForPageLoad` (the same mechanism `amOnPage`/`refreshPage` use) — which waits for it to
|
|
1978
|
-
* actually finish, rather than a fixed sleep that has no relationship to how long the navigation
|
|
1979
|
-
* actually takes: strictly more correct for a slow navigation, not just faster for a fast one.
|
|
1980
|
-
* @param [armed] - from `_armActionSettle`, called before the action.
|
|
1981
|
-
*/
|
|
1982
|
-
protected _waitForAction(armed?: any | null): Promise<void>;
|
|
1711
|
+
forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
1983
1712
|
/**
|
|
1984
1713
|
* Fills a text field or textarea, after clearing its value, with the given string.
|
|
1985
1714
|
* Field is located by name, label, CSS, or XPath.
|
|
1986
1715
|
*
|
|
1716
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1717
|
+
*
|
|
1987
1718
|
* ```js
|
|
1988
1719
|
* // by label
|
|
1989
1720
|
* I.fillField('Email', 'hello@world.com');
|
|
@@ -1993,43 +1724,59 @@ declare namespace CodeceptJS {
|
|
|
1993
1724
|
* I.fillField('form#login input[name=username]', 'John');
|
|
1994
1725
|
* // or by strict locator
|
|
1995
1726
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1727
|
+
* // by ARIA role locator
|
|
1728
|
+
* I.fillField({role: 'textbox', name: 'Email'}, 'hello@world.com');
|
|
1729
|
+
* // within a context
|
|
1730
|
+
* I.fillField('Name', 'John', '#section2');
|
|
1996
1731
|
* ```
|
|
1732
|
+
*
|
|
1733
|
+
* > ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators](/locators#aria-locators).
|
|
1997
1734
|
* @param field - located by label|name|CSS|XPath|strict locator.
|
|
1998
1735
|
* @param value - text value to fill.
|
|
1999
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1736
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2000
1737
|
*/
|
|
2001
|
-
fillField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1738
|
+
fillField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2002
1739
|
/**
|
|
2003
1740
|
* Appends text to a input field or textarea.
|
|
2004
1741
|
* Field is located by name, label, CSS or XPath
|
|
2005
1742
|
*
|
|
1743
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1744
|
+
*
|
|
2006
1745
|
* ```js
|
|
2007
1746
|
* I.appendField('#myTextField', 'appended');
|
|
2008
1747
|
* // typing secret
|
|
2009
1748
|
* I.appendField('password', secret('123456'));
|
|
1749
|
+
* // within a context
|
|
1750
|
+
* I.appendField('name', 'John', '.form-container');
|
|
2010
1751
|
* ```
|
|
2011
1752
|
* @param field - located by label|name|CSS|XPath|strict locator
|
|
2012
1753
|
* @param value - text value to append.
|
|
2013
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1754
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2014
1755
|
*/
|
|
2015
|
-
appendField(field: CodeceptJS.LocatorOrString, value: string, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1756
|
+
appendField(field: CodeceptJS.LocatorOrString, value: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2016
1757
|
/**
|
|
2017
1758
|
* Clears a `<textarea>` or text `<input>` element's value.
|
|
2018
1759
|
*
|
|
1760
|
+
* The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1761
|
+
*
|
|
2019
1762
|
* ```js
|
|
2020
1763
|
* I.clearField('Email');
|
|
2021
1764
|
* I.clearField('user[email]');
|
|
2022
1765
|
* I.clearField('#email');
|
|
1766
|
+
* // within a context
|
|
1767
|
+
* I.clearField('Email', '.form-container');
|
|
2023
1768
|
* ```
|
|
2024
|
-
* @param
|
|
2025
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1769
|
+
* @param editable - field located by label|name|CSS|XPath|strict locator.
|
|
1770
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2026
1771
|
*/
|
|
2027
|
-
clearField(
|
|
1772
|
+
clearField(editable: LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2028
1773
|
/**
|
|
2029
1774
|
* Selects an option in a drop-down select.
|
|
2030
1775
|
* Field is searched by label | name | CSS | XPath.
|
|
2031
1776
|
* Option is selected by visible text or by value.
|
|
2032
1777
|
*
|
|
1778
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1779
|
+
*
|
|
2033
1780
|
* ```js
|
|
2034
1781
|
* I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
2035
1782
|
* I.selectOption('subscription', 'Monthly'); // match option by text
|
|
@@ -2037,16 +1784,26 @@ declare namespace CodeceptJS {
|
|
|
2037
1784
|
* I.selectOption('//form/select[@name=account]','Premium');
|
|
2038
1785
|
* I.selectOption('form select[name=account]', 'Premium');
|
|
2039
1786
|
* I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
1787
|
+
* // within a context
|
|
1788
|
+
* I.selectOption('age', '21-60', '#section2');
|
|
1789
|
+
* ```
|
|
1790
|
+
*
|
|
1791
|
+
* Provide an array for the second argument to select multiple options.
|
|
1792
|
+
*
|
|
1793
|
+
* ```js
|
|
1794
|
+
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
2040
1795
|
* ```
|
|
2041
1796
|
* @param select - field located by label|name|CSS|XPath|strict locator.
|
|
2042
|
-
* @param option - visible text or value of option
|
|
2043
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1797
|
+
* @param option - visible text or value of option.
|
|
1798
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2044
1799
|
*/
|
|
2045
|
-
selectOption(select:
|
|
1800
|
+
selectOption(select: LocatorOrString, option: string | any[], context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2046
1801
|
/**
|
|
2047
1802
|
* Selects a checkbox or radio button.
|
|
2048
1803
|
* Element is located by label or name or CSS or XPath.
|
|
2049
1804
|
*
|
|
1805
|
+
* The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1806
|
+
*
|
|
2050
1807
|
* ```js
|
|
2051
1808
|
* I.checkOption('#agree');
|
|
2052
1809
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
@@ -2055,11 +1812,13 @@ declare namespace CodeceptJS {
|
|
|
2055
1812
|
* @param field - checkbox located by label | name | CSS | XPath | strict locator.
|
|
2056
1813
|
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2057
1814
|
*/
|
|
2058
|
-
checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1815
|
+
checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2059
1816
|
/**
|
|
2060
1817
|
* Unselects a checkbox or radio button.
|
|
2061
1818
|
* Element is located by label or name or CSS or XPath.
|
|
2062
1819
|
*
|
|
1820
|
+
* The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1821
|
+
*
|
|
2063
1822
|
* ```js
|
|
2064
1823
|
* I.uncheckOption('#agree');
|
|
2065
1824
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
@@ -2068,31 +1827,34 @@ declare namespace CodeceptJS {
|
|
|
2068
1827
|
* @param field - checkbox located by label | name | CSS | XPath | strict locator.
|
|
2069
1828
|
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2070
1829
|
*/
|
|
2071
|
-
uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1830
|
+
uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2072
1831
|
/**
|
|
2073
|
-
* Attaches a file to
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
* `<input type="file">` is then addressed by that attribute through the CDP `DOM` domain, which
|
|
2079
|
-
* `CDPBrowser` otherwise never uses, to call `DOM.setFileInputFiles`; any other element (a
|
|
2080
|
-
* drag-and-drop dropzone) instead gets a synthetic `dragenter`/`dragover`/`drop` sequence with a
|
|
2081
|
-
* `DataTransfer` built from the file's contents, entirely in-page. The marker is removed again in
|
|
2082
|
-
* a `finally`.
|
|
1832
|
+
* Attaches a file to element located by label, name, CSS or XPath
|
|
1833
|
+
* Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
|
|
1834
|
+
* File will be uploaded to remote system (if tests are running remotely).
|
|
1835
|
+
*
|
|
1836
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
2083
1837
|
*
|
|
2084
1838
|
* ```js
|
|
2085
1839
|
* I.attachFile('Avatar', 'data/avatar.jpg');
|
|
2086
|
-
* I.attachFile('
|
|
1840
|
+
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1841
|
+
* // within a context
|
|
1842
|
+
* I.attachFile('Avatar', 'data/avatar.jpg', '.form-container');
|
|
1843
|
+
* ```
|
|
1844
|
+
*
|
|
1845
|
+
* If the locator points to a non-file-input element (e.g., a dropzone area),
|
|
1846
|
+
* the file will be dropped onto that element using drag-and-drop events.
|
|
1847
|
+
*
|
|
1848
|
+
* ```js
|
|
2087
1849
|
* I.attachFile('#dropzone', 'data/avatar.jpg');
|
|
2088
1850
|
* ```
|
|
2089
|
-
* @param
|
|
2090
|
-
* @param pathToFile -
|
|
2091
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
1851
|
+
* @param locator - field located by label|name|CSS|XPath|strict locator.
|
|
1852
|
+
* @param pathToFile - local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
1853
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2092
1854
|
*/
|
|
2093
|
-
attachFile(
|
|
1855
|
+
attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2094
1856
|
/**
|
|
2095
|
-
* Waits for element to be present on page (by default waits for
|
|
1857
|
+
* Waits for element to be present on page (by default waits for 1sec).
|
|
2096
1858
|
* Element can be located by CSS or XPath.
|
|
2097
1859
|
*
|
|
2098
1860
|
* ```js
|
|
@@ -2100,11 +1862,11 @@ declare namespace CodeceptJS {
|
|
|
2100
1862
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2101
1863
|
* ```
|
|
2102
1864
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2103
|
-
* @param [sec = null] - (optional, `
|
|
1865
|
+
* @param [sec = null] - (optional, `1` by default) time in seconds to wait
|
|
2104
1866
|
*/
|
|
2105
|
-
waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<
|
|
1867
|
+
waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
|
|
2106
1868
|
/**
|
|
2107
|
-
* Waits for a text to appear (by default waits for
|
|
1869
|
+
* Waits for a text to appear (by default waits for 1sec).
|
|
2108
1870
|
* Element can be located by CSS or XPath.
|
|
2109
1871
|
* Narrow down search results by providing context.
|
|
2110
1872
|
*
|
|
@@ -2113,10 +1875,10 @@ declare namespace CodeceptJS {
|
|
|
2113
1875
|
* I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
2114
1876
|
* ```
|
|
2115
1877
|
* @param text - to wait for.
|
|
2116
|
-
* @param [sec =
|
|
1878
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2117
1879
|
* @param [context = null] - (optional) element located by CSS|XPath|strict locator.
|
|
2118
1880
|
*/
|
|
2119
|
-
waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): Promise<
|
|
1881
|
+
waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2120
1882
|
/**
|
|
2121
1883
|
* Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
|
|
2122
1884
|
*
|
|
@@ -2124,23 +1886,27 @@ declare namespace CodeceptJS {
|
|
|
2124
1886
|
* I.waitInUrl('/info', 2);
|
|
2125
1887
|
* ```
|
|
2126
1888
|
* @param urlPart - value to check.
|
|
2127
|
-
* @param [sec =
|
|
1889
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2128
1890
|
*/
|
|
2129
|
-
waitInUrl(urlPart: string, sec?: number): Promise<
|
|
1891
|
+
waitInUrl(urlPart: string, sec?: number): Promise<any>;
|
|
2130
1892
|
/**
|
|
2131
|
-
* Waits for a function to return true (waits for
|
|
1893
|
+
* Waits for a function to return true (waits for 1 sec by default).
|
|
2132
1894
|
* Running in browser context.
|
|
2133
1895
|
*
|
|
2134
1896
|
* ```js
|
|
1897
|
+
* I.waitForFunction(fn[, [args[, timeout]])
|
|
1898
|
+
* ```
|
|
1899
|
+
*
|
|
1900
|
+
* ```js
|
|
2135
1901
|
* I.waitForFunction(() => window.requests == 0);
|
|
2136
1902
|
* I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
|
|
2137
1903
|
* I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
|
|
2138
1904
|
* ```
|
|
2139
1905
|
* @param fn - to be executed in browser context.
|
|
2140
|
-
* @param [argsOrSec = null] - (optional) arguments for function or
|
|
2141
|
-
* @param [sec = null] - (optional, `
|
|
1906
|
+
* @param [argsOrSec = null] - (optional, `1` by default) arguments for function or seconds.
|
|
1907
|
+
* @param [sec = null] - (optional, `1` by default) time in seconds to wait
|
|
2142
1908
|
*/
|
|
2143
|
-
waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): Promise<
|
|
1909
|
+
waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): Promise<any>;
|
|
2144
1910
|
/**
|
|
2145
1911
|
* Sets cookie(s).
|
|
2146
1912
|
*
|
|
@@ -2157,7 +1923,7 @@ declare namespace CodeceptJS {
|
|
|
2157
1923
|
* ```
|
|
2158
1924
|
* @param cookie - a cookie object or array of cookie objects.
|
|
2159
1925
|
*/
|
|
2160
|
-
setCookie(cookie:
|
|
1926
|
+
setCookie(cookie: Cookie | Cookie[]): Promise<any>;
|
|
2161
1927
|
/**
|
|
2162
1928
|
* Retrieves all cookies visible to the current page.
|
|
2163
1929
|
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
@@ -2178,9 +1944,8 @@ declare namespace CodeceptJS {
|
|
|
2178
1944
|
* assert(cookie.value, '123456');
|
|
2179
1945
|
* ```
|
|
2180
1946
|
* @param [name = null] - cookie name.
|
|
2181
|
-
* @returns a cookie object, or an array of all cookies when `name` is not provided.
|
|
2182
1947
|
*/
|
|
2183
|
-
grabCookie(name?: string
|
|
1948
|
+
grabCookie(name?: string): Promise<any>;
|
|
2184
1949
|
/**
|
|
2185
1950
|
* Clears a cookie by name,
|
|
2186
1951
|
* if none provided clears all cookies.
|
|
@@ -2189,9 +1954,9 @@ declare namespace CodeceptJS {
|
|
|
2189
1954
|
* I.clearCookie();
|
|
2190
1955
|
* I.clearCookie('test');
|
|
2191
1956
|
* ```
|
|
2192
|
-
* @param [
|
|
1957
|
+
* @param [cookie = null] - (optional, `null` by default) cookie name
|
|
2193
1958
|
*/
|
|
2194
|
-
clearCookie(
|
|
1959
|
+
clearCookie(cookie?: string): Promise<any>;
|
|
2195
1960
|
/**
|
|
2196
1961
|
* Checks that the system clipboard contains the given text.
|
|
2197
1962
|
*
|
|
@@ -2200,10 +1965,11 @@ declare namespace CodeceptJS {
|
|
|
2200
1965
|
* I.seeInClipboard('https://codecept.io');
|
|
2201
1966
|
* ```
|
|
2202
1967
|
*
|
|
2203
|
-
* Reading the clipboard requires a secure context (`https` or `localhost`)
|
|
1968
|
+
* Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
1969
|
+
* in Chromium-based browsers, where read access is granted automatically.
|
|
2204
1970
|
* @param text - value to check.
|
|
2205
1971
|
*/
|
|
2206
|
-
seeInClipboard(text: string): Promise<
|
|
1972
|
+
seeInClipboard(text: string): Promise<any>;
|
|
2207
1973
|
/**
|
|
2208
1974
|
* Checks that the system clipboard is equal to the given text.
|
|
2209
1975
|
*
|
|
@@ -2212,10 +1978,11 @@ declare namespace CodeceptJS {
|
|
|
2212
1978
|
* I.seeClipboardEquals('https://codecept.io');
|
|
2213
1979
|
* ```
|
|
2214
1980
|
*
|
|
2215
|
-
* Reading the clipboard requires a secure context (`https` or `localhost`)
|
|
1981
|
+
* Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
1982
|
+
* in Chromium-based browsers, where read access is granted automatically.
|
|
2216
1983
|
* @param text - value to check.
|
|
2217
1984
|
*/
|
|
2218
|
-
seeClipboardEquals(text: string): Promise<
|
|
1985
|
+
seeClipboardEquals(text: string): Promise<any>;
|
|
2219
1986
|
/**
|
|
2220
1987
|
* Clears the system clipboard.
|
|
2221
1988
|
*
|
|
@@ -2224,24 +1991,21 @@ declare namespace CodeceptJS {
|
|
|
2224
1991
|
* I.seeClipboardEquals('');
|
|
2225
1992
|
* ```
|
|
2226
1993
|
*/
|
|
2227
|
-
clearClipboard(): Promise<
|
|
1994
|
+
clearClipboard(): Promise<any>;
|
|
2228
1995
|
/**
|
|
2229
|
-
* Grabs the text content of the system clipboard.
|
|
1996
|
+
* Grabs the text content of the system clipboard and returns it to test.
|
|
2230
1997
|
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
2231
1998
|
*
|
|
2232
1999
|
* ```js
|
|
2233
2000
|
* I.click('Copy to clipboard');
|
|
2234
|
-
*
|
|
2001
|
+
* let url = await I.grabFromClipboard();
|
|
2235
2002
|
* ```
|
|
2003
|
+
*
|
|
2004
|
+
* Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
2005
|
+
* in Chromium-based browsers, where read access is granted automatically.
|
|
2236
2006
|
* @returns the system clipboard contents.
|
|
2237
2007
|
*/
|
|
2238
2008
|
grabFromClipboard(): Promise<string>;
|
|
2239
|
-
/**
|
|
2240
|
-
* Brings the current target to front and grants it clipboard read/write access, so
|
|
2241
|
-
* `navigator.clipboard` does not reject with a permission or focus error. Failures are ignored:
|
|
2242
|
-
* a browser without `Browser.grantPermissions` surfaces its own error from the read instead.
|
|
2243
|
-
*/
|
|
2244
|
-
protected _grantClipboardAccess(): Promise<any>;
|
|
2245
2009
|
/**
|
|
2246
2010
|
* Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
|
|
2247
2011
|
* Filename is relative to the output folder.
|
|
@@ -2251,168 +2015,203 @@ declare namespace CodeceptJS {
|
|
|
2251
2015
|
* ```
|
|
2252
2016
|
* @param fileName - file name to save.
|
|
2253
2017
|
*/
|
|
2254
|
-
saveScreenshot(fileName: string): Promise<
|
|
2018
|
+
saveScreenshot(fileName: string): Promise<any>;
|
|
2255
2019
|
/**
|
|
2256
|
-
* Saves
|
|
2020
|
+
* Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
2021
|
+
* Filename is relative to output folder.
|
|
2257
2022
|
*
|
|
2258
2023
|
* ```js
|
|
2259
|
-
* I.saveElementScreenshot('
|
|
2024
|
+
* I.saveElementScreenshot(`#submit`,'debug.png');
|
|
2260
2025
|
* ```
|
|
2261
2026
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2262
2027
|
* @param fileName - file name to save.
|
|
2263
2028
|
*/
|
|
2264
|
-
saveElementScreenshot(locator: CodeceptJS.LocatorOrString, fileName: string): Promise<
|
|
2029
|
+
saveElementScreenshot(locator: CodeceptJS.LocatorOrString, fileName: string): Promise<any>;
|
|
2265
2030
|
/**
|
|
2266
2031
|
* Pauses execution for a number of seconds.
|
|
2267
2032
|
*
|
|
2268
2033
|
* ```js
|
|
2269
|
-
* I.wait(2); //
|
|
2034
|
+
* I.wait(2); // wait 2 secs
|
|
2270
2035
|
* ```
|
|
2271
|
-
* @param sec - number of
|
|
2036
|
+
* @param sec - number of second to wait.
|
|
2272
2037
|
*/
|
|
2273
|
-
wait(sec: number): Promise<
|
|
2038
|
+
wait(sec: number): Promise<any>;
|
|
2274
2039
|
/**
|
|
2275
2040
|
* Checks that title does not contain text.
|
|
2041
|
+
*
|
|
2042
|
+
* ```js
|
|
2043
|
+
* I.dontSeeInTitle('Error');
|
|
2044
|
+
* ```
|
|
2276
2045
|
* @param text - value to check.
|
|
2277
2046
|
*/
|
|
2278
|
-
dontSeeInTitle(text: string): Promise<
|
|
2047
|
+
dontSeeInTitle(text: string): Promise<any>;
|
|
2279
2048
|
/**
|
|
2280
2049
|
* Checks that current url is equal to provided one.
|
|
2281
|
-
*
|
|
2050
|
+
* If a relative url provided, a configured url will be prepended to it.
|
|
2051
|
+
* So both examples will work:
|
|
2282
2052
|
*
|
|
2283
2053
|
* ```js
|
|
2284
2054
|
* I.seeCurrentUrlEquals('/register');
|
|
2055
|
+
* I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
2285
2056
|
* ```
|
|
2286
2057
|
* @param url - value to check.
|
|
2287
2058
|
*/
|
|
2288
|
-
seeCurrentUrlEquals(url: string): Promise<
|
|
2059
|
+
seeCurrentUrlEquals(url: string): Promise<any>;
|
|
2289
2060
|
/**
|
|
2290
2061
|
* Checks that current url is not equal to provided one.
|
|
2291
|
-
*
|
|
2062
|
+
* If a relative url provided, a configured url will be prepended to it.
|
|
2063
|
+
*
|
|
2064
|
+
* ```js
|
|
2065
|
+
* I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
|
|
2066
|
+
* I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
|
|
2067
|
+
* ```
|
|
2292
2068
|
* @param url - value to check.
|
|
2293
2069
|
*/
|
|
2294
|
-
dontSeeCurrentUrlEquals(url: string): Promise<
|
|
2295
|
-
/**
|
|
2296
|
-
* Resolves the current page URL to a `pathname`, ignoring the origin, query string, and hash.
|
|
2297
|
-
* @returns the pathname of the current page.
|
|
2298
|
-
*/
|
|
2299
|
-
protected _grabCurrentPath(): Promise<string>;
|
|
2070
|
+
dontSeeCurrentUrlEquals(url: string): Promise<any>;
|
|
2300
2071
|
/**
|
|
2301
|
-
* Checks that current
|
|
2072
|
+
* Checks that current URL path matches the expected path.
|
|
2073
|
+
* Query strings and URL fragments are ignored.
|
|
2302
2074
|
*
|
|
2303
2075
|
* ```js
|
|
2304
|
-
* I.seeCurrentPathEquals('/info');
|
|
2076
|
+
* I.seeCurrentPathEquals('/info'); // passes for '/info', '/info?user=1', '/info#section'
|
|
2077
|
+
* I.seeCurrentPathEquals('/'); // passes for '/', '/?user=ok', '/#top'
|
|
2305
2078
|
* ```
|
|
2306
2079
|
* @param path - value to check.
|
|
2307
2080
|
*/
|
|
2308
|
-
seeCurrentPathEquals(path: string): Promise<
|
|
2081
|
+
seeCurrentPathEquals(path: string): Promise<any>;
|
|
2309
2082
|
/**
|
|
2310
|
-
*
|
|
2083
|
+
* Checks that current URL path does NOT match the expected path.
|
|
2084
|
+
* Query strings and URL fragments are ignored.
|
|
2085
|
+
*
|
|
2086
|
+
* ```js
|
|
2087
|
+
* I.dontSeeCurrentPathEquals('/form'); // fails for '/form', '/form?user=1', '/form#section'
|
|
2088
|
+
* I.dontSeeCurrentPathEquals('/'); // fails for '/', '/?user=ok', '/#top'
|
|
2089
|
+
* ```
|
|
2311
2090
|
* @param path - value to check.
|
|
2312
2091
|
*/
|
|
2313
|
-
dontSeeCurrentPathEquals(path: string): Promise<
|
|
2092
|
+
dontSeeCurrentPathEquals(path: string): Promise<any>;
|
|
2314
2093
|
/**
|
|
2315
|
-
* Waits for the entire URL to match the expected
|
|
2094
|
+
* Waits for the entire URL to match the expected
|
|
2316
2095
|
*
|
|
2317
2096
|
* ```js
|
|
2318
2097
|
* I.waitUrlEquals('/info', 2);
|
|
2098
|
+
* I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
2319
2099
|
* ```
|
|
2320
2100
|
* @param urlPart - value to check.
|
|
2321
|
-
* @param [sec =
|
|
2101
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2322
2102
|
*/
|
|
2323
|
-
waitUrlEquals(urlPart: string, sec?: number): Promise<
|
|
2103
|
+
waitUrlEquals(urlPart: string, sec?: number): Promise<any>;
|
|
2324
2104
|
/**
|
|
2325
|
-
* Waits for current
|
|
2105
|
+
* Waits for the current URL path to match the expected path.
|
|
2106
|
+
* Query strings and URL fragments are ignored.
|
|
2326
2107
|
*
|
|
2327
2108
|
* ```js
|
|
2328
|
-
* I.waitCurrentPathEquals('/info',
|
|
2109
|
+
* I.waitCurrentPathEquals('/info', 5);
|
|
2329
2110
|
* ```
|
|
2330
2111
|
* @param path - value to check.
|
|
2331
|
-
* @param [sec = null] - (optional, `
|
|
2112
|
+
* @param [sec = null] - (optional, `waitForTimeout` by default) time in seconds to wait
|
|
2332
2113
|
*/
|
|
2333
|
-
waitCurrentPathEquals(path: string, sec?: number): Promise<
|
|
2114
|
+
waitCurrentPathEquals(path: string, sec?: number): Promise<any>;
|
|
2334
2115
|
/**
|
|
2335
|
-
* Checks that the given input field or textarea equals
|
|
2336
|
-
* For fuzzy locators,
|
|
2116
|
+
* Checks that the given input field or textarea equals to given value.
|
|
2117
|
+
* For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
2118
|
+
*
|
|
2119
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
2337
2120
|
*
|
|
2338
2121
|
* ```js
|
|
2339
2122
|
* I.seeInField('Username', 'davert');
|
|
2123
|
+
* I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
2124
|
+
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
2125
|
+
* I.seeInField('#searchform input','Search');
|
|
2126
|
+
* // within a context
|
|
2127
|
+
* I.seeInField('Name', 'John', '.form-container');
|
|
2340
2128
|
* ```
|
|
2341
2129
|
* @param field - located by label|name|CSS|XPath|strict locator.
|
|
2342
2130
|
* @param value - value to check.
|
|
2343
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
2131
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2344
2132
|
*/
|
|
2345
|
-
seeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<
|
|
2133
|
+
seeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2346
2134
|
/**
|
|
2135
|
+
* Checks that value of input field or textarea doesn't equal to given value
|
|
2347
2136
|
* Opposite to `seeInField`.
|
|
2137
|
+
*
|
|
2138
|
+
* The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
2139
|
+
*
|
|
2140
|
+
* ```js
|
|
2141
|
+
* I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
2142
|
+
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
2143
|
+
* // within a context
|
|
2144
|
+
* I.dontSeeInField('Name', 'old_value', '.form-container');
|
|
2145
|
+
* ```
|
|
2348
2146
|
* @param field - located by label|name|CSS|XPath|strict locator.
|
|
2349
2147
|
* @param value - value to check.
|
|
2350
|
-
* @param [context = null] - (optional, `null` by default) element
|
|
2351
|
-
*/
|
|
2352
|
-
dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<void>;
|
|
2353
|
-
/**
|
|
2354
|
-
* Shared implementation for `seeInField`/`dontSeeInField`.
|
|
2148
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
2355
2149
|
*/
|
|
2356
|
-
|
|
2150
|
+
dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2357
2151
|
/**
|
|
2358
2152
|
* Grab number of visible elements by locator.
|
|
2153
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
2359
2154
|
*
|
|
2360
2155
|
* ```js
|
|
2361
|
-
* let
|
|
2156
|
+
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
2362
2157
|
* ```
|
|
2363
2158
|
* @param locator - located by CSS|XPath|strict locator.
|
|
2364
|
-
* @returns number of visible
|
|
2159
|
+
* @returns number of visible elements
|
|
2365
2160
|
*/
|
|
2366
2161
|
grabNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString): Promise<number>;
|
|
2367
2162
|
/**
|
|
2368
|
-
* Asserts that an element
|
|
2163
|
+
* Asserts that an element is visible a given number of times.
|
|
2164
|
+
* Element is located by CSS or XPath.
|
|
2369
2165
|
*
|
|
2370
2166
|
* ```js
|
|
2371
2167
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
2372
2168
|
* ```
|
|
2373
|
-
* @param locator - located by CSS|XPath|strict locator.
|
|
2374
|
-
* @param num -
|
|
2169
|
+
* @param locator - element located by CSS|XPath|strict locator.
|
|
2170
|
+
* @param num - number of elements.
|
|
2375
2171
|
*/
|
|
2376
|
-
seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): Promise<
|
|
2172
|
+
seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): Promise<any>;
|
|
2377
2173
|
/**
|
|
2378
|
-
* Retrieves
|
|
2174
|
+
* Retrieves a page scroll position and returns it to test.
|
|
2175
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
2379
2176
|
*
|
|
2380
2177
|
* ```js
|
|
2381
2178
|
* let { x, y } = await I.grabPageScrollPosition();
|
|
2382
2179
|
* ```
|
|
2383
|
-
* @returns scroll position
|
|
2180
|
+
* @returns scroll position
|
|
2384
2181
|
*/
|
|
2385
|
-
grabPageScrollPosition(): Promise<
|
|
2182
|
+
grabPageScrollPosition(): Promise<PageScrollPosition>;
|
|
2386
2183
|
/**
|
|
2387
|
-
*
|
|
2184
|
+
* Scroll page to the top.
|
|
2388
2185
|
*
|
|
2389
2186
|
* ```js
|
|
2390
2187
|
* I.scrollPageToTop();
|
|
2391
2188
|
* ```
|
|
2392
2189
|
*/
|
|
2393
|
-
scrollPageToTop(): Promise<
|
|
2190
|
+
scrollPageToTop(): Promise<any>;
|
|
2394
2191
|
/**
|
|
2395
|
-
*
|
|
2192
|
+
* Scroll page to the bottom.
|
|
2396
2193
|
*
|
|
2397
2194
|
* ```js
|
|
2398
2195
|
* I.scrollPageToBottom();
|
|
2399
2196
|
* ```
|
|
2400
2197
|
*/
|
|
2401
|
-
scrollPageToBottom(): Promise<
|
|
2198
|
+
scrollPageToBottom(): Promise<any>;
|
|
2402
2199
|
/**
|
|
2403
|
-
* Scrolls to
|
|
2200
|
+
* Scrolls to element matched by locator.
|
|
2201
|
+
* Extra shift can be set with offsetX and offsetY options.
|
|
2404
2202
|
*
|
|
2405
2203
|
* ```js
|
|
2406
|
-
* I.scrollTo('
|
|
2407
|
-
* I.scrollTo(
|
|
2204
|
+
* I.scrollTo('footer');
|
|
2205
|
+
* I.scrollTo('#submit', 5, 5);
|
|
2408
2206
|
* ```
|
|
2409
|
-
* @param locator -
|
|
2410
|
-
* @param [offsetX = 0] -
|
|
2411
|
-
* @param [offsetY = 0] -
|
|
2207
|
+
* @param locator - located by CSS|XPath|strict locator.
|
|
2208
|
+
* @param [offsetX = 0] - (optional, `0` by default) X-axis offset.
|
|
2209
|
+
* @param [offsetY = 0] - (optional, `0` by default) Y-axis offset.
|
|
2412
2210
|
*/
|
|
2413
|
-
scrollTo(locator: CodeceptJS.LocatorOrString
|
|
2211
|
+
scrollTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): Promise<any>;
|
|
2414
2212
|
/**
|
|
2415
|
-
*
|
|
2213
|
+
* Grab CSS property for given locator
|
|
2214
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
2416
2215
|
* If more than one element is found - value of first element is returned.
|
|
2417
2216
|
*
|
|
2418
2217
|
* ```js
|
|
@@ -2424,79 +2223,94 @@ declare namespace CodeceptJS {
|
|
|
2424
2223
|
*/
|
|
2425
2224
|
grabCssPropertyFrom(locator: CodeceptJS.LocatorOrString, cssProperty: string): Promise<string>;
|
|
2426
2225
|
/**
|
|
2427
|
-
*
|
|
2226
|
+
* Grab array of CSS properties for given locator
|
|
2227
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
2428
2228
|
*
|
|
2429
2229
|
* ```js
|
|
2430
2230
|
* const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
2431
2231
|
* ```
|
|
2432
2232
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2433
2233
|
* @param cssProperty - CSS property name.
|
|
2434
|
-
* @returns
|
|
2234
|
+
* @returns CSS value
|
|
2435
2235
|
*/
|
|
2436
2236
|
grabCssPropertyFromAll(locator: CodeceptJS.LocatorOrString, cssProperty: string): Promise<string[]>;
|
|
2437
2237
|
/**
|
|
2438
|
-
* Checks that all elements
|
|
2238
|
+
* Checks that all elements with given locator have given CSS properties.
|
|
2439
2239
|
*
|
|
2440
2240
|
* ```js
|
|
2441
|
-
* I.seeCssPropertiesOnElements('h3', { 'font-weight':
|
|
2241
|
+
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
2442
2242
|
* ```
|
|
2443
|
-
* @param locator -
|
|
2243
|
+
* @param locator - located by CSS|XPath|strict locator.
|
|
2444
2244
|
* @param cssProperties - object with CSS properties and their values to check.
|
|
2445
2245
|
*/
|
|
2446
|
-
seeCssPropertiesOnElements(locator: CodeceptJS.LocatorOrString, cssProperties: any): Promise<
|
|
2246
|
+
seeCssPropertiesOnElements(locator: CodeceptJS.LocatorOrString, cssProperties: any): Promise<any>;
|
|
2447
2247
|
/**
|
|
2448
|
-
* Checks that all elements
|
|
2449
|
-
* An expected value is matched either as an exact match or as a regular expression against the actual value.
|
|
2248
|
+
* Checks that all elements with given locator have given attributes.
|
|
2450
2249
|
*
|
|
2451
2250
|
* ```js
|
|
2452
|
-
* I.seeAttributesOnElements('//form', { method:
|
|
2251
|
+
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
2453
2252
|
* ```
|
|
2454
|
-
* @param locator -
|
|
2455
|
-
* @param attributes -
|
|
2253
|
+
* @param locator - located by CSS|XPath|strict locator.
|
|
2254
|
+
* @param attributes - attributes and their values to check.
|
|
2456
2255
|
*/
|
|
2457
|
-
seeAttributesOnElements(locator: CodeceptJS.LocatorOrString, attributes: any): Promise<
|
|
2256
|
+
seeAttributesOnElements(locator: CodeceptJS.LocatorOrString, attributes: any): Promise<any>;
|
|
2458
2257
|
/**
|
|
2459
|
-
*
|
|
2258
|
+
* Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
|
|
2259
|
+
*
|
|
2260
|
+
* Examples:
|
|
2460
2261
|
*
|
|
2461
2262
|
* ```js
|
|
2462
|
-
* I.
|
|
2263
|
+
* I.dontSee('#add-to-cart-btn');
|
|
2264
|
+
* I.focus('#product-tile')
|
|
2265
|
+
* I.see('#add-to-cart-bnt');
|
|
2463
2266
|
* ```
|
|
2464
|
-
* @param locator -
|
|
2267
|
+
* @param locator - field located by label|name|CSS|XPath|strict locator.
|
|
2268
|
+
* @param [options] - Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
2465
2269
|
*/
|
|
2466
|
-
focus(locator: CodeceptJS.LocatorOrString): Promise<
|
|
2270
|
+
focus(locator: CodeceptJS.LocatorOrString, options?: any): Promise<any>;
|
|
2467
2271
|
/**
|
|
2468
|
-
*
|
|
2272
|
+
* Remove focus from a text input, button, etc.
|
|
2273
|
+
* Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
2274
|
+
*
|
|
2275
|
+
* Examples:
|
|
2469
2276
|
*
|
|
2470
2277
|
* ```js
|
|
2471
|
-
* I.blur('
|
|
2278
|
+
* I.blur('.text-area')
|
|
2472
2279
|
* ```
|
|
2473
|
-
*
|
|
2280
|
+
* ```js
|
|
2281
|
+
* //element `#product-tile` is focused
|
|
2282
|
+
* I.see('#add-to-cart-btn');
|
|
2283
|
+
* I.blur('#product-tile')
|
|
2284
|
+
* I.dontSee('#add-to-cart-btn');
|
|
2285
|
+
* ```
|
|
2286
|
+
* @param locator - field located by label|name|CSS|XPath|strict locator.
|
|
2287
|
+
* @param [options] - Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
2474
2288
|
*/
|
|
2475
|
-
blur(locator: CodeceptJS.LocatorOrString): Promise<
|
|
2289
|
+
blur(locator: CodeceptJS.LocatorOrString, options?: any): Promise<any>;
|
|
2476
2290
|
/**
|
|
2477
|
-
* Types
|
|
2478
|
-
*
|
|
2479
|
-
*
|
|
2480
|
-
* works on rich-text/contenteditable targets as well as `input`/`textarea`. Mirrors Puppeteer's
|
|
2481
|
-
* `type(text, options)` semantics.
|
|
2482
|
-
*
|
|
2483
|
-
* Without a `delay`, every character is dispatched in a single round-trip to the page. With a
|
|
2484
|
-
* `delay`, characters are dispatched one round-trip at a time so the requested pause actually
|
|
2485
|
-
* elapses between key presses.
|
|
2291
|
+
* Types out the given text into an active field.
|
|
2292
|
+
* To slow down typing use a second parameter, to set interval between key presses.
|
|
2293
|
+
* _Note:_ Should be used when [`fillField`](#fillfield) is not an option.
|
|
2486
2294
|
*
|
|
2487
2295
|
* ```js
|
|
2488
|
-
*
|
|
2489
|
-
* I.type('
|
|
2490
|
-
*
|
|
2296
|
+
* // passing in a string
|
|
2297
|
+
* I.type('Type this out.');
|
|
2298
|
+
*
|
|
2299
|
+
* // typing values with a 100ms interval
|
|
2300
|
+
* I.type('4141555311111111', 100);
|
|
2301
|
+
*
|
|
2302
|
+
* // passing in an array
|
|
2303
|
+
* I.type(['T', 'E', 'X', 'T']);
|
|
2304
|
+
*
|
|
2305
|
+
* // passing a secret
|
|
2306
|
+
* I.type(secret('123456'));
|
|
2491
2307
|
* ```
|
|
2492
|
-
* @param
|
|
2493
|
-
* @param [delay = null] - (optional) delay in
|
|
2308
|
+
* @param key - or array of keys to type.
|
|
2309
|
+
* @param [delay = null] - (optional) delay in ms between key presses
|
|
2494
2310
|
*/
|
|
2495
|
-
type(
|
|
2311
|
+
type(key: string | string[], delay?: number): Promise<any>;
|
|
2496
2312
|
/**
|
|
2497
|
-
* Presses a key or key combination on the
|
|
2498
|
-
* Under `options.strict`, a modifier+editing-key combination (e.g. `Ctrl+A`) dispatched with no
|
|
2499
|
-
* element focused throws `NonFocusedType`, mirroring `focusCheck.js`'s behavior on other helpers.
|
|
2313
|
+
* Presses a key or a key combination on the focused element.
|
|
2500
2314
|
*
|
|
2501
2315
|
* ```js
|
|
2502
2316
|
* I.pressKey('Enter');
|
|
@@ -2504,171 +2318,186 @@ declare namespace CodeceptJS {
|
|
|
2504
2318
|
* ```
|
|
2505
2319
|
* @param key - a key or an array of keys to combine (modifiers first).
|
|
2506
2320
|
*/
|
|
2507
|
-
pressKey(key: string | string[]): Promise<
|
|
2321
|
+
pressKey(key: string | string[]): Promise<any>;
|
|
2508
2322
|
/**
|
|
2509
|
-
*
|
|
2510
|
-
*
|
|
2511
|
-
*
|
|
2512
|
-
*
|
|
2513
|
-
* ```
|
|
2514
|
-
* @param width - window width, or `'maximize'`.
|
|
2515
|
-
* @param [height] - window height.
|
|
2323
|
+
* Resize the current window to provided width and height.
|
|
2324
|
+
* First parameter can be set to `maximize`.
|
|
2325
|
+
* @param width - width in pixels or `maximize`.
|
|
2326
|
+
* @param height - height in pixels.
|
|
2516
2327
|
*/
|
|
2517
|
-
resizeWindow(width: number
|
|
2328
|
+
resizeWindow(width: number, height: number): Promise<any>;
|
|
2518
2329
|
/**
|
|
2519
|
-
* Performs a double-click on an element matched by
|
|
2330
|
+
* Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
2331
|
+
* Context can be specified as second parameter to narrow search.
|
|
2520
2332
|
*
|
|
2521
2333
|
* ```js
|
|
2522
2334
|
* I.doubleClick('Edit');
|
|
2335
|
+
* I.doubleClick('Edit', '.actions');
|
|
2336
|
+
* I.doubleClick({css: 'button.accept'});
|
|
2337
|
+
* I.doubleClick('.btn.edit');
|
|
2523
2338
|
* ```
|
|
2524
|
-
* @param locator - clickable
|
|
2525
|
-
* @param [context = null] - (optional, `null` by default
|
|
2339
|
+
* @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
2340
|
+
* @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
2526
2341
|
*/
|
|
2527
|
-
doubleClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
2342
|
+
doubleClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2528
2343
|
/**
|
|
2529
|
-
* Performs
|
|
2344
|
+
* Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
2530
2345
|
*
|
|
2531
2346
|
* ```js
|
|
2532
|
-
*
|
|
2347
|
+
* // right click element with id el
|
|
2348
|
+
* I.rightClick('#el');
|
|
2349
|
+
* // right click link or button with text "Click me"
|
|
2350
|
+
* I.rightClick('Click me');
|
|
2351
|
+
* // right click button with text "Click me" inside .context
|
|
2352
|
+
* I.rightClick('Click me', '.context');
|
|
2533
2353
|
* ```
|
|
2534
|
-
* @param locator - clickable element located by
|
|
2535
|
-
* @param [context = null] - (optional, `null` by default
|
|
2354
|
+
* @param locator - clickable element located by CSS|XPath|strict locator.
|
|
2355
|
+
* @param [context = null] - (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
2536
2356
|
*/
|
|
2537
|
-
rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<
|
|
2357
|
+
rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
|
|
2538
2358
|
/**
|
|
2539
|
-
* Clicks at
|
|
2540
|
-
*
|
|
2359
|
+
* Clicks at page coordinates, or at coordinates relative to an element.
|
|
2360
|
+
* Requires a browser that renders layout.
|
|
2541
2361
|
*
|
|
2542
2362
|
* ```js
|
|
2543
|
-
* I.clickXY(100, 200); //
|
|
2363
|
+
* I.clickXY(100, 200); // page coordinates
|
|
2544
2364
|
* I.clickXY('#area', 50, 30); // relative to #area
|
|
2545
2365
|
* ```
|
|
2546
|
-
* @param locator - element to click relative to, or
|
|
2547
|
-
* @param [x] - X coordinate relative to element, or
|
|
2548
|
-
* @param [y] - Y coordinate relative to element.
|
|
2366
|
+
* @param locator - element to click relative to, or the X page coordinate.
|
|
2367
|
+
* @param [x] - X coordinate relative to the element, or the Y page coordinate if `locator` is a number.
|
|
2368
|
+
* @param [y] - Y coordinate relative to the element.
|
|
2549
2369
|
*/
|
|
2550
|
-
clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<
|
|
2370
|
+
clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<any>;
|
|
2551
2371
|
/**
|
|
2552
|
-
* Waits for an element to become visible (by default waits for
|
|
2372
|
+
* Waits for an element to become visible on a page (by default waits for 1sec).
|
|
2373
|
+
* Element can be located by CSS or XPath.
|
|
2553
2374
|
*
|
|
2554
2375
|
* ```js
|
|
2555
|
-
* I.waitForVisible('#popup'
|
|
2376
|
+
* I.waitForVisible('#popup');
|
|
2556
2377
|
* ```
|
|
2557
2378
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2558
|
-
* @param [sec =
|
|
2379
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2559
2380
|
*/
|
|
2560
|
-
waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<
|
|
2381
|
+
waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
|
|
2561
2382
|
/**
|
|
2562
|
-
* Waits for an element to become invisible (by default waits for
|
|
2383
|
+
* Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
2384
|
+
* Element can be located by CSS or XPath.
|
|
2563
2385
|
*
|
|
2564
2386
|
* ```js
|
|
2565
|
-
* I.waitForInvisible('#popup'
|
|
2387
|
+
* I.waitForInvisible('#popup');
|
|
2566
2388
|
* ```
|
|
2567
2389
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2568
|
-
* @param [sec =
|
|
2390
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2569
2391
|
*/
|
|
2570
|
-
waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<
|
|
2392
|
+
waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
|
|
2571
2393
|
/**
|
|
2572
|
-
* Waits for an element to
|
|
2394
|
+
* Waits for an element to hide (by default waits for 1sec).
|
|
2395
|
+
* Element can be located by CSS or XPath.
|
|
2396
|
+
*
|
|
2397
|
+
* ```js
|
|
2398
|
+
* I.waitToHide('#popup');
|
|
2399
|
+
* ```
|
|
2573
2400
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2574
|
-
* @param [sec =
|
|
2401
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2575
2402
|
*/
|
|
2576
|
-
waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<
|
|
2403
|
+
waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
|
|
2577
2404
|
/**
|
|
2578
|
-
* Waits for an element to
|
|
2405
|
+
* Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
2406
|
+
* Element can be located by CSS or XPath.
|
|
2579
2407
|
*
|
|
2580
2408
|
* ```js
|
|
2581
|
-
* I.waitForDetached('#popup'
|
|
2409
|
+
* I.waitForDetached('#popup');
|
|
2582
2410
|
* ```
|
|
2583
2411
|
* @param locator - element located by CSS|XPath|strict locator.
|
|
2584
|
-
* @param [sec =
|
|
2412
|
+
* @param [sec = 1] - (optional, `1` by default) time in seconds to wait
|
|
2585
2413
|
*/
|
|
2586
|
-
waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<
|
|
2414
|
+
waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
|
|
2587
2415
|
/**
|
|
2588
|
-
* Checks that
|
|
2416
|
+
* Checks that cookie with given name exists.
|
|
2417
|
+
*
|
|
2418
|
+
* ```js
|
|
2419
|
+
* I.seeCookie('Auth');
|
|
2420
|
+
* ```
|
|
2589
2421
|
* @param name - cookie name.
|
|
2590
2422
|
*/
|
|
2591
|
-
seeCookie(name: string): Promise<
|
|
2423
|
+
seeCookie(name: string): Promise<any>;
|
|
2592
2424
|
/**
|
|
2593
|
-
* Checks that
|
|
2425
|
+
* Checks that cookie with given name does not exist.
|
|
2426
|
+
*
|
|
2427
|
+
* ```js
|
|
2428
|
+
* I.dontSeeCookie('auth'); // no auth cookie
|
|
2429
|
+
* ```
|
|
2594
2430
|
* @param name - cookie name.
|
|
2595
2431
|
*/
|
|
2596
|
-
dontSeeCookie(name: string): Promise<
|
|
2432
|
+
dontSeeCookie(name: string): Promise<any>;
|
|
2597
2433
|
/**
|
|
2598
|
-
* Waits for
|
|
2434
|
+
* Waits for the specified cookie in the cookies.
|
|
2599
2435
|
*
|
|
2600
2436
|
* ```js
|
|
2601
|
-
* I.waitForCookie(
|
|
2437
|
+
* I.waitForCookie("token");
|
|
2602
2438
|
* ```
|
|
2603
|
-
* @param name - cookie name.
|
|
2604
|
-
* @param [sec =
|
|
2439
|
+
* @param name - expected cookie name.
|
|
2440
|
+
* @param [sec = 3] - (optional, `3` by default) time in seconds to wait
|
|
2605
2441
|
*/
|
|
2606
|
-
waitForCookie(name: string, sec?: number): Promise<
|
|
2442
|
+
waitForCookie(name: string, sec?: number): Promise<any>;
|
|
2607
2443
|
/**
|
|
2608
|
-
* Retrieves the
|
|
2444
|
+
* Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
2445
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
2609
2446
|
* If more than one element is found - HTML of first element is returned.
|
|
2610
2447
|
*
|
|
2611
2448
|
* ```js
|
|
2612
2449
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
2613
2450
|
* ```
|
|
2614
|
-
* @param
|
|
2451
|
+
* @param element - located by CSS|XPath|strict locator.
|
|
2615
2452
|
* @returns HTML code for an element
|
|
2616
2453
|
*/
|
|
2617
|
-
grabHTMLFrom(
|
|
2454
|
+
grabHTMLFrom(element: CodeceptJS.LocatorOrString): Promise<string>;
|
|
2618
2455
|
/**
|
|
2619
|
-
* Retrieves the
|
|
2456
|
+
* Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
|
|
2457
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
2620
2458
|
*
|
|
2621
2459
|
* ```js
|
|
2622
2460
|
* let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
2623
2461
|
* ```
|
|
2624
|
-
* @param
|
|
2625
|
-
* @returns HTML code for
|
|
2462
|
+
* @param element - located by CSS|XPath|strict locator.
|
|
2463
|
+
* @returns HTML code for an element
|
|
2626
2464
|
*/
|
|
2627
|
-
grabHTMLFromAll(
|
|
2465
|
+
grabHTMLFromAll(element: CodeceptJS.LocatorOrString): Promise<string[]>;
|
|
2628
2466
|
/**
|
|
2629
|
-
* Executes
|
|
2630
|
-
*
|
|
2467
|
+
* Executes async script on page.
|
|
2468
|
+
* Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
2469
|
+
*
|
|
2470
|
+
* Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
|
|
2471
|
+
*
|
|
2472
|
+
* ```js
|
|
2473
|
+
* I.executeAsyncScript(function(done) {
|
|
2474
|
+
* Vue.nextTick(done); // waiting for next tick
|
|
2475
|
+
* });
|
|
2476
|
+
* ```
|
|
2477
|
+
*
|
|
2478
|
+
* By passing value to `done()` function you can return values.
|
|
2479
|
+
* Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
|
|
2631
2480
|
*
|
|
2632
2481
|
* ```js
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2635
|
-
*
|
|
2482
|
+
* let val = await I.executeAsyncScript(function(url, done) {
|
|
2483
|
+
* // in browser context
|
|
2484
|
+
* $.ajax(url, { success: (data) => done(data); }
|
|
2485
|
+
* }, 'http://ajax.callback.url/');
|
|
2636
2486
|
* ```
|
|
2637
|
-
* @param fn -
|
|
2638
|
-
* @param args -
|
|
2639
|
-
* @returns
|
|
2487
|
+
* @param fn - function to be executed in browser context.
|
|
2488
|
+
* @param args - to be passed to function.
|
|
2489
|
+
* @returns script return value
|
|
2640
2490
|
*/
|
|
2641
|
-
executeAsyncScript(fn: (...params: any[]) => any, ...args: any[]): Promise<any>;
|
|
2491
|
+
executeAsyncScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
|
|
2642
2492
|
/**
|
|
2643
|
-
* Starts recording network
|
|
2644
|
-
*
|
|
2645
|
-
* request, `response` a promise of `{url(), status(), statusText(), body()}`) the shared
|
|
2646
|
-
* `lib/helper/network` actions expect from Puppeteer/Playwright. The CDP listeners are
|
|
2647
|
-
* installed once (lazily) and left in place afterwards, since `CDPConnection` has no listener
|
|
2648
|
-
* removal and `this.cdp` is reused across tests; they filter by `this.sessionId`, so only the
|
|
2649
|
-
* currently active test/page's requests are recorded.
|
|
2493
|
+
* Starts recording the network traffics.
|
|
2494
|
+
* This also resets recorded network requests.
|
|
2650
2495
|
*
|
|
2651
2496
|
* ```js
|
|
2652
2497
|
* I.startRecordingTraffic();
|
|
2653
2498
|
* ```
|
|
2654
2499
|
*/
|
|
2655
|
-
startRecordingTraffic(): Promise<
|
|
2656
|
-
/**
|
|
2657
|
-
* `Network.requestWillBeSent` handler, pushed into `this.requests` when it belongs to the
|
|
2658
|
-
* currently active session and recording is on.
|
|
2659
|
-
*/
|
|
2660
|
-
protected _onTrafficRequest(): Promise<any>;
|
|
2661
|
-
/**
|
|
2662
|
-
* `Network.responseReceived` handler, resolving the matching pending `response` promise pushed
|
|
2663
|
-
* by `_onTrafficRequest` with a Puppeteer-`HTTPResponse`-like object.
|
|
2664
|
-
*/
|
|
2665
|
-
protected _onTrafficResponse(): Promise<any>;
|
|
2666
|
-
/**
|
|
2667
|
-
* `Network.loadingFailed` handler, resolving a still-pending `response` promise to `null`
|
|
2668
|
-
* (matching Puppeteer's `request.response()` for a failed request) so `grabRecordedNetworkTraffics`
|
|
2669
|
-
* never awaits a promise that would otherwise never settle.
|
|
2670
|
-
*/
|
|
2671
|
-
protected _onTrafficLoadingFailed(): Promise<any>;
|
|
2500
|
+
startRecordingTraffic(): Promise<any>;
|
|
2672
2501
|
/**
|
|
2673
2502
|
* Grab the recording network traffics
|
|
2674
2503
|
*
|
|
@@ -2741,8 +2570,7 @@ declare namespace CodeceptJS {
|
|
|
2741
2570
|
url: string | RegExp;
|
|
2742
2571
|
}): Promise<any>;
|
|
2743
2572
|
/**
|
|
2744
|
-
* Stops recording network traffic
|
|
2745
|
-
* in `this.requests` are kept; only new requests stop being appended.
|
|
2573
|
+
* Stops recording of network traffic. Recorded traffic is not flashed.
|
|
2746
2574
|
*
|
|
2747
2575
|
* ```js
|
|
2748
2576
|
* I.stopRecordingTraffic();
|
|
@@ -2758,46 +2586,134 @@ declare namespace CodeceptJS {
|
|
|
2758
2586
|
*/
|
|
2759
2587
|
flushNetworkTraffics(): Promise<any>;
|
|
2760
2588
|
/**
|
|
2761
|
-
* Starts recording a
|
|
2762
|
-
*
|
|
2763
|
-
* required or the browser stops sending more), and buffered in `this._screencastFrames`. The
|
|
2764
|
-
* underlying `Page.screencastFrame` listener is installed once (lazily) and left in place, like
|
|
2765
|
-
* `startRecordingTraffic`'s listeners, since `CDPConnection` has no listener-removal API; it
|
|
2766
|
-
* filters by `this.sessionId` so only the currently active test's frames are buffered. Call
|
|
2767
|
-
* `stopScreencast` to end the capture and assemble the buffered frames into an APNG.
|
|
2589
|
+
* Starts recording a video of the page. Stop it with `stopScreencast`.
|
|
2590
|
+
* Usually enabled through the `screencast` plugin rather than called directly.
|
|
2768
2591
|
*
|
|
2769
2592
|
* ```js
|
|
2770
2593
|
* I.startScreencast();
|
|
2771
2594
|
* ```
|
|
2772
|
-
* @param [options] - {maxWidth
|
|
2595
|
+
* @param [options] - `{ maxWidth, maxHeight, quality, everyNthFrame }`
|
|
2596
|
+
*/
|
|
2597
|
+
startScreencast(options?: any): Promise<any>;
|
|
2598
|
+
/**
|
|
2599
|
+
* Stops the recording started by `startScreencast` and returns it as an animated PNG.
|
|
2600
|
+
*
|
|
2601
|
+
* ```js
|
|
2602
|
+
* const video = await I.stopScreencast();
|
|
2603
|
+
* ```
|
|
2604
|
+
* @param [options] - `{ lastFrameDelayMs }`: how long the last frame is shown, in milliseconds (1000 by default).
|
|
2605
|
+
* @returns APNG data, or `null` if no frames were recorded.
|
|
2773
2606
|
*/
|
|
2774
|
-
|
|
2607
|
+
stopScreencast(options?: any): Promise<Buffer | null>;
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* Asserts statements about the current page with a decision model.
|
|
2611
|
+
*
|
|
2612
|
+
* Decision models (like [Jev](https://openrouter.ai/typesafe/jev-1.13) or [Clef](https://openrouter.ai/cloudflare/clef))
|
|
2613
|
+
* do not generate text. They read the page state and return the probability that a statement is true.
|
|
2614
|
+
* A statement passes when its probability reaches the configured `confidence`.
|
|
2615
|
+
*
|
|
2616
|
+
* ```js
|
|
2617
|
+
* I.decide('top level navigation is available');
|
|
2618
|
+
* I.decide([
|
|
2619
|
+
* 'checkout form has all required fields',
|
|
2620
|
+
* 'success message is shown',
|
|
2621
|
+
* 'submit button enabled',
|
|
2622
|
+
* 'cancel button present',
|
|
2623
|
+
* ]);
|
|
2624
|
+
* I.decideVisually('sidebar is shown');
|
|
2625
|
+
* ```
|
|
2626
|
+
*
|
|
2627
|
+
* The model receives the page URL, title and ARIA snapshot.
|
|
2628
|
+
* Helpers without ARIA snapshots (anything but Playwright) send minified HTML instead.
|
|
2629
|
+
* `decideVisually` also sends a screenshot, so it requires a model with image input.
|
|
2630
|
+
*
|
|
2631
|
+
* This helper must be enabled together with a web helper (Playwright, Puppeteer, WebDriver).
|
|
2632
|
+
*
|
|
2633
|
+
* ## Configuration
|
|
2634
|
+
*
|
|
2635
|
+
* Decision model is created with the OpenRouter provider from `@openrouter/ai-sdk-provider`
|
|
2636
|
+
* and configured in the `ai.decisionModel` section of the config:
|
|
2637
|
+
*
|
|
2638
|
+
* ```js
|
|
2639
|
+
* import { createOpenRouter } from '@openrouter/ai-sdk-provider'
|
|
2640
|
+
*
|
|
2641
|
+
* const openrouter = createOpenRouter({
|
|
2642
|
+
* apiKey: process.env.OPENROUTER_API_KEY,
|
|
2643
|
+
* })
|
|
2644
|
+
*
|
|
2645
|
+
* export default {
|
|
2646
|
+
* ai: {
|
|
2647
|
+
* decisionModel: {
|
|
2648
|
+
* model: openrouter.evaluationModel('typesafe/jev-1.13'),
|
|
2649
|
+
* confidence: 0.8,
|
|
2650
|
+
* },
|
|
2651
|
+
* },
|
|
2652
|
+
* helpers: {
|
|
2653
|
+
* Playwright: { url: 'http://localhost' },
|
|
2654
|
+
* Decision: {},
|
|
2655
|
+
* },
|
|
2656
|
+
* }
|
|
2657
|
+
* ```
|
|
2658
|
+
*
|
|
2659
|
+
* * `model` - decision model used by `decide`.
|
|
2660
|
+
* * `confidence` (default: `0.7`) - minimal probability, between 0 and 1, for a statement to pass.
|
|
2661
|
+
* * `timeout` (default: `15000`) - request timeout in ms.
|
|
2662
|
+
* * `maxLength` (default: `12000`) - maximal length of ARIA snapshot or HTML sent to the model.
|
|
2663
|
+
*
|
|
2664
|
+
* `decideVisually` uses a separate decision model with image input, configured as `visualModel`:
|
|
2665
|
+
*
|
|
2666
|
+
* ```js
|
|
2667
|
+
* decisionModel: {
|
|
2668
|
+
* model: openrouter.evaluationModel('typesafe/jev-1.13'),
|
|
2669
|
+
* visualModel: openrouter.evaluationModel('cloudflare/clef'),
|
|
2670
|
+
* },
|
|
2671
|
+
* ```
|
|
2672
|
+
*
|
|
2673
|
+
* The helper has one option:
|
|
2674
|
+
*
|
|
2675
|
+
* * `mode` (default: `assert`) - how decisions are executed:
|
|
2676
|
+
* * `assert` - request the model and fail the step when a statement is not confirmed.
|
|
2677
|
+
* * `report` - request the model but never fail, even on API errors. Results and errors are added to the step as a comment.
|
|
2678
|
+
* * `skip` - do not request the model, every decision passes.
|
|
2679
|
+
*
|
|
2680
|
+
* ```js
|
|
2681
|
+
* Decision: { mode: process.env.CI ? 'assert' : 'skip' }
|
|
2682
|
+
* ```
|
|
2683
|
+
*
|
|
2684
|
+
* Decisions work without the `--ai` flag.
|
|
2685
|
+
* Browse all decision models at [OpenRouter](https://openrouter.ai/models?output_modalities=decisions).
|
|
2686
|
+
*
|
|
2687
|
+
* ## Methods
|
|
2688
|
+
*/
|
|
2689
|
+
class DecisionTs {
|
|
2775
2690
|
/**
|
|
2776
|
-
*
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2691
|
+
* Asserts that a statement (or each of statements) is true for the current page.
|
|
2692
|
+
* The decision model receives page URL, title and ARIA snapshot.
|
|
2693
|
+
* Multiple statements are checked in a single request and all of them must pass.
|
|
2694
|
+
*
|
|
2695
|
+
* ```js
|
|
2696
|
+
* I.decide('user is logged in');
|
|
2697
|
+
* I.decide(['submit button enabled', 'cancel button present']);
|
|
2698
|
+
* const probability = await I.decide('cart is empty');
|
|
2699
|
+
* ```
|
|
2700
|
+
* @param statements - statement or list of statements to verify.
|
|
2701
|
+
* @returns probability of each statement, `undefined` in `skip` mode.
|
|
2780
2702
|
*/
|
|
2781
|
-
|
|
2703
|
+
decide(statements: string | string[]): Promise<number | number[] | undefined>;
|
|
2782
2704
|
/**
|
|
2783
|
-
*
|
|
2784
|
-
*
|
|
2785
|
-
*
|
|
2786
|
-
* only emit a frame on damage — so this reproduces the actual pacing of what happened, not a
|
|
2787
|
-
* fixed frame rate); the last frame is held for `options.lastFrameDelayMs` (default 1000ms) since
|
|
2788
|
-
* it has no "next" frame to derive a delay from. Every frame is checked for the PNG signature
|
|
2789
|
-
* before assembly — CDP's `format: 'png'` is honored by both Chrome and Obscura (verified
|
|
2790
|
-
* directly), but if some other engine ever sends a different format regardless, this reports it
|
|
2791
|
-
* via `debugSection` and returns `null` instead of muxing a broken file. Returns `null` if no
|
|
2792
|
-
* frames were captured (screencast never started, or stopped immediately after starting).
|
|
2705
|
+
* Asserts that a statement (or each of statements) is true for the current page using a screenshot.
|
|
2706
|
+
* The decision model receives page URL, title, ARIA snapshot and a screenshot.
|
|
2707
|
+
* Requires `visualModel` with image input. Experimental.
|
|
2793
2708
|
*
|
|
2794
2709
|
* ```js
|
|
2795
|
-
*
|
|
2710
|
+
* I.decideVisually('sidebar is shown');
|
|
2711
|
+
* I.decideVisually(['logo is in the header', 'page uses dark theme']);
|
|
2796
2712
|
* ```
|
|
2797
|
-
* @param
|
|
2798
|
-
* @returns
|
|
2713
|
+
* @param statements - statement or list of statements to verify.
|
|
2714
|
+
* @returns probability of each statement, `undefined` in `skip` mode.
|
|
2799
2715
|
*/
|
|
2800
|
-
|
|
2716
|
+
decideVisually(statements: string | string[]): Promise<number | number[] | undefined>;
|
|
2801
2717
|
}
|
|
2802
2718
|
/**
|
|
2803
2719
|
* Helper for testing filesystem.
|
|
@@ -3374,15 +3290,14 @@ declare namespace CodeceptJS {
|
|
|
3374
3290
|
/**
|
|
3375
3291
|
* ## Configuration
|
|
3376
3292
|
*
|
|
3377
|
-
* This helper should be configured in codecept.conf.js
|
|
3378
|
-
* accepts (see its config table), plus:
|
|
3293
|
+
* This helper should be configured in codecept.conf.js
|
|
3379
3294
|
* @property [url = http://localhost] - base URL for tests
|
|
3380
3295
|
* @property [accountId] - Cloudflare account ID; defaults to CF_ACCOUNT_ID env var
|
|
3381
3296
|
* @property [apiToken] - Cloudflare API token; defaults to CF_API_TOKEN env var
|
|
3382
3297
|
* @property [keepAlive = 240000] - session keep-alive time in milliseconds
|
|
3383
3298
|
* @property [apiBase = https://api.cloudflare.com/client/v4] - Cloudflare API base URL
|
|
3384
|
-
* @property [input = cdp] -
|
|
3385
|
-
* @property [capabilities] -
|
|
3299
|
+
* @property [input = cdp] - how actions are dispatched: `cdp` (real mouse and keyboard events) or `synthetic` (DOM events).
|
|
3300
|
+
* @property [capabilities] - browser capabilities; Kitesurf sets `{ layout: 'real', screenshot: true }`.
|
|
3386
3301
|
*/
|
|
3387
3302
|
type KitesurfConfig = {
|
|
3388
3303
|
url?: string;
|
|
@@ -3449,55 +3364,146 @@ declare namespace CodeceptJS {
|
|
|
3449
3364
|
*/
|
|
3450
3365
|
class KitesurfTs {
|
|
3451
3366
|
constructor(config: KitesurfConfig);
|
|
3452
|
-
/**
|
|
3453
|
-
* Acquires a Kitesurf browser session from the Cloudflare Browser Run API and resolves it to
|
|
3454
|
-
* the `wss://` debugger URL `CDPConnection` connects to. Overrides `CDPBrowser._resolveEndpoint`,
|
|
3455
|
-
* which resolves a fixed local endpoint instead of provisioning a cloud session per test.
|
|
3456
|
-
* @returns a `wss://` debugger URL ready to be passed to `CDPConnection`.
|
|
3457
|
-
*/
|
|
3458
|
-
protected _resolveEndpoint(): Promise<string>;
|
|
3459
|
-
/**
|
|
3460
|
-
* Closes the target as `CDPBrowser._finishTest` does, then releases the cloud session acquired
|
|
3461
|
-
* in `_resolveEndpoint` via the Cloudflare API so it does not linger for the full `keepAlive`
|
|
3462
|
-
* window. The release runs in a `finally` so a rejection while closing the CDP connection still
|
|
3463
|
-
* frees the cloud session instead of leaving the browser alive until `keepAlive` expires; the
|
|
3464
|
-
* session id is cleared before the request, so a repeated call never releases it twice.
|
|
3465
|
-
*/
|
|
3466
|
-
protected _finishTest(): Promise<any>;
|
|
3467
3367
|
}
|
|
3468
3368
|
/**
|
|
3469
3369
|
* ## Configuration
|
|
3470
3370
|
*
|
|
3471
|
-
* This helper should be configured in codecept.conf.js
|
|
3472
|
-
* accepts (see its config table), plus:
|
|
3371
|
+
* This helper should be configured in codecept.conf.js
|
|
3473
3372
|
* @property [endpoint] - explicit CDP endpoint. Setting this switches the helper to ATTACH
|
|
3474
3373
|
* mode: it only connects, and never spawns or kills a process, no matter what else is configured.
|
|
3475
3374
|
* Leave it unset for SELF-MANAGED mode (see below).
|
|
3476
|
-
* @property [binaryPath] - path to the `
|
|
3477
|
-
* (`endpoint` unset). Checked before `
|
|
3478
|
-
* @property [port] - port `
|
|
3375
|
+
* @property [binaryPath] - path to the `lightpanda` executable, used in SELF-MANAGED mode
|
|
3376
|
+
* (`endpoint` unset). Checked before `LIGHTPANDA_PATH` and `PATH`.
|
|
3377
|
+
* @property [port] - port `lightpanda serve` listens on, in SELF-MANAGED mode. When unset, a
|
|
3479
3378
|
* free port is picked automatically, which is what makes `run-workers` collision-free — every
|
|
3480
3379
|
* worker gets its own instance on its own port with zero config.
|
|
3481
|
-
* @property [serverStartTimeout = 15000] - milliseconds to wait for a spawned `
|
|
3380
|
+
* @property [serverStartTimeout = 15000] - milliseconds to wait for a spawned `lightpanda serve`
|
|
3482
3381
|
* to answer `/json/version` before `_connect` gives up.
|
|
3483
3382
|
*/
|
|
3484
|
-
type
|
|
3383
|
+
type LightpandaConfig = {
|
|
3485
3384
|
endpoint?: string;
|
|
3486
3385
|
binaryPath?: string;
|
|
3487
3386
|
port?: number;
|
|
3488
3387
|
serverStartTimeout?: number;
|
|
3489
3388
|
};
|
|
3490
3389
|
/**
|
|
3491
|
-
*
|
|
3492
|
-
*
|
|
3493
|
-
*
|
|
3494
|
-
*
|
|
3495
|
-
* given binary is in — `CDPBrowser._probeCapabilities` detects `layout`/`screenshot` per binary at
|
|
3496
|
-
* runtime, so the same helper works against either.
|
|
3390
|
+
* Lightpanda drives [Lightpanda](https://lightpanda.io), a headless browser written from scratch
|
|
3391
|
+
* for automation, exposed over the Chrome DevTools Protocol. It executes real JavaScript in V8 and
|
|
3392
|
+
* implements the DOM and Web APIs, but has no graphical rendering engine: nothing is ever painted,
|
|
3393
|
+
* so there are no screenshots.
|
|
3497
3394
|
*
|
|
3498
3395
|
* This helper is a thin `CDPBrowser` subclass: it changes nothing about how locating or acting on
|
|
3499
|
-
* elements works, it only pins the config presets
|
|
3500
|
-
* process lifecycle, the same way Playwright manages its own browser process.
|
|
3396
|
+
* elements works, it only pins the config presets Lightpanda requires and manages the
|
|
3397
|
+
* `lightpanda serve` process lifecycle, the same way Playwright manages its own browser process.
|
|
3398
|
+
*
|
|
3399
|
+
* > Lightpanda support is experimental. Pin the browser version in CI and keep a
|
|
3400
|
+
* > Playwright/WebDriver job for browser-compatibility coverage.
|
|
3401
|
+
*
|
|
3402
|
+
* ## Modes
|
|
3403
|
+
*
|
|
3404
|
+
* - **ATTACH** — `endpoint` is set explicitly in the config. The helper only connects to it; it
|
|
3405
|
+
* never spawns or kills anything, no matter what `binaryPath`/`port` are set to.
|
|
3406
|
+
* - **SELF-LAUNCH** — `endpoint` is unset and a binary can be resolved, in order: `binaryPath` in
|
|
3407
|
+
* the config, then the `LIGHTPANDA_PATH` environment variable, then `lightpanda` on `PATH`. The
|
|
3408
|
+
* helper spawns `lightpanda serve --host 127.0.0.1 --port <port>` (`port` from the config, or a
|
|
3409
|
+
* free port picked automatically), waits for it to answer, connects, and kills it in
|
|
3410
|
+
* `_finishTest`.
|
|
3411
|
+
* - **COURTESY-ATTACH** — `endpoint` is unset and no binary can be resolved, but something already
|
|
3412
|
+
* answers `http://127.0.0.1:9222/json/version` (e.g. `lightpanda serve` started by hand, or the
|
|
3413
|
+
* `lightpanda/browser` Docker image). The helper attaches to it and never kills it. If neither a
|
|
3414
|
+
* binary nor a running server on :9222 can be found, the helper throws a loud, actionable error.
|
|
3415
|
+
*
|
|
3416
|
+
* ## Install
|
|
3417
|
+
*
|
|
3418
|
+
* Follow the [official installation instructions](https://lightpanda.io/docs/open-source/installation),
|
|
3419
|
+
* then put `lightpanda` on your `PATH`, or point `binaryPath`/`LIGHTPANDA_PATH` at it. The helper
|
|
3420
|
+
* then launches and tears it down automatically.
|
|
3421
|
+
*
|
|
3422
|
+
* Lightpanda sends usage telemetry by default. This helper always spawns it with
|
|
3423
|
+
* `LIGHTPANDA_DISABLE_TELEMETRY=true`; set that variable yourself when you start the server by hand.
|
|
3424
|
+
*
|
|
3425
|
+
* Lightpanda is licensed under AGPL-3.0. It runs as a separate process that CodeceptJS talks to
|
|
3426
|
+
* over a WebSocket, so it does not change the license of CodeceptJS or of your tests.
|
|
3427
|
+
*
|
|
3428
|
+
* ## Config presets
|
|
3429
|
+
*
|
|
3430
|
+
* These are set automatically and only need overriding for unusual setups:
|
|
3431
|
+
*
|
|
3432
|
+
* | option | value | why |
|
|
3433
|
+
* | --- | --- | --- |
|
|
3434
|
+
* | `input` | `synthetic` | nothing is painted, so coordinates are not hit-tested; `click` always takes the `forceClick` path |
|
|
3435
|
+
* | `xpathPolyfill` | `auto` | probed per binary/page |
|
|
3436
|
+
* | `capabilities.layout` | `real` | Lightpanda computes visibility-related styles and element boxes without painting, which is enough for `seeElement` and the `waitForVisible` family; it is pinned because the runtime layout probe cannot run on Lightpanda's `about:blank` |
|
|
3437
|
+
* | `capabilities.screenshot` | `false` | there is no rendering engine |
|
|
3438
|
+
*
|
|
3439
|
+
* ## Limitations
|
|
3440
|
+
*
|
|
3441
|
+
* - No screenshots and no screencast: `saveScreenshot` throws.
|
|
3442
|
+
* - No frames or popups.
|
|
3443
|
+
* - No scrolling: scroll positions always stay at 0.
|
|
3444
|
+
* - Computed styles cover what visibility checks need (`display`, `visibility`, `opacity`,
|
|
3445
|
+
* `pointer-events`); `grabCssPropertyFrom` and `seeCssPropertiesOnElements` are unreliable for
|
|
3446
|
+
* other properties.
|
|
3447
|
+
* - No coordinate-based input (`clickXY`).
|
|
3448
|
+
* - No clipboard access.
|
|
3449
|
+
* - Some rich text editors (TinyMCE, Trix, Monaco) never finish initialising.
|
|
3450
|
+
*
|
|
3451
|
+
* <!-- configuration -->
|
|
3452
|
+
*
|
|
3453
|
+
* ## Example
|
|
3454
|
+
*
|
|
3455
|
+
* ```js
|
|
3456
|
+
* // inside codecept.conf.js — SELF-LAUNCH mode (recommended): the helper finds/starts/stops
|
|
3457
|
+
* // lightpanda serve on its own, on a free port. Ideal for run-workers: every worker gets its
|
|
3458
|
+
* // own instance with no config.
|
|
3459
|
+
* {
|
|
3460
|
+
* helpers: {
|
|
3461
|
+
* Lightpanda: {
|
|
3462
|
+
* url: 'http://localhost',
|
|
3463
|
+
* }
|
|
3464
|
+
* }
|
|
3465
|
+
* }
|
|
3466
|
+
* ```
|
|
3467
|
+
*
|
|
3468
|
+
* ```js
|
|
3469
|
+
* // ATTACH mode — connect to a Lightpanda instance you manage yourself (remote host, container, etc.)
|
|
3470
|
+
* {
|
|
3471
|
+
* helpers: {
|
|
3472
|
+
* Lightpanda: {
|
|
3473
|
+
* url: 'http://localhost',
|
|
3474
|
+
* endpoint: 'http://127.0.0.1:9222',
|
|
3475
|
+
* }
|
|
3476
|
+
* }
|
|
3477
|
+
* }
|
|
3478
|
+
* ```
|
|
3479
|
+
*
|
|
3480
|
+
* ## Methods
|
|
3481
|
+
*/
|
|
3482
|
+
class LightpandaTs {
|
|
3483
|
+
constructor(config: LightpandaConfig);
|
|
3484
|
+
}
|
|
3485
|
+
/**
|
|
3486
|
+
* ## Configuration
|
|
3487
|
+
*
|
|
3488
|
+
* This helper should be configured in codecept.conf.js
|
|
3489
|
+
* @property [endpoint] - connect to a running Obscura instead of starting one (ATTACH mode).
|
|
3490
|
+
* @property [binaryPath] - path to the `obscura` executable. Checked before `OBSCURA_PATH` and `PATH`.
|
|
3491
|
+
* @property [port] - port for `obscura serve`. A free port is picked when unset, so parallel workers never collide.
|
|
3492
|
+
* @property [serverStartTimeout = 15000] - how long to wait for `obscura serve` to start, in milliseconds.
|
|
3493
|
+
*/
|
|
3494
|
+
type ObscuraConfig = {
|
|
3495
|
+
endpoint?: string;
|
|
3496
|
+
binaryPath?: string;
|
|
3497
|
+
port?: number;
|
|
3498
|
+
serverStartTimeout?: number;
|
|
3499
|
+
};
|
|
3500
|
+
/**
|
|
3501
|
+
* Obscura drives [Obscura](https://github.com/h4ckf0r0day/obscura), a lightweight headless
|
|
3502
|
+
* browser controlled over the Chrome DevTools Protocol. Default builds from v0.2.0 render pages
|
|
3503
|
+
* (layout, screenshots); `-no-render` builds and v0.1.x run JavaScript and the DOM only. The helper
|
|
3504
|
+
* detects which build it runs against, so the same config works for both.
|
|
3505
|
+
*
|
|
3506
|
+
* The helper starts and stops `obscura serve` for you, the same way Playwright manages its browser.
|
|
3501
3507
|
*
|
|
3502
3508
|
* > Obscura support is experimental in CodeceptJS 4.2. Pin the browser version in CI and keep a
|
|
3503
3509
|
* > Playwright/WebDriver job for browser-compatibility coverage.
|
|
@@ -3517,8 +3523,8 @@ declare namespace CodeceptJS {
|
|
|
3517
3523
|
* - **SELF-LAUNCH** — `endpoint` is unset and a binary can be resolved, in order: `binaryPath` in
|
|
3518
3524
|
* the config, then the `OBSCURA_PATH` environment variable, then `obscura` on `PATH`. The helper
|
|
3519
3525
|
* spawns `obscura serve --port <port> --allow-private-network --allow-file-access` (`port` from
|
|
3520
|
-
* the config, or a free port picked automatically), waits for it to answer, connects, and
|
|
3521
|
-
* it
|
|
3526
|
+
* the config, or a free port picked automatically), waits for it to answer, connects, and stops
|
|
3527
|
+
* it when tests finish.
|
|
3522
3528
|
* - **COURTESY-ATTACH** — `endpoint` is unset and no binary can be resolved, but something already
|
|
3523
3529
|
* answers `http://127.0.0.1:9222/json/version` (e.g. `obscura serve` started by hand, or by CI
|
|
3524
3530
|
* before this process ever ran). The helper attaches to it and never kills it — it isn't the
|
|
@@ -3557,13 +3563,11 @@ declare namespace CodeceptJS {
|
|
|
3557
3563
|
*
|
|
3558
3564
|
* | option | value | why |
|
|
3559
3565
|
* | --- | --- | --- |
|
|
3560
|
-
* | `input` | `synthetic` |
|
|
3561
|
-
* | `xpathPolyfill` | `auto` |
|
|
3566
|
+
* | `input` | `synthetic` | clicks that navigate are unreliable in Obscura, so `click` behaves like `forceClick` |
|
|
3567
|
+
* | `xpathPolyfill` | `auto` | Obscura's XPath lacks attribute selection and `not()`, so the polyfill is used when needed |
|
|
3562
3568
|
*
|
|
3563
|
-
* `capabilities
|
|
3564
|
-
*
|
|
3565
|
-
* (`'real'`/`true` on v0.2.0+ default builds, `'none'`/`false` on `-no-render` builds and v0.1.x).
|
|
3566
|
-
* Set them explicitly in your own config to skip probing or to force a mode.
|
|
3569
|
+
* `capabilities` are detected at runtime from the Obscura build. Set them in your config to skip
|
|
3570
|
+
* detection or to force a mode.
|
|
3567
3571
|
*
|
|
3568
3572
|
* ## Limitations
|
|
3569
3573
|
*
|
|
@@ -3610,62 +3614,6 @@ declare namespace CodeceptJS {
|
|
|
3610
3614
|
*/
|
|
3611
3615
|
class ObscuraTs {
|
|
3612
3616
|
constructor(config: ObscuraConfig);
|
|
3613
|
-
/**
|
|
3614
|
-
* In ATTACH mode, connects exactly as `CDPBrowser._connect` would. In SELF-MANAGED mode,
|
|
3615
|
-
* resolves and spawns `obscura serve` (or courtesy-attaches to an already-running one on
|
|
3616
|
-
* :9222) exactly once via `_resolveSelfManaged`, then connects.
|
|
3617
|
-
*
|
|
3618
|
-
* A spawn failure (e.g. a bad binary) is delivered asynchronously by Node as an `error`
|
|
3619
|
-
* event; it is recorded on `this.serverError` and surfaced as a rejection from `_waitForServer`
|
|
3620
|
-
* instead of crashing the process as an uncaught exception.
|
|
3621
|
-
*/
|
|
3622
|
-
protected _connect(): Promise<any>;
|
|
3623
|
-
/**
|
|
3624
|
-
* Resolves how to reach Obscura when no explicit `endpoint` was configured, trying, in order:
|
|
3625
|
-
* spawn a binary (`binaryPath` config, then `OBSCURA_PATH` env, then `obscura` on `PATH`),
|
|
3626
|
-
* courtesy-attach to `http://127.0.0.1:9222` if something already answers there, or throw a
|
|
3627
|
-
* loud, actionable error. Sets `this.options.endpoint` as a side effect.
|
|
3628
|
-
*/
|
|
3629
|
-
protected _resolveSelfManaged(): Promise<any>;
|
|
3630
|
-
/**
|
|
3631
|
-
* Resolves the `obscura` binary to spawn, in priority order: `options.binaryPath`, then the
|
|
3632
|
-
* `OBSCURA_PATH` environment variable, then `obscura` on `PATH`. The `PATH` lookup walks the
|
|
3633
|
-
* directories itself instead of shelling out to `which`, which does not exist on Windows: on
|
|
3634
|
-
* Windows every `PATHEXT` suffix is tried, so an `obscura.exe` on `PATH` is found too.
|
|
3635
|
-
*/
|
|
3636
|
-
protected _resolveBinary(): Promise<any>;
|
|
3637
|
-
/**
|
|
3638
|
-
* Picks a free TCP port on 127.0.0.1 by briefly listening on port 0 and reading back the OS-assigned
|
|
3639
|
-
* port. Used as the SELF-LAUNCH default when `options.port` isn't explicitly set, so multiple
|
|
3640
|
-
* `run-workers` workers never collide on the same port.
|
|
3641
|
-
* @returns a free port.
|
|
3642
|
-
*/
|
|
3643
|
-
protected _findFreePort(): Promise<number>;
|
|
3644
|
-
/**
|
|
3645
|
-
* Probes a `/json/version`-style URL with a short timeout, used for the COURTESY-ATTACH check.
|
|
3646
|
-
* @returns true if the URL answered.
|
|
3647
|
-
*/
|
|
3648
|
-
protected _probeUp(url: string): Promise<boolean>;
|
|
3649
|
-
/**
|
|
3650
|
-
* Polls `http://127.0.0.1:<port>/json/version` until `obscura serve` responds, `this.serverError`
|
|
3651
|
-
* is set by the spawned process' `error` event, or `options.serverStartTimeout` elapses. The
|
|
3652
|
-
* process typically comes up within tens of milliseconds — a 20ms retry interval (down from a
|
|
3653
|
-
* previous 200ms) keeps the wasted tail after the server is actually ready small, since this cost
|
|
3654
|
-
* is paid once per run and counts directly toward real-world startup latency.
|
|
3655
|
-
*/
|
|
3656
|
-
protected _waitForServer(): Promise<any>;
|
|
3657
|
-
/**
|
|
3658
|
-
* Closes the CDP connection (via `CDPBrowser._finishTest`), then kills the `obscura serve`
|
|
3659
|
-
* process spawned by `_connect`, if any (never runs in ATTACH or COURTESY-ATTACH mode, since
|
|
3660
|
-
* `this.serverProcess` is only ever set in SELF-LAUNCH mode). Runs in a `finally` so the process
|
|
3661
|
-
* is always reaped even if closing the CDP connection throws. Sends `SIGTERM` first and waits for
|
|
3662
|
-
* the process to exit; a process that ignores `SIGTERM` is escalated to `SIGKILL` after 5s. The
|
|
3663
|
-
* promise only resolves once the child has actually exited (confirmed via the `exit` event, not
|
|
3664
|
-
* merely once `SIGKILL` was sent — the kernel needs a moment to reap it), with a final safety-net
|
|
3665
|
-
* timeout so a stuck child can never keep the event loop alive even if that confirmation is
|
|
3666
|
-
* somehow lost.
|
|
3667
|
-
*/
|
|
3668
|
-
protected _finishTest(): Promise<any>;
|
|
3669
3617
|
}
|
|
3670
3618
|
/**
|
|
3671
3619
|
* ## Configuration
|