codeceptjs 4.2.0-beta.4 → 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.
Files changed (65) hide show
  1. package/README.md +2 -0
  2. package/bin/codecept.js +11 -0
  3. package/docs/agents.md +26 -1
  4. package/docs/ai.md +57 -0
  5. package/docs/alternative-browsers.md +175 -148
  6. package/docs/assertions.md +74 -0
  7. package/docs/bootstrap.md +2 -0
  8. package/docs/commands.md +45 -0
  9. package/docs/configuration.md +37 -0
  10. package/docs/debugging.md +1 -1
  11. package/docs/helpers/ApiDataFactory.md +20 -20
  12. package/docs/helpers/Appium.md +1615 -670
  13. package/docs/helpers/Decision.md +146 -0
  14. package/docs/helpers/GraphQL.md +31 -31
  15. package/docs/helpers/GraphQLDataFactory.md +20 -20
  16. package/docs/helpers/Kitesurf.md +1808 -25
  17. package/docs/helpers/Lightpanda.md +139 -0
  18. package/docs/helpers/Obscura.md +1799 -74
  19. package/docs/helpers/Playwright.md +490 -428
  20. package/docs/helpers/Puppeteer.md +317 -255
  21. package/docs/helpers/REST.md +43 -43
  22. package/docs/helpers/WebDriver.md +237 -175
  23. package/docs/installation.md +16 -0
  24. package/docs/mcp.md +7 -1
  25. package/docs/parallel.md +35 -1
  26. package/docs/plugins/pause.md +2 -1
  27. package/docs/plugins/sitemap.md +48 -0
  28. package/docs/plugins.md +4 -0
  29. package/lib/ai.js +81 -2
  30. package/lib/codecept.js +32 -2
  31. package/lib/command/init.js +22 -0
  32. package/lib/command/initAgent.js +78 -0
  33. package/lib/command/run-multiple.js +3 -0
  34. package/lib/command/run-workers.js +10 -3
  35. package/lib/command/run.js +3 -2
  36. package/lib/command/utils.js +15 -0
  37. package/lib/command/workers/runTests.js +10 -10
  38. package/lib/container.js +4 -2
  39. package/lib/effects.js +19 -1
  40. package/lib/helper/Appium.js +23 -0
  41. package/lib/helper/CDPBrowser.js +387 -1338
  42. package/lib/helper/Decision.js +256 -0
  43. package/lib/helper/Kitesurf.js +3 -21
  44. package/lib/helper/Lightpanda.js +137 -0
  45. package/lib/helper/Obscura.js +21 -238
  46. package/lib/helper/Playwright.js +50 -4
  47. package/lib/helper/Puppeteer.js +62 -8
  48. package/lib/helper/WebDriver.js +45 -1
  49. package/lib/helper/extras/clipboard.js +31 -0
  50. package/lib/listener/result.js +4 -0
  51. package/lib/mocha/bdd.js +19 -1
  52. package/lib/plugin/junitReporter.js +4 -1
  53. package/lib/plugin/pause.js +4 -1
  54. package/lib/plugin/sitemap.js +228 -0
  55. package/lib/recorder.js +19 -18
  56. package/lib/result.js +16 -0
  57. package/lib/step/base.js +12 -0
  58. package/lib/utils.js +2 -10
  59. package/lib/webServer.js +193 -0
  60. package/lib/workers.js +118 -31
  61. package/package.json +4 -2
  62. package/typings/index.d.ts +60 -7
  63. package/typings/promiseBasedTypes.d.ts +985 -814
  64. package/typings/types.d.ts +1084 -815
  65. package/docs/helpers/CDPBrowser.md +0 -2138
@@ -770,6 +770,32 @@ declare namespace CodeceptJS {
770
770
  * @returns Appium: support both Android and iOS
771
771
  */
772
772
  closeApp(): Promise<void>;
773
+ /**
774
+ * Clears the system clipboard.
775
+ *
776
+ * ```js
777
+ * I.clearClipboard();
778
+ * I.seeClipboardEquals('');
779
+ * ```
780
+ */
781
+ clearClipboard(): Promise<any>;
782
+ /**
783
+ * Grabs the text content of the system clipboard and returns it to test.
784
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
785
+ *
786
+ * ```js
787
+ * I.click('Copy to clipboard');
788
+ * let url = await I.grabFromClipboard();
789
+ * ```
790
+ *
791
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
792
+ * in Chromium-based browsers, where read access is granted automatically.
793
+ * @returns the system clipboard contents.
794
+ *
795
+ *
796
+ * Appium: support both Android and iOS
797
+ */
798
+ grabFromClipboard(): Promise<string>;
773
799
  /**
774
800
  * Appends text to a input field or textarea.
775
801
  * Field is located by name, label, CSS or XPath
@@ -1167,16 +1193,16 @@ declare namespace CodeceptJS {
1167
1193
  *
1168
1194
  * This helper should be configured in codecept.conf.js
1169
1195
  * @property [url = http://localhost] - base url of website to be tested.
1170
- * @property [endpoint = http://127.0.0.1:9222] - Chrome DevTools Protocol endpoint. Either an `http(s)://` address exposing `/json/version` (from which the `webSocketDebuggerUrl` is resolved) or a raw `ws(s)://` debugger URL.
1171
- * @property [headers = {}] - headers sent with the endpoint resolution request and the WebSocket handshake. Useful for authenticated remote browser providers.
1172
- * @property [input = auto] - how synthetic user actions (click, fill, etc.) are dispatched by helpers built on top of this class. `auto` picks `cdp` when a real layout engine is detected and `synthetic` otherwise; can be pinned to `cdp` or `synthetic`.
1173
- * @property [xpathPolyfill = auto] - whether to inject the bundled XPath polyfill before installing the in-page client. `auto` probes the page and only injects when `document.evaluate` is unavailable or broken; `true`/`false` force the behavior.
1174
- * @property [capabilities = {}] - pre-seed detected browser capabilities (`layout`, `xpath`, `screenshot`, `innerText`) to skip runtime probing. Values set here are never overwritten by `_probeCapabilities`/`_ensureClient`.
1175
- * @property [waitForTimeout = 5] - default wait* timeout in seconds, used by helpers built on top of this class.
1176
- * @property [waitForAction = 100] - only takes effect when set explicitly: a literal fixed pacing sleep (in milliseconds) after click, type, or other interactions, mirroring other browser helpers. Left unset, actions settle in an event-aware way instead — near-instant when nothing navigates, waiting for the navigation to actually finish (not a guessed fixed delay) when one does.
1177
- * @property [pollInterval = 25] - interval in milliseconds between retries while polling for a condition (e.g. page ready state, `waitFor*`). Distinct from `waitForAction`.
1178
- * @property [getPageTimeout = 30] - maximum time in seconds to wait for a page to finish loading after navigation or reload; also used as the CDP command timeout (in ms, x1000).
1179
- * @property [waitForNavigation = load] - when to consider a navigation finished: `load`, `domcontentloaded`, or `networkidle`. Mirrors the Puppeteer helper's option name. `networkidle` waits for the CDP `networkIdle` lifecycle event, which on a busy page can lag `load` by a second or more — only opt in if the extra wait is actually needed.
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`.
1180
1206
  */
1181
1207
  type CDPBrowserConfig = {
1182
1208
  url?: string;
@@ -1200,6 +1226,8 @@ declare namespace CodeceptJS {
1200
1226
  * script evaluation, and simple in-page element interaction (installed lazily through the
1201
1227
  * `window.__codecept` client script). It does not launch a browser itself — point `endpoint` at an
1202
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`.
1203
1231
  *
1204
1232
  * ## Example
1205
1233
  *
@@ -1222,416 +1250,160 @@ declare namespace CodeceptJS {
1222
1250
  class CDPBrowserTs {
1223
1251
  constructor(config: CDPBrowserConfig);
1224
1252
  /**
1225
- * No-op hook kept for interface parity with other browser helpers. Connecting to the CDP
1226
- * endpoint is deferred to `_before`, since a fresh target/session is opened per test.
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.
1227
1267
  */
1228
- _init(): Promise<any>;
1268
+ protected _manageServer(config: any, server: any): Promise<any>;
1229
1269
  /**
1230
- * Resolves `options.endpoint` to a raw WebSocket debugger URL. If the configured endpoint is
1231
- * an `http(s)://` address, this fetches `/json/version` from it and reads `webSocketDebuggerUrl`
1232
- * from the response, matching the discovery flow exposed by Chrome's `--remote-debugging-port`.
1233
- * A `ws(s)://` endpoint is returned unchanged.
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.
1234
1275
  *
1235
- * This is the subclass override point for helpers that connect through a different discovery
1236
- * mechanism (e.g. a cloud browser provider with its own session-creation API).
1237
- * @returns a `ws(s)://` debugger URL ready to be passed to `CDPConnection`.
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.
1238
1279
  */
1239
- protected _resolveEndpoint(): Promise<string>;
1280
+ protected _resolveSelfManaged(): Promise<any>;
1240
1281
  /**
1241
- * Resolves the CDP endpoint and opens the underlying `CDPConnection`, storing it on `this.cdp`.
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.
1242
1286
  */
1243
- protected _connect(): Promise<any>;
1244
- /**
1245
- * Hook executed before each test. Ensures a live `CDPConnection` exists (connecting lazily on
1246
- * first use, and reconnecting if a previous connection was closed), then creates a fresh
1247
- * `about:blank` target and attaches to it with `Target.attachToTarget`, storing `this.targetId`
1248
- * and `this.sessionId`. `Page` and `Runtime` domains are enabled on the new session, and engine
1249
- * capabilities are probed here (against `about:blank`, uncontended) rather than only lazily on
1250
- * the first real page — see `_probeCapabilities`.
1251
- *
1252
- * Also resets `_navStartWaiters` and `_lastMainFrameNav`: both are scoped to a single
1253
- * `sessionId`/`targetId`, which are about to change, so anything left over from the previous test
1254
- * (e.g. an action-settle waiter still armed because its test threw between arming and settling)
1255
- * can never legitimately resolve against the new session — better to drop it here than leave it
1256
- * waiting for the rest of the run.
1257
- */
1258
- protected _before(): Promise<any>;
1259
- /**
1260
- * Lazily installs a single, persistent `Page.lifecycleEvent` listener on the underlying
1261
- * `CDPConnection` and drains it into whichever `_waitForLoadEvent` calls are currently pending,
1262
- * matched by `loaderId`. Installed once per helper instance (the connection outlives individual
1263
- * tests), never removed — `CDPConnection` has no listener-removal API, so a single persistent
1264
- * dispatcher (rather than one listener per navigation) is what keeps this leak-free.
1265
- *
1266
- * Also, for the main frame (`params.frameId === this.targetId`, which holds for a page target's
1267
- * own top-level frame) only:
1268
- * - Drains `_navStartWaiters` (armed by `_armActionSettle`, before an action, for `_waitForAction`'s
1269
- * event-aware settle) on an `'init'` event — confirmed via a raw probe (against both Obscura and
1270
- * Chrome, through the actual CLI path) to be the earliest signal CDP emits when a new top-level
1271
- * navigation begins. Arming happens *before* the action is dispatched, not after: the same probe
1272
- * found `'init'` can arrive while the action's own CDP round trip is still in flight, sometimes
1273
- * only a millisecond or two after it started — a listener installed only once the action's
1274
- * promise resolves can already be too late, not merely unlucky.
1275
- * - Maintains `_lastMainFrameNav`, a rolling `{loaderId, events}` record of every lifecycle event
1276
- * name seen for the current main-frame navigation (reset whenever `loaderId` changes). On a
1277
- * fast/local navigation, the same raw probe found the *entire* sequence — `init` through
1278
- * `networkIdle` — arriving as one batch while the triggering action's own round trip was still
1279
- * in flight. Without this cache, `_waitForAction` would correctly detect that a navigation
1280
- * started, then arm a *fresh* wait for the `load` event specifically — which, in that common
1281
- * case, had already fired and will never fire again, paying the full grace-window-plus-poll cost
1282
- * of `_waitForPageLoad` on every single navigating action instead of settling immediately.
1283
- */
1284
- protected _ensureLifecycleListener(): Promise<any>;
1285
- /**
1286
- * Starts waiting for a `Page.lifecycleEvent` named `eventName` for the given `loaderId` on the
1287
- * current session. `loaderId` (from the `Page.navigate` response) discriminates the awaited
1288
- * navigation from any other in-flight or stale lifecycle events (e.g. the `about:blank` target
1289
- * created in `_before`), which is essential since Chrome emits the target's initial `about:blank`
1290
- * lifecycle sequence asynchronously, sometimes after this listener is already installed.
1291
- *
1292
- * Returns a `{promise, cancel}` pair rather than a bare promise: `_waitForPageLoad` races this
1293
- * against a readyState poll, and whichever side loses must be actively torn down (not just have
1294
- * its rejection swallowed) — an abandoned-but-still-pending wait would sit in `_pageLoadWaiters`
1295
- * for the full timeout on every single navigation, for no purpose.
1296
- * @param loaderId - the loader id of the navigation to wait for, from `Page.navigate`'s response.
1297
- * @param eventName - the `Page.lifecycleEvent` name to wait for (e.g. `load`, `DOMContentLoaded`, `networkIdle`).
1298
- * @param timeoutSec - maximum time to wait, in seconds.
1299
- */
1300
- protected _waitForLoadEvent(loaderId: string, eventName: string, timeoutSec: number): Promise<any>;
1301
- /**
1302
- * Arms the event-aware settle's navigation-start listener. Must be called *before* the action
1303
- * that might trigger a navigation is dispatched, not after — see `_ensureLifecycleListener` for
1304
- * why. Returns `null` when `options.waitForAction` was set explicitly, since `_waitForAction`
1305
- * ignores the armed listener entirely in that case (a literal fixed sleep, as before this round).
1306
- *
1307
- * No timeout here: `_waitForAction` applies the grace window itself, starting from when *it*
1308
- * runs (after the action's own dispatch already resolved), racing this already-armed listener
1309
- * against a fresh timer instead of one that started ticking before the action even began.
1310
- */
1311
- protected _armActionSettle(): Promise<any>;
1312
- /**
1313
- * Waits for a page to finish loading after `Page.navigate`/`Page.reload`, per `options.waitForNavigation`.
1314
- *
1315
- * Purely event-driven for the first `PAGE_LOAD_GRACE_MS`: only the push-based
1316
- * `Page.lifecycleEvent` signal (matched by `loaderId`) is awaited, issuing zero `_evaluate` calls
1317
- * — this matters because an `_evaluate` sent while the page's own JavaScript is still busy (e.g.
1318
- * a real-world page doing post-load hydration/analytics work) can queue behind it for hundreds of
1319
- * ms to multiple seconds, measured directly against a JS-heavy page. Only if the grace window
1320
- * elapses without the event (an engine that doesn't emit it, or a genuinely slow navigation) does
1321
- * the `document.readyState` poll (via `_poll`) start, racing the still-pending lifecycle wait —
1322
- * both bounded by the same `options.getPageTimeout`, so a lifecycle-less engine costs at most
1323
- * `PAGE_LOAD_GRACE_MS` more than the poll alone would have, never double the timeout. No
1324
- * `loaderId` (e.g. from `Page.reload`, which returns none) skips straight to the poll.
1325
- *
1326
- * Whichever side ultimately loses is actively cancelled, not merely abandoned — an abandoned poll
1327
- * or lifecycle wait would otherwise keep running (issuing readyState `_evaluate` calls every
1328
- * `pollInterval`, or holding a `_pageLoadWaiters` entry) for up to the full timeout on every
1329
- * navigation, competing for the same CDP connection with real work.
1330
- * @param loaderId - loader id from the triggering `Page.navigate` response, if any.
1331
- * @param timeoutMessage - error message used if the readyState poll times out.
1332
- */
1333
- protected _waitForPageLoad(loaderId: string | null, timeoutMessage: string): Promise<void>;
1334
- /**
1335
- * Hook executed after each test. Closes the target opened in `_before` via `Target.closeTarget`
1336
- * and clears `this.targetId`/`this.sessionId`. The underlying `CDPConnection` is left open so it
1337
- * can be reused by the next test.
1338
- */
1339
- protected _after(): Promise<any>;
1287
+ protected _resolveBinary(): Promise<any>;
1340
1288
  /**
1341
- * Hook executed after all tests are run. Closes the underlying `CDPConnection` (and its
1342
- * WebSocket) and clears `this.cdp`. Must leave no open sockets or pending timers behind, so the
1343
- * process can exit on its own.
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.
1344
1293
  */
1345
- protected _finishTest(): Promise<any>;
1294
+ protected _findFreePort(): Promise<number>;
1346
1295
  /**
1347
- * Evaluates a JavaScript expression in the page attached to the current session via
1348
- * `Runtime.evaluate`, awaiting any returned promise and returning the value by reference
1349
- * (`returnByValue: true`). If the expression throws, the browser-side exception description
1350
- * (or fallback text) is re-thrown as a JS `Error`.
1351
- * @param expression - a JavaScript expression (or IIFE) to run in the page context.
1352
- * @returns the evaluated value, or `undefined` if the expression has no result.
1353
- */
1354
- protected _evaluate(expression: string): Promise<any>;
1355
- /**
1356
- * Ensures the in-page client (`window.__codecept`, installed from `cdpBrowserClient.js`) is
1357
- * present on the current page, installing it (and the XPath polyfill, if needed) exactly once.
1358
- * Safe to call repeatedly; it is a no-op once the client is detected.
1359
- */
1360
- protected _ensureClient(): Promise<any>;
1361
- /**
1362
- * Installs the in-page client unconditionally — no `typeof window.__codecept` presence check.
1363
- * Used by callers that already know, from a sentinel value returned alongside a failed action,
1364
- * that the client is missing on the current page, so re-checking would just be a redundant
1365
- * contended round trip.
1366
- *
1367
- * The 171KB XPath polyfill is only injected alongside the client when `needsXPath` is true (the
1368
- * default, for callers without candidate information) *and* the engine actually needs it
1369
- * (`capabilities.xpath === 'polyfill'`, cached from `_before`'s probe). Callers that know their
1370
- * candidates never resolve to an `xpath` strategy (e.g. `_runSelected`, once it has inspected
1371
- * `candidates`/`within`) can pass `false` to skip that inject — the client is still told, via the
1372
- * `xpathNeedsPolyfill` flag baked in at install time, that the *engine* will eventually need it,
1373
- * so a later call that does hit an xpath candidate gets a clean `'__NO_XPATH__'` miss signal
1374
- * (from `window.__codecept.run`) instead of silently falling through to a broken native
1375
- * `document.evaluate` — `_runSelected` reacts to that sentinel by injecting the polyfill and
1376
- * retrying once, mirroring the `'__NO_CLIENT__'` handling right next to it.
1377
- */
1378
- protected _installClient(needsXPath?: boolean): Promise<any>;
1379
- /**
1380
- * Whether any candidate strategy — in `candidates` itself, or in any of the `within` scoping
1381
- * `layers` searched before it — is an `xpath` locator. Used to decide, before the client is even
1382
- * installed, whether the XPath polyfill needs to be bundled into that install or can be deferred.
1383
- */
1384
- protected _candidatesNeedXPath(candidates: { type: string; value: string; }[], layers: { type: string; value: string; }[][]): Promise<any>;
1385
- /**
1386
- * Determines whether the bundled XPath polyfill must be injected before the in-page client is
1387
- * installed. Honors an explicit `options.xpathPolyfill` boolean; otherwise reuses a previously
1388
- * probed `capabilities.xpath`, or probes the page's native `document.evaluate`. The probe appends
1389
- * two throwaway elements distinguished only by text content and asserts that a text-value XPath
1390
- * predicate (`normalize-space(string(.))=...`, the basis of every fuzzy/clickable locator) resolves
1391
- * to exactly the matching one — merely checking that `document.evaluate` runs without throwing is
1392
- * not enough, since some engines execute a text-value predicate without actually filtering by it,
1393
- * silently returning every candidate node instead of none or one. The result is cached on
1394
- * `capabilities.xpath` (`'native'` or `'polyfill'`).
1395
- * @returns `true` if the polyfill should be injected.
1396
- */
1397
- protected _needsXPathPolyfill(): Promise<boolean>;
1398
- /**
1399
- * Determines whether `see`/`dontSee`/`waitForText` should read whole-page text through the
1400
- * client's own visibility-aware `visibleText()` walker instead of the native
1401
- * `document.body.innerText`. Probes once per page by appending a `display:none` element and a
1402
- * `<script>` element, each with distinguishing text, and checking that native `innerText`
1403
- * excludes both — some engines return an `innerText` that does not honor computed visibility or
1404
- * exclude script/style content, even when `getComputedStyle`/layout are otherwise reliable. The
1405
- * result is cached on `capabilities.innerText` (`'native'` or `'computed'`).
1406
- * @returns `true` if the `visibleText()` fallback should be used.
1407
- */
1408
- protected _needsVisibleTextFallback(): Promise<boolean>;
1409
- /**
1410
- * Probes and caches capabilities that depend on the actual browser *engine* rather than any
1411
- * particular page's content: `capabilities.layout` (via `getComputedStyle`), `capabilities.screenshot`
1412
- * (inferred from `layout`), `capabilities.xpath` (via `_needsXPathPolyfill`), and
1413
- * `capabilities.innerText` (via `_needsVisibleTextFallback`). Already-known capabilities
1414
- * (pre-seeded through `options.capabilities`, or probed earlier) are never re-probed — so, across
1415
- * a whole run, this issues a handful of `_evaluate` calls exactly once and is a no-op afterward.
1416
- *
1417
- * Called from `_before`, against the fresh `about:blank` target created there, specifically so
1418
- * these probes run before any real navigation — measured directly (a full stall ledger against
1419
- * `github.com`) that running them on the first *real* page instead can cost seconds each, since
1420
- * every one is an `_evaluate` competing with that page's own JavaScript for the V8 isolate.
1421
- * `about:blank` has no such competition. Also called (cheaply, already cached by then) from
1422
- * `amOnPage`, so a helper that skips `_before` for some reason still probes correctly.
1423
- *
1424
- * The `xpath`/`innerText` probes determine *whether* their respective fallback is needed; they
1425
- * do not install anything — injection stays deferred to `_ensureClient`'s reactive install and
1426
- * `_textSource`'s own read, matching `amOnPage` no longer eagerly installing the client.
1427
- */
1428
- protected _probeCapabilities(): Promise<any>;
1429
- /**
1430
- * Delegates a find-and-act call to `window.__codecept.run(candidates, action, payload)`. This is
1431
- * the primary extension point used by helpers built on top of this class for element queries and
1432
- * interactions.
1433
- *
1434
- * A per-call `context` locator, when given, is resolved and layered on top of any active
1435
- * `within` block (searched inside it, not instead of it), so `context` narrows the search
1436
- * without breaking out of a surrounding `within`.
1437
- * @param candidates - locator strategies to try, in order, until one matches at least one element.
1438
- * @param action - name of the action to run against the matched elements (e.g. `count`, `click`, `fill`).
1439
- * @param [payload] - extra data the action needs (e.g. `{ value }` for `fill`).
1440
- * @param [context = null] - element to search in, narrowing the candidates below it.
1441
- * @returns number of matched elements and the action's result.
1442
- */
1443
- protected _run(candidates: { type: 'css' | 'xpath'; value: string; }[], action: string, payload?: any, context?: CodeceptJS.LocatorOrString): Promise<{ found: number; result: any; }>;
1444
- /**
1445
- * Same as `_run`, but takes an explicit selection descriptor instead of reading one from
1446
- * `store.currentStep`/`options.strict`. Used internally by `CDPElementHandle` to address one
1447
- * specific element out of a candidate set by its 1-based index.
1448
- *
1449
- * The in-page client's presence is checked in the same round-trip as the action itself: the
1450
- * evaluated expression resolves to a sentinel string when `window.__codecept` is missing (e.g.
1451
- * right after a navigation the registered script didn't reach), in which case the client is
1452
- * installed and the call is retried exactly once. Separately, if the client is already present
1453
- * but reports (via its own `'__NO_XPATH__'` sentinel) that this call needs the XPath polyfill and
1454
- * it was not bundled into that earlier install, the polyfill is injected and the call is retried
1455
- * once more — see `_installClient`.
1456
- * @param selection - `{index}` or `{strict: true}`, mirroring `_selectionDescriptor`.
1457
- */
1458
- protected _runSelected(candidates: { type: 'css' | 'xpath'; value: string; }[], action: string, payload: any | null, selection: any | null, context?: CodeceptJS.LocatorOrString): Promise<{ found: number; result: any; }>;
1459
- /**
1460
- * Builds the `{index, strict}` element-selection descriptor from the current step's options
1461
- * (`store.currentStep.opts`) and `options.strict`, mirroring the semantics of
1462
- * `lib/helper/extras/elementSelection.js` (used by Puppeteer/WebDriver): a per-step
1463
- * `elementIndex` (numeric, or the `'first'`/`'last'` aliases) always takes precedence and
1464
- * disables strict mode for that step; otherwise `exact`/`strictMode` per-step options
1465
- * override `options.strict` to enable or cancel strict mode.
1466
- */
1467
- protected _selectionDescriptor(): Promise<any>;
1468
- /**
1469
- * A short, human-readable label built from `candidates`, used in `_run`'s elementIndex/strict
1470
- * error messages when no locator string is otherwise available.
1471
- */
1472
- protected _candidatesLabel(candidates: { type: 'css' | 'xpath'; value: string; }[]): Promise<any>;
1473
- /**
1474
- * Starts a `within` block, scoping every subsequent `_run` call (and therefore every element
1475
- * lookup performed by this helper) to the descendants of the element matched by `locator`.
1476
- * Verifies the element exists (against the full document, i.e. unscoped) before narrowing.
1477
- * @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.
1478
1298
  */
1479
- _withinBegin(locator: CodeceptJS.LocatorOrString): Promise<void>;
1299
+ protected _probeUp(url: string): Promise<boolean>;
1480
1300
  /**
1481
- * Ends the current `within` block, restoring unscoped element lookups.
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.
1482
1306
  */
1483
- _withinEnd(): Promise<void>;
1307
+ protected _waitForServer(): Promise<any>;
1484
1308
  /**
1485
- * Repeatedly calls `fn` until it returns a truthy value or `timeoutSec` elapses, checking
1486
- * immediately and waiting `options.pollInterval` milliseconds between subsequent attempts.
1487
- * @param fn - the condition to poll; should resolve to a truthy value once satisfied.
1488
- * @param timeoutSec - maximum time to poll, in seconds.
1489
- * @param message - error message used when the timeout is reached.
1490
- * @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.
1491
- * @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`.
1492
1312
  */
1493
- protected _poll(fn: (...params: any[]) => any, timeoutSec: number, message: string, cancelToken?: any): Promise<any>;
1313
+ protected _connect(): Promise<any>;
1494
1314
  /**
1495
- * Resolves a path against `options.url`. Absolute URLs (matching `scheme://`) are returned
1496
- * unchanged; anything else is appended to `options.url` with its trailing slash stripped.
1497
- * @param path - an absolute URL or a path relative to `options.url`.
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.
1498
1326
  */
1499
- protected _url(path: string): Promise<any>;
1327
+ protected _finishTest(): Promise<any>;
1500
1328
  /**
1501
- * Opens a web page in the current session.
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.
1502
1331
  *
1503
1332
  * ```js
1504
1333
  * I.amOnPage('/'); // opens main page of website
1505
1334
  * I.amOnPage('https://github.com'); // opens github
1506
1335
  * I.amOnPage('/login'); // opens a login page
1507
1336
  * ```
1508
- *
1509
- * Navigates via `Page.navigate`, then waits (up to `options.getPageTimeout` seconds) for the page
1510
- * to finish loading, preferring the push-based `Page.lifecycleEvent` signal (per
1511
- * `options.waitForNavigation`) over polling `document.readyState`. Capabilities are (re-)probed
1512
- * (a no-op after the first page, since they're cached for the helper's lifetime).
1513
- *
1514
- * The in-page client is deliberately *not* eagerly (re-)installed here — navigation discards any
1515
- * previously injected script, but installing it is deferred to the first actual action after
1516
- * this call, via `_runSelected`'s sentinel-and-retry. This keeps `amOnPage` itself down to the
1517
- * navigate command plus the push-based wait: no `_evaluate` call is issued on this hot path,
1518
- * which matters most right when the page's own JavaScript may still be busy (measured directly:
1519
- * an `_evaluate` sent in that window can queue behind it for hundreds of ms to multiple seconds
1520
- * on a JS-heavy real-world page, regardless of how small the evaluated expression is).
1521
1337
  * @param url - url path or global url.
1522
1338
  */
1523
- amOnPage(url: string): Promise<void>;
1339
+ amOnPage(url: string): Promise<any>;
1524
1340
  /**
1525
- * Reloads the current page.
1341
+ * Reload the current page.
1526
1342
  *
1527
1343
  * ```js
1528
1344
  * I.refreshPage();
1529
1345
  * ```
1530
- *
1531
- * Triggers `Page.reload` and waits (up to `options.getPageTimeout` seconds) for
1532
- * `document.readyState` to reach `'complete'`.
1533
1346
  */
1534
- refreshPage(): Promise<void>;
1347
+ refreshPage(): Promise<any>;
1535
1348
  /**
1536
- * Executes a JavaScript function in the browser context and returns its result.
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.
1537
1353
  *
1538
- * If a function is passed, it is serialized with `Function.prototype.toString()`, so it must
1539
- * not reference variables from the outer (Node.js) scope — pass any needed data as arguments
1540
- * instead. A string is evaluated as-is.
1354
+ * Example with jQuery DatePicker:
1541
1355
  *
1542
1356
  * ```js
1543
- * let title = await I.executeScript(() => document.title);
1544
- * let sum = await I.executeScript((a, b) => a + b, 2, 3);
1357
+ * // change date of jQuery DatePicker
1358
+ * I.executeScript(function() {
1359
+ * // now we are inside browser context
1360
+ * $('date').datetimepicker('setDate', new Date());
1361
+ * });
1545
1362
  * ```
1363
+ * Can return values. Don't forget to use `await` to get them.
1546
1364
  *
1547
- * If the function returns a promise, `executeScript` waits for it to resolve.
1548
- * @param fn - a JavaScript function to be executed in the browser context, or a string expression.
1549
- * @param args - arguments to pass into the function.
1550
- * @returns the value returned (or resolved) by the function.
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
1551
1374
  */
1552
1375
  executeScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
1553
1376
  /**
1554
- * Retrieves the page URL of the current page.
1377
+ * Get current URL from browser.
1378
+ * Resumes test execution, so should be used inside an async function.
1555
1379
  *
1556
1380
  * ```js
1557
1381
  * let url = await I.grabCurrentUrl();
1558
1382
  * console.log(`Current URL is [${url}]`);
1559
1383
  * ```
1560
- * @returns current URL.
1384
+ * @returns current URL
1561
1385
  */
1562
1386
  grabCurrentUrl(): Promise<string>;
1563
1387
  /**
1564
- * 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.
1565
1390
  *
1566
1391
  * ```js
1567
1392
  * let title = await I.grabTitle();
1568
1393
  * ```
1569
- * @returns title of the page.
1394
+ * @returns title
1570
1395
  */
1571
1396
  grabTitle(): Promise<string>;
1572
1397
  /**
1573
- * Retrieves the source code of the current page.
1398
+ * Retrieves page source and returns it to test.
1399
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
1574
1400
  *
1575
1401
  * ```js
1576
1402
  * let pageSource = await I.grabSource();
1577
1403
  * ```
1578
- * @returns source code of the current page (the outer HTML of `<html>`).
1404
+ * @returns source code
1579
1405
  */
1580
1406
  grabSource(): Promise<string>;
1581
- /**
1582
- * Builds the list of `{type, value}` candidates `_run` should try, in order, for a given
1583
- * locator and `kind`. A strict locator (CSS/XPath/object form) resolves to a single candidate.
1584
- * A fuzzy (plain-text) locator is expanded into a strategy-specific list of XPath expressions
1585
- * mirroring the click/field/checkbox matching used by other browser helpers (matching by
1586
- * visible text, label, name, placeholder, ARIA attributes, etc.), falling back to treating the
1587
- * raw text as a CSS selector.
1588
- *
1589
- * A role locator (`{role, text, exact}`) resolves to a single `role`-type candidate, resolved
1590
- * in-page by the client's implicit ARIA role mapping (native elements) plus explicit `role`
1591
- * attributes, filtered by accessible name/text when `text` is given.
1592
- * @param locator - element located by CSS|XPath|strict locator, or plain fuzzy text.
1593
- * @param [kind = 'element'] - matching strategy to use when `locator` is fuzzy.
1594
- */
1595
- protected _candidates(locator: CodeceptJS.LocatorOrString, kind?: 'element' | 'clickable' | 'field' | 'checkable'): Promise<any>;
1596
- /**
1597
- * Resolves the text to search `see`/`dontSee`/`waitForText` against, when no explicit `context`
1598
- * locator is given. An explicit `context` is always resolved through `_run`, so it is implicitly
1599
- * scoped to the active `within` block, if any. Without a `context`, this reads the `within` root's
1600
- * text when a `within` block is active, or the whole page's text otherwise — via native
1601
- * `document.body.innerText`, or the client's `visibleText()` walker when
1602
- * `_needsVisibleTextFallback` determines native `innerText` is not trustworthy.
1603
- */
1604
- protected _textSource(context: CodeceptJS.LocatorOrString): Promise<string>;
1605
- /**
1606
- * Runs the in-page `containsText` check against the whole page (no `context`/`within` scoping —
1607
- * those stay on `_textSource`'s per-element path, already small). Returns only `{found, snippet}`
1608
- * instead of the full haystack: on a page with a large body, serializing that whole string across
1609
- * the CDP wire (and, on engines where `capabilities.innerText` requires the `visibleText()`
1610
- * walker, holding it in memory) is avoidable work `see`/`dontSee`/`waitForText` don't actually
1611
- * need on their common, non-throwing path.
1612
- *
1613
- * Also folds the client's install into the very same round trip when it is still missing, instead
1614
- * of a separate presence-check evaluate followed by an install evaluate before the check itself
1615
- * can even run — mirroring `_runSelected`'s sentinel-retry design, but collapsed into one evaluate
1616
- * since the install source itself is known and cacheable up front. That install is client-only,
1617
- * never the 171KB XPath polyfill: `containsText` never calls `document.evaluate`, so bundling it
1618
- * here would be pure waste for a scenario that never resolves an xpath locator. The client is
1619
- * still told, via `installCodeceptClient`'s `xpathNeedsPolyfill` flag, whether the *engine*
1620
- * (`capabilities.xpath`, cached by `_before`'s `about:blank` probe) will eventually need it, so a
1621
- * later xpath-resolving action on the same page gets a clean `'__NO_XPATH__'` miss signal from
1622
- * `window.__codecept.run` instead of silently hitting a broken native `document.evaluate` —
1623
- * `_runSelected` reacts to that sentinel already. The bootstrap source is built once and reused
1624
- * for the life of the instance, since whether the engine needs the polyfill never changes.
1625
- */
1626
- protected _runTextCheck(text: string, opts: any): Promise<{ found: boolean; snippet: string | null; }>;
1627
- /**
1628
- * Shared implementation for `see`/`dontSee`. Without a `context` locator and outside any `within`
1629
- * block, checks presence via `_runTextCheck`'s fast, boolean-only round trip; the full haystack is
1630
- * only fetched (one extra, rare evaluate) when the assertion is about to fail, to build the same
1631
- * `stringIncludes` error as before this optimization. With a `context` or inside `within`, this is
1632
- * unchanged from before — already a small, per-element read, not the identified cost.
1633
- */
1634
- protected _checkText(text: string, context: CodeceptJS.LocatorOrString, negate: boolean): Promise<void>;
1635
1407
  /**
1636
1408
  * Checks that a page contains a visible text.
1637
1409
  * Use context parameter to narrow down the search.
@@ -1644,7 +1416,7 @@ declare namespace CodeceptJS {
1644
1416
  * @param text - expected on page.
1645
1417
  * @param [context = null] - (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
1646
1418
  */
1647
- see(text: string, context?: CodeceptJS.LocatorOrString): Promise<void>;
1419
+ see(text: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
1648
1420
  /**
1649
1421
  * Opposite to `see`. Checks that a text is not present on a page.
1650
1422
  * Use context parameter to narrow down the search.
@@ -1654,9 +1426,9 @@ declare namespace CodeceptJS {
1654
1426
  * I.dontSee('Login', '.nav'); // no login inside .nav element
1655
1427
  * ```
1656
1428
  * @param text - which is not present.
1657
- * @param [context = null] - (optional) element located by CSS|XPath|strict locator in which to perform search.
1429
+ * @param [context = null] - (optional) element located by CSS|XPath|strict locator in which to perfrom search.
1658
1430
  */
1659
- dontSee(text: string, context?: CodeceptJS.LocatorOrString): Promise<void>;
1431
+ dontSee(text: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
1660
1432
  /**
1661
1433
  * Checks that the current page contains the given string in its raw source code.
1662
1434
  *
@@ -1665,12 +1437,16 @@ declare namespace CodeceptJS {
1665
1437
  * ```
1666
1438
  * @param text - value to check.
1667
1439
  */
1668
- seeInSource(text: string): Promise<void>;
1440
+ seeInSource(text: string): Promise<any>;
1669
1441
  /**
1670
- * Checks that the current page does not contain the given string in its raw source code.
1671
- * @param text - value to check.
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.
1672
1448
  */
1673
- dontSeeInSource(text: string): Promise<void>;
1449
+ dontSeeInSource(value: string): Promise<any>;
1674
1450
  /**
1675
1451
  * Checks that current url contains a provided fragment.
1676
1452
  *
@@ -1679,12 +1455,12 @@ declare namespace CodeceptJS {
1679
1455
  * ```
1680
1456
  * @param url - a fragment to check
1681
1457
  */
1682
- seeInCurrentUrl(url: string): Promise<void>;
1458
+ seeInCurrentUrl(url: string): Promise<any>;
1683
1459
  /**
1684
1460
  * Checks that current url does not contain a provided fragment.
1685
1461
  * @param url - value to check.
1686
1462
  */
1687
- dontSeeInCurrentUrl(url: string): Promise<void>;
1463
+ dontSeeInCurrentUrl(url: string): Promise<any>;
1688
1464
  /**
1689
1465
  * Checks that title contains text.
1690
1466
  *
@@ -1693,9 +1469,9 @@ declare namespace CodeceptJS {
1693
1469
  * ```
1694
1470
  * @param text - text value to check.
1695
1471
  */
1696
- seeInTitle(text: string): Promise<void>;
1472
+ seeInTitle(text: string): Promise<any>;
1697
1473
  /**
1698
- * Checks that a given Element is present in the DOM.
1474
+ * Checks that a given Element is present in the DOM
1699
1475
  * Element is located by CSS or XPath.
1700
1476
  *
1701
1477
  * ```js
@@ -1703,43 +1479,47 @@ declare namespace CodeceptJS {
1703
1479
  * ```
1704
1480
  * @param locator - element located by CSS|XPath|strict locator.
1705
1481
  */
1706
- seeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<void>;
1482
+ seeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<any>;
1707
1483
  /**
1708
1484
  * Opposite to `seeElementInDOM`. Checks that element is not on page.
1709
1485
  *
1710
1486
  * ```js
1711
1487
  * I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
1712
1488
  * ```
1713
- * @param locator - located by CSS|XPath|strict locator.
1714
- */
1715
- dontSeeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<void>;
1716
- /**
1717
- * Throws if the current page has no real layout engine (`capabilities.layout === 'none'`),
1718
- * used to guard visibility-dependent assertions that cannot be evaluated without one.
1719
- * @param action - name of the calling assertion, used in the error message.
1489
+ * @param locator - located by CSS|XPath|Strict locator.
1720
1490
  */
1721
- protected _assertLayoutSupported(action: string): Promise<any>;
1491
+ dontSeeElementInDOM(locator: CodeceptJS.LocatorOrString): Promise<any>;
1722
1492
  /**
1723
- * Checks that a given Element is visible.
1493
+ * Checks that a given Element is visible
1724
1494
  * Element is located by CSS or XPath.
1725
1495
  *
1496
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
1497
+ *
1726
1498
  * ```js
1727
1499
  * I.seeElement('#modal');
1500
+ * I.seeElement('#modal', '#container');
1501
+ * // using ARIA role locator
1502
+ * I.seeElement({role: 'dialog'});
1728
1503
  * ```
1504
+ *
1505
+ * > ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators](/locators#aria-locators).
1729
1506
  * @param locator - located by CSS|XPath|strict locator.
1730
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1507
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
1731
1508
  */
1732
- seeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1509
+ seeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
1733
1510
  /**
1734
- * 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.
1735
1514
  *
1736
1515
  * ```js
1737
1516
  * I.dontSeeElement('.modal'); // modal is not shown
1517
+ * I.dontSeeElement('.modal', '#container');
1738
1518
  * ```
1739
- * @param locator - located by CSS|XPath|strict locator.
1740
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1519
+ * @param locator - located by CSS|XPath|Strict locator.
1520
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
1741
1521
  */
1742
- dontSeeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1522
+ dontSeeElement(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
1743
1523
  /**
1744
1524
  * Verifies that the specified checkbox is checked.
1745
1525
  *
@@ -1748,19 +1528,20 @@ declare namespace CodeceptJS {
1748
1528
  * I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1749
1529
  * I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1750
1530
  * ```
1751
- * @param locator - located by label|name|CSS|XPath|strict locator.
1531
+ * @param field - located by label|name|CSS|XPath|strict locator.
1752
1532
  */
1753
- seeCheckboxIsChecked(locator: CodeceptJS.LocatorOrString): Promise<void>;
1533
+ seeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): Promise<any>;
1754
1534
  /**
1755
1535
  * Verifies that the specified checkbox is not checked.
1756
1536
  *
1757
1537
  * ```js
1758
1538
  * I.dontSeeCheckboxIsChecked('#agree'); // located by ID
1759
1539
  * I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
1540
+ * I.dontSeeCheckboxIsChecked('agree'); // located by name
1760
1541
  * ```
1761
- * @param locator - located by label|name|CSS|XPath|strict locator.
1542
+ * @param field - located by label|name|CSS|XPath|strict locator.
1762
1543
  */
1763
- dontSeeCheckboxIsChecked(locator: CodeceptJS.LocatorOrString): Promise<void>;
1544
+ dontSeeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): Promise<any>;
1764
1545
  /**
1765
1546
  * Retrieves a text from an element located by CSS or XPath and returns it to test.
1766
1547
  * Resumes test execution, so **should be used inside async with `await`** operator.
@@ -1770,49 +1551,42 @@ declare namespace CodeceptJS {
1770
1551
  * ```
1771
1552
  * If multiple elements found returns first element.
1772
1553
  * @param locator - element located by CSS|XPath|strict locator.
1773
- * @returns text value
1554
+ * @returns attribute value
1774
1555
  */
1775
1556
  grabTextFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
1776
1557
  /**
1777
- * Retrieves all texts from elements located by CSS or XPath and returns it to test.
1558
+ * Retrieves all texts from an element located by CSS or XPath and returns it to test.
1778
1559
  * Resumes test execution, so **should be used inside async with `await`** operator.
1779
1560
  *
1780
1561
  * ```js
1781
1562
  * let pins = await I.grabTextFromAll('#pin li');
1782
1563
  * ```
1783
1564
  * @param locator - element located by CSS|XPath|strict locator.
1784
- * @returns array of text values
1565
+ * @returns attribute value
1785
1566
  */
1786
1567
  grabTextFromAll(locator: CodeceptJS.LocatorOrString): Promise<string[]>;
1787
1568
  /**
1788
- * Retrieves an array of `WebElement`s matching a locator (`lib/element/WebElement.js`,
1789
- * wrapping a `CDPElementHandle`). Element handles are re-resolved on demand by re-running
1790
- * `candidates` and picking the matching index, since `CDPBrowser` never keeps a persistent
1791
- * 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.
1792
1571
  *
1793
1572
  * ```js
1794
- * const buttons = await I.grabWebElements({ role: 'button' });
1573
+ * const webElements = await I.grabWebElements('#button');
1795
1574
  * ```
1796
1575
  * @param locator - element located by CSS|XPath|strict locator.
1797
- * @returns array of WebElement instances.
1576
+ * @returns WebElement of being used Web helper
1798
1577
  */
1799
- grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<object[]>;
1578
+ grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
1800
1579
  /**
1801
- * Retrieves the first `WebElement` matching a locator.
1580
+ * Grab WebElement for given locator
1581
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
1802
1582
  *
1803
1583
  * ```js
1804
- * const button = await I.grabWebElement({ role: 'button', text: 'Submit' });
1584
+ * const webElement = await I.grabWebElement('#button');
1805
1585
  * ```
1806
1586
  * @param locator - element located by CSS|XPath|strict locator.
1807
- * @returns a WebElement instance.
1808
- */
1809
- grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<object>;
1810
- /**
1811
- * Resolves whether the `texts` action should read via the client's `visibleText()` walker
1812
- * (probed once via `_needsVisibleTextFallback` and cached on `capabilities.innerText`) instead
1813
- * of each element's native `innerText`, then runs it.
1587
+ * @returns WebElement of being used Web helper
1814
1588
  */
1815
- protected _texts(candidates: { type: string; value: string | object; }[]): Promise<{ found: number; result: any; }>;
1589
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
1816
1590
  /**
1817
1591
  * Retrieves a value from a form element located by CSS or XPath and returns it to test.
1818
1592
  * Resumes test execution, so **should be used inside async function with `await`** operator.
@@ -1826,14 +1600,14 @@ declare namespace CodeceptJS {
1826
1600
  */
1827
1601
  grabValueFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
1828
1602
  /**
1829
- * Retrieves an array of values from fields located by CSS or XPath and returns it to test.
1603
+ * Retrieves an array of value from a form located by CSS or XPath and returns it to test.
1830
1604
  * Resumes test execution, so **should be used inside async function with `await`** operator.
1831
1605
  *
1832
1606
  * ```js
1833
1607
  * let inputs = await I.grabValueFromAll('//form/input');
1834
1608
  * ```
1835
1609
  * @param locator - field located by label|name|CSS|XPath|strict locator.
1836
- * @returns array of attribute values
1610
+ * @returns attribute value
1837
1611
  */
1838
1612
  grabValueFromAll(locator: CodeceptJS.LocatorOrString): Promise<string[]>;
1839
1613
  /**
@@ -1858,7 +1632,7 @@ declare namespace CodeceptJS {
1858
1632
  * ```
1859
1633
  * @param locator - element located by CSS|XPath|strict locator.
1860
1634
  * @param attr - attribute name.
1861
- * @returns array of attribute values
1635
+ * @returns attribute value
1862
1636
  */
1863
1637
  grabAttributeFromAll(locator: CodeceptJS.LocatorOrString, attr: string): Promise<string[]>;
1864
1638
  /**
@@ -1878,13 +1652,13 @@ declare namespace CodeceptJS {
1878
1652
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1879
1653
  * For images, the "alt" attribute and inner text of any parent links are searched.
1880
1654
  *
1881
- * When `options.input` is `'cdp'`, the click is dispatched as real `Input.dispatchMouseEvent` mouse events
1882
- * (`mouseMoved` / `mousePressed` / `mouseReleased`) at the center of the element's bounding box, so it
1883
- * exercises the same input pipeline a real user would. Otherwise it delegates to `forceClick`. A matched
1884
- * element with a zero-size bounding box (e.g. `display: none`) has no valid coordinate to click and throws;
1885
- * 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.
1886
1658
  *
1887
1659
  * ```js
1660
+ * // click body element (default)
1661
+ * I.click();
1888
1662
  * // simple link
1889
1663
  * I.click('Logout');
1890
1664
  * // button of form
@@ -1893,22 +1667,30 @@ declare namespace CodeceptJS {
1893
1667
  * I.click('#form input[type=submit]');
1894
1668
  * // XPath
1895
1669
  * I.click('//form/*[@type=submit]');
1670
+ * // link in context
1671
+ * I.click('Logout', '#nav');
1896
1672
  * // using strict locator
1897
1673
  * I.click({css: 'nav a.login'});
1674
+ * // using ARIA role locator
1675
+ * I.click({role: 'button', name: 'Submit'});
1898
1676
  * ```
1899
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
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.
1900
1680
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1901
1681
  */
1902
- click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1682
+ click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
1903
1683
  /**
1904
1684
  * Perform an emulated click on a link or a button, given by a locator.
1905
- * Unlike `click`, this always dispatches a synthetic in-page `el.click()` instead of sending native
1906
- * CDP input events. This works on hidden, animated or inactive elements as well.
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.
1907
1687
  *
1908
1688
  * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
1909
1689
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1910
1690
  * For images, the "alt" attribute and inner text of any parent links are searched.
1911
1691
  *
1692
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
1693
+ *
1912
1694
  * ```js
1913
1695
  * // simple link
1914
1696
  * I.forceClick('Logout');
@@ -1918,46 +1700,21 @@ declare namespace CodeceptJS {
1918
1700
  * I.forceClick('#form input[type=submit]');
1919
1701
  * // XPath
1920
1702
  * I.forceClick('//form/*[@type=submit]');
1703
+ * // link in context
1704
+ * I.forceClick('Logout', '#nav');
1921
1705
  * // using strict locator
1922
1706
  * I.forceClick({css: 'nav a.login'});
1923
1707
  * ```
1924
1708
  * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1925
1709
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1926
1710
  */
1927
- forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1928
- /**
1929
- * Settles after an interaction (click, key press, etc.) before the next step runs, using the
1930
- * listener `_armActionSettle` started *before* the interaction was dispatched (`armed`; a fresh
1931
- * one is armed here too, as a safety net, if a call site forgot to — but arming this late can
1932
- * only miss a navigation that already started during the action's own dispatch, exactly the race
1933
- * this design exists to avoid, so every call site should pass its own pre-armed `armed`, not rely
1934
- * on this fallback).
1935
- *
1936
- * If `options.waitForAction` was set explicitly in the config, honors it literally as a fixed
1937
- * pacing sleep, exactly as before this round — an explicit value is a deliberate choice
1938
- * (slow-motion debugging, a known-slow app) this never second-guesses.
1939
- *
1940
- * Otherwise, event-aware: races the armed listener against a *fresh* `ACTION_SETTLE_GRACE_MS`
1941
- * window (started now, not when it was armed — the action's own dispatch already ran concurrently
1942
- * with the arm, so this is genuinely bounded extra time, not a guess). If nothing declares a
1943
- * navigation, returns immediately once the window elapses — the common case for most actions
1944
- * (typing, toggling a checkbox, focusing a field) — instead of a fixed `options.waitForAction`
1945
- * (100ms by default) sleep on every single action regardless of whether anything is happening.
1946
- *
1947
- * If a navigation *did* start, `_lastMainFrameNav` (see `_ensureLifecycleListener`) is checked
1948
- * first: on a fast/local page, the entire lifecycle sequence through the target event has
1949
- * typically already arrived in the same batch that announced the navigation started, in which
1950
- * case this returns immediately. Only a navigation still genuinely in flight falls through to
1951
- * `_waitForPageLoad` (the same mechanism `amOnPage`/`refreshPage` use) — which waits for it to
1952
- * actually finish, rather than a fixed sleep that has no relationship to how long the navigation
1953
- * actually takes: strictly more correct for a slow navigation, not just faster for a fast one.
1954
- * @param [armed] - from `_armActionSettle`, called before the action.
1955
- */
1956
- protected _waitForAction(armed?: any | null): Promise<void>;
1711
+ forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
1957
1712
  /**
1958
1713
  * Fills a text field or textarea, after clearing its value, with the given string.
1959
1714
  * Field is located by name, label, CSS, or XPath.
1960
1715
  *
1716
+ * The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1717
+ *
1961
1718
  * ```js
1962
1719
  * // by label
1963
1720
  * I.fillField('Email', 'hello@world.com');
@@ -1967,43 +1724,59 @@ declare namespace CodeceptJS {
1967
1724
  * I.fillField('form#login input[name=username]', 'John');
1968
1725
  * // or by strict locator
1969
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');
1970
1731
  * ```
1732
+ *
1733
+ * > ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators](/locators#aria-locators).
1971
1734
  * @param field - located by label|name|CSS|XPath|strict locator.
1972
1735
  * @param value - text value to fill.
1973
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1736
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
1974
1737
  */
1975
- fillField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<void>;
1738
+ fillField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
1976
1739
  /**
1977
1740
  * Appends text to a input field or textarea.
1978
1741
  * Field is located by name, label, CSS or XPath
1979
1742
  *
1743
+ * The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1744
+ *
1980
1745
  * ```js
1981
1746
  * I.appendField('#myTextField', 'appended');
1982
1747
  * // typing secret
1983
1748
  * I.appendField('password', secret('123456'));
1749
+ * // within a context
1750
+ * I.appendField('name', 'John', '.form-container');
1984
1751
  * ```
1985
1752
  * @param field - located by label|name|CSS|XPath|strict locator
1986
1753
  * @param value - text value to append.
1987
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1754
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
1988
1755
  */
1989
- appendField(field: CodeceptJS.LocatorOrString, value: string, context?: CodeceptJS.LocatorOrString): Promise<void>;
1756
+ appendField(field: CodeceptJS.LocatorOrString, value: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
1990
1757
  /**
1991
1758
  * Clears a `<textarea>` or text `<input>` element's value.
1992
1759
  *
1760
+ * The second parameter is an optional context (CSS or XPath locator) to narrow the search.
1761
+ *
1993
1762
  * ```js
1994
1763
  * I.clearField('Email');
1995
1764
  * I.clearField('user[email]');
1996
1765
  * I.clearField('#email');
1766
+ * // within a context
1767
+ * I.clearField('Email', '.form-container');
1997
1768
  * ```
1998
- * @param field - editable field located by label|name|CSS|XPath|strict locator.
1999
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
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.
2000
1771
  */
2001
- clearField(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1772
+ clearField(editable: LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
2002
1773
  /**
2003
1774
  * Selects an option in a drop-down select.
2004
1775
  * Field is searched by label | name | CSS | XPath.
2005
1776
  * Option is selected by visible text or by value.
2006
1777
  *
1778
+ * The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1779
+ *
2007
1780
  * ```js
2008
1781
  * I.selectOption('Choose Plan', 'Monthly'); // select by label
2009
1782
  * I.selectOption('subscription', 'Monthly'); // match option by text
@@ -2011,16 +1784,26 @@ declare namespace CodeceptJS {
2011
1784
  * I.selectOption('//form/select[@name=account]','Premium');
2012
1785
  * I.selectOption('form select[name=account]', 'Premium');
2013
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']);
2014
1795
  * ```
2015
1796
  * @param select - field located by label|name|CSS|XPath|strict locator.
2016
- * @param option - visible text or value of option, or an array of them for a multi-select.
2017
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1797
+ * @param option - visible text or value of option.
1798
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
2018
1799
  */
2019
- selectOption(select: CodeceptJS.LocatorOrString, option: string | string[], context?: CodeceptJS.LocatorOrString): Promise<void>;
1800
+ selectOption(select: LocatorOrString, option: string | any[], context?: CodeceptJS.LocatorOrString): Promise<any>;
2020
1801
  /**
2021
1802
  * Selects a checkbox or radio button.
2022
1803
  * Element is located by label or name or CSS or XPath.
2023
1804
  *
1805
+ * The second parameter is an optional context (CSS or XPath locator) to narrow the search.
1806
+ *
2024
1807
  * ```js
2025
1808
  * I.checkOption('#agree');
2026
1809
  * I.checkOption('I Agree to Terms and Conditions');
@@ -2029,11 +1812,13 @@ declare namespace CodeceptJS {
2029
1812
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
2030
1813
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
2031
1814
  */
2032
- checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1815
+ checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
2033
1816
  /**
2034
1817
  * Unselects a checkbox or radio button.
2035
1818
  * Element is located by label or name or CSS or XPath.
2036
1819
  *
1820
+ * The second parameter is an optional context (CSS or XPath locator) to narrow the search.
1821
+ *
2037
1822
  * ```js
2038
1823
  * I.uncheckOption('#agree');
2039
1824
  * I.uncheckOption('I Agree to Terms and Conditions');
@@ -2042,31 +1827,34 @@ declare namespace CodeceptJS {
2042
1827
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
2043
1828
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
2044
1829
  */
2045
- uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
1830
+ uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
2046
1831
  /**
2047
- * Attaches a file to a file input field, or drops it onto a drag-and-drop dropzone element,
2048
- * resolved by label|name|CSS|XPath|strict locator. `pathToFile` is resolved relative to
2049
- * `codecept_dir` (matching Puppeteer/WebDriver). Since `CDPBrowser` never brings element handles
2050
- * back to Node, the resolved element is marked with a throwaway `data-codecept-upload` attribute
2051
- * in-page (respecting `context`/`within`/elementIndex exactly like every other action). A real
2052
- * `<input type="file">` is then addressed by that attribute through the CDP `DOM` domain, which
2053
- * `CDPBrowser` otherwise never uses, to call `DOM.setFileInputFiles`; any other element (a
2054
- * drag-and-drop dropzone) instead gets a synthetic `dragenter`/`dragover`/`drop` sequence with a
2055
- * `DataTransfer` built from the file's contents, entirely in-page. The marker is removed again in
2056
- * 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.
2057
1837
  *
2058
1838
  * ```js
2059
1839
  * I.attachFile('Avatar', 'data/avatar.jpg');
2060
- * I.attachFile('#file', 'data/avatar.jpg');
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
2061
1849
  * I.attachFile('#dropzone', 'data/avatar.jpg');
2062
1850
  * ```
2063
- * @param field - located by label|name|CSS|XPath|strict locator.
2064
- * @param pathToFile - path to file, relative to `codecept_dir`.
2065
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
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.
2066
1854
  */
2067
- attachFile(field: CodeceptJS.LocatorOrString, pathToFile: string, context?: CodeceptJS.LocatorOrString): Promise<void>;
1855
+ attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string, context?: CodeceptJS.LocatorOrString): Promise<any>;
2068
1856
  /**
2069
- * Waits for element to be present on page (by default waits for `options.waitForTimeout` seconds).
1857
+ * Waits for element to be present on page (by default waits for 1sec).
2070
1858
  * Element can be located by CSS or XPath.
2071
1859
  *
2072
1860
  * ```js
@@ -2074,11 +1862,11 @@ declare namespace CodeceptJS {
2074
1862
  * I.waitForElement('.btn.continue', 5); // wait for 5 secs
2075
1863
  * ```
2076
1864
  * @param locator - element located by CSS|XPath|strict locator.
2077
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
1865
+ * @param [sec = null] - (optional, `1` by default) time in seconds to wait
2078
1866
  */
2079
- waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<void>;
1867
+ waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
2080
1868
  /**
2081
- * Waits for a text to appear (by default waits for `options.waitForTimeout` seconds).
1869
+ * Waits for a text to appear (by default waits for 1sec).
2082
1870
  * Element can be located by CSS or XPath.
2083
1871
  * Narrow down search results by providing context.
2084
1872
  *
@@ -2087,10 +1875,10 @@ declare namespace CodeceptJS {
2087
1875
  * I.waitForText('Thank you, form has been submitted', 5, '#modal');
2088
1876
  * ```
2089
1877
  * @param text - to wait for.
2090
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
1878
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2091
1879
  * @param [context = null] - (optional) element located by CSS|XPath|strict locator.
2092
1880
  */
2093
- waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): Promise<void>;
1881
+ waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): Promise<any>;
2094
1882
  /**
2095
1883
  * Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
2096
1884
  *
@@ -2098,23 +1886,27 @@ declare namespace CodeceptJS {
2098
1886
  * I.waitInUrl('/info', 2);
2099
1887
  * ```
2100
1888
  * @param urlPart - value to check.
2101
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
1889
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2102
1890
  */
2103
- waitInUrl(urlPart: string, sec?: number): Promise<void>;
1891
+ waitInUrl(urlPart: string, sec?: number): Promise<any>;
2104
1892
  /**
2105
- * Waits for a function to return true (waits for `options.waitForTimeout` seconds by default).
1893
+ * Waits for a function to return true (waits for 1 sec by default).
2106
1894
  * Running in browser context.
2107
1895
  *
2108
1896
  * ```js
1897
+ * I.waitForFunction(fn[, [args[, timeout]])
1898
+ * ```
1899
+ *
1900
+ * ```js
2109
1901
  * I.waitForFunction(() => window.requests == 0);
2110
1902
  * I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
2111
1903
  * I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
2112
1904
  * ```
2113
1905
  * @param fn - to be executed in browser context.
2114
- * @param [argsOrSec = null] - (optional) arguments for function or, if a number, seconds to wait.
2115
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
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
2116
1908
  */
2117
- waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): Promise<void>;
1909
+ waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): Promise<any>;
2118
1910
  /**
2119
1911
  * Sets cookie(s).
2120
1912
  *
@@ -2131,7 +1923,7 @@ declare namespace CodeceptJS {
2131
1923
  * ```
2132
1924
  * @param cookie - a cookie object or array of cookie objects.
2133
1925
  */
2134
- setCookie(cookie: CodeceptJS.Cookie | CodeceptJS.Cookie[]): Promise<void>;
1926
+ setCookie(cookie: Cookie | Cookie[]): Promise<any>;
2135
1927
  /**
2136
1928
  * Retrieves all cookies visible to the current page.
2137
1929
  * Resumes test execution, so **should be used inside async function with `await`** operator.
@@ -2152,9 +1944,8 @@ declare namespace CodeceptJS {
2152
1944
  * assert(cookie.value, '123456');
2153
1945
  * ```
2154
1946
  * @param [name = null] - cookie name.
2155
- * @returns a cookie object, or an array of all cookies when `name` is not provided.
2156
1947
  */
2157
- grabCookie(name?: string | null): Promise<CodeceptJS.Cookie | CodeceptJS.Cookie[]>;
1948
+ grabCookie(name?: string): Promise<any>;
2158
1949
  /**
2159
1950
  * Clears a cookie by name,
2160
1951
  * if none provided clears all cookies.
@@ -2163,9 +1954,58 @@ declare namespace CodeceptJS {
2163
1954
  * I.clearCookie();
2164
1955
  * I.clearCookie('test');
2165
1956
  * ```
2166
- * @param [name = null] - (optional, `null` by default) cookie name
1957
+ * @param [cookie = null] - (optional, `null` by default) cookie name
1958
+ */
1959
+ clearCookie(cookie?: string): Promise<any>;
1960
+ /**
1961
+ * Checks that the system clipboard contains the given text.
1962
+ *
1963
+ * ```js
1964
+ * I.click('Copy to clipboard');
1965
+ * I.seeInClipboard('https://codecept.io');
1966
+ * ```
1967
+ *
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.
1970
+ * @param text - value to check.
1971
+ */
1972
+ seeInClipboard(text: string): Promise<any>;
1973
+ /**
1974
+ * Checks that the system clipboard is equal to the given text.
1975
+ *
1976
+ * ```js
1977
+ * I.click('Copy to clipboard');
1978
+ * I.seeClipboardEquals('https://codecept.io');
1979
+ * ```
1980
+ *
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.
1983
+ * @param text - value to check.
1984
+ */
1985
+ seeClipboardEquals(text: string): Promise<any>;
1986
+ /**
1987
+ * Clears the system clipboard.
1988
+ *
1989
+ * ```js
1990
+ * I.clearClipboard();
1991
+ * I.seeClipboardEquals('');
1992
+ * ```
1993
+ */
1994
+ clearClipboard(): Promise<any>;
1995
+ /**
1996
+ * Grabs the text content of the system clipboard and returns it to test.
1997
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
1998
+ *
1999
+ * ```js
2000
+ * I.click('Copy to clipboard');
2001
+ * let url = await I.grabFromClipboard();
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.
2006
+ * @returns the system clipboard contents.
2167
2007
  */
2168
- clearCookie(name?: string | null): Promise<void>;
2008
+ grabFromClipboard(): Promise<string>;
2169
2009
  /**
2170
2010
  * Saves a screenshot to the output folder (set in codecept.conf.ts or codecept.conf.js).
2171
2011
  * Filename is relative to the output folder.
@@ -2175,168 +2015,203 @@ declare namespace CodeceptJS {
2175
2015
  * ```
2176
2016
  * @param fileName - file name to save.
2177
2017
  */
2178
- saveScreenshot(fileName: string): Promise<void>;
2018
+ saveScreenshot(fileName: string): Promise<any>;
2179
2019
  /**
2180
- * Saves a screenshot of a single element to the output folder.
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.
2181
2022
  *
2182
2023
  * ```js
2183
- * I.saveElementScreenshot('#logo', 'logo.png');
2024
+ * I.saveElementScreenshot(`#submit`,'debug.png');
2184
2025
  * ```
2185
2026
  * @param locator - element located by CSS|XPath|strict locator.
2186
2027
  * @param fileName - file name to save.
2187
2028
  */
2188
- saveElementScreenshot(locator: CodeceptJS.LocatorOrString, fileName: string): Promise<void>;
2029
+ saveElementScreenshot(locator: CodeceptJS.LocatorOrString, fileName: string): Promise<any>;
2189
2030
  /**
2190
2031
  * Pauses execution for a number of seconds.
2191
2032
  *
2192
2033
  * ```js
2193
- * I.wait(2); // waits 2 secs
2034
+ * I.wait(2); // wait 2 secs
2194
2035
  * ```
2195
- * @param sec - number of seconds to wait.
2036
+ * @param sec - number of second to wait.
2196
2037
  */
2197
- wait(sec: number): Promise<void>;
2038
+ wait(sec: number): Promise<any>;
2198
2039
  /**
2199
2040
  * Checks that title does not contain text.
2041
+ *
2042
+ * ```js
2043
+ * I.dontSeeInTitle('Error');
2044
+ * ```
2200
2045
  * @param text - value to check.
2201
2046
  */
2202
- dontSeeInTitle(text: string): Promise<void>;
2047
+ dontSeeInTitle(text: string): Promise<any>;
2203
2048
  /**
2204
2049
  * Checks that current url is equal to provided one.
2205
- * Unlike `seeInCurrentUrl` performs a strict comparison.
2050
+ * If a relative url provided, a configured url will be prepended to it.
2051
+ * So both examples will work:
2206
2052
  *
2207
2053
  * ```js
2208
2054
  * I.seeCurrentUrlEquals('/register');
2055
+ * I.seeCurrentUrlEquals('http://my.site.com/register');
2209
2056
  * ```
2210
2057
  * @param url - value to check.
2211
2058
  */
2212
- seeCurrentUrlEquals(url: string): Promise<void>;
2059
+ seeCurrentUrlEquals(url: string): Promise<any>;
2213
2060
  /**
2214
2061
  * Checks that current url is not equal to provided one.
2215
- * Unlike `dontSeeInCurrentUrl` performs a strict comparison.
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
+ * ```
2216
2068
  * @param url - value to check.
2217
2069
  */
2218
- dontSeeCurrentUrlEquals(url: string): Promise<void>;
2219
- /**
2220
- * Resolves the current page URL to a `pathname`, ignoring the origin, query string, and hash.
2221
- * @returns the pathname of the current page.
2222
- */
2223
- protected _grabCurrentPath(): Promise<string>;
2070
+ dontSeeCurrentUrlEquals(url: string): Promise<any>;
2224
2071
  /**
2225
- * Checks that current url path (ignoring query string and hash) equals to provided one.
2072
+ * Checks that current URL path matches the expected path.
2073
+ * Query strings and URL fragments are ignored.
2226
2074
  *
2227
2075
  * ```js
2228
- * I.seeCurrentPathEquals('/info');
2076
+ * I.seeCurrentPathEquals('/info'); // passes for '/info', '/info?user=1', '/info#section'
2077
+ * I.seeCurrentPathEquals('/'); // passes for '/', '/?user=ok', '/#top'
2229
2078
  * ```
2230
2079
  * @param path - value to check.
2231
2080
  */
2232
- seeCurrentPathEquals(path: string): Promise<void>;
2081
+ seeCurrentPathEquals(path: string): Promise<any>;
2233
2082
  /**
2234
- * Opposite to `seeCurrentPathEquals`.
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
+ * ```
2235
2090
  * @param path - value to check.
2236
2091
  */
2237
- dontSeeCurrentPathEquals(path: string): Promise<void>;
2092
+ dontSeeCurrentPathEquals(path: string): Promise<any>;
2238
2093
  /**
2239
- * Waits for the entire URL to match the expected (by default waits for `options.waitForTimeout` seconds).
2094
+ * Waits for the entire URL to match the expected
2240
2095
  *
2241
2096
  * ```js
2242
2097
  * I.waitUrlEquals('/info', 2);
2098
+ * I.waitUrlEquals('http://127.0.0.1:8000/info');
2243
2099
  * ```
2244
2100
  * @param urlPart - value to check.
2245
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2101
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2246
2102
  */
2247
- waitUrlEquals(urlPart: string, sec?: number): Promise<void>;
2103
+ waitUrlEquals(urlPart: string, sec?: number): Promise<any>;
2248
2104
  /**
2249
- * Waits for current url path (ignoring query string and hash) to equal to the expected.
2105
+ * Waits for the current URL path to match the expected path.
2106
+ * Query strings and URL fragments are ignored.
2250
2107
  *
2251
2108
  * ```js
2252
- * I.waitCurrentPathEquals('/info', 2);
2109
+ * I.waitCurrentPathEquals('/info', 5);
2253
2110
  * ```
2254
2111
  * @param path - value to check.
2255
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2112
+ * @param [sec = null] - (optional, `waitForTimeout` by default) time in seconds to wait
2256
2113
  */
2257
- waitCurrentPathEquals(path: string, sec?: number): Promise<void>;
2114
+ waitCurrentPathEquals(path: string, sec?: number): Promise<any>;
2258
2115
  /**
2259
- * Checks that the given input field or textarea equals (contains) the given value.
2260
- * For fuzzy locators, the field is searched by label|name|CSS|XPath|strict locator.
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.
2261
2120
  *
2262
2121
  * ```js
2263
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');
2264
2128
  * ```
2265
2129
  * @param field - located by label|name|CSS|XPath|strict locator.
2266
2130
  * @param value - value to check.
2267
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
2131
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
2268
2132
  */
2269
- seeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<void>;
2133
+ seeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
2270
2134
  /**
2135
+ * Checks that value of input field or textarea doesn't equal to given value
2271
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
+ * ```
2272
2146
  * @param field - located by label|name|CSS|XPath|strict locator.
2273
2147
  * @param value - value to check.
2274
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
2275
- */
2276
- dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<void>;
2277
- /**
2278
- * Shared implementation for `seeInField`/`dontSeeInField`.
2148
+ * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
2279
2149
  */
2280
- protected _seeInField(assertType: 'assert' | 'negate', field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<void>;
2150
+ dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret, context?: CodeceptJS.LocatorOrString): Promise<any>;
2281
2151
  /**
2282
2152
  * Grab number of visible elements by locator.
2153
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
2283
2154
  *
2284
2155
  * ```js
2285
- * let numOfVisibleElements = await I.grabNumberOfVisibleElements('p');
2156
+ * let numOfElements = await I.grabNumberOfVisibleElements('p');
2286
2157
  * ```
2287
2158
  * @param locator - located by CSS|XPath|strict locator.
2288
- * @returns number of visible matched elements.
2159
+ * @returns number of visible elements
2289
2160
  */
2290
2161
  grabNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString): Promise<number>;
2291
2162
  /**
2292
- * Asserts that an element appears a given number of times on the page, and that all matching elements are visible.
2163
+ * Asserts that an element is visible a given number of times.
2164
+ * Element is located by CSS or XPath.
2293
2165
  *
2294
2166
  * ```js
2295
2167
  * I.seeNumberOfVisibleElements('.buttons', 3);
2296
2168
  * ```
2297
- * @param locator - located by CSS|XPath|strict locator.
2298
- * @param num - expected number of elements.
2169
+ * @param locator - element located by CSS|XPath|strict locator.
2170
+ * @param num - number of elements.
2299
2171
  */
2300
- seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): Promise<void>;
2172
+ seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): Promise<any>;
2301
2173
  /**
2302
- * Retrieves the current page scroll position.
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.
2303
2176
  *
2304
2177
  * ```js
2305
2178
  * let { x, y } = await I.grabPageScrollPosition();
2306
2179
  * ```
2307
- * @returns scroll position.
2180
+ * @returns scroll position
2308
2181
  */
2309
- grabPageScrollPosition(): Promise<{ x: number; y: number; }>;
2182
+ grabPageScrollPosition(): Promise<PageScrollPosition>;
2310
2183
  /**
2311
- * Scrolls to the top of the page.
2184
+ * Scroll page to the top.
2312
2185
  *
2313
2186
  * ```js
2314
2187
  * I.scrollPageToTop();
2315
2188
  * ```
2316
2189
  */
2317
- scrollPageToTop(): Promise<void>;
2190
+ scrollPageToTop(): Promise<any>;
2318
2191
  /**
2319
- * Scrolls to the bottom of the page.
2192
+ * Scroll page to the bottom.
2320
2193
  *
2321
2194
  * ```js
2322
2195
  * I.scrollPageToBottom();
2323
2196
  * ```
2324
2197
  */
2325
- scrollPageToBottom(): Promise<void>;
2198
+ scrollPageToBottom(): Promise<any>;
2326
2199
  /**
2327
- * Scrolls to the element matched by locator, or to given coordinates.
2200
+ * Scrolls to element matched by locator.
2201
+ * Extra shift can be set with offsetX and offsetY options.
2328
2202
  *
2329
2203
  * ```js
2330
- * I.scrollTo('#submit');
2331
- * I.scrollTo(100, 200);
2204
+ * I.scrollTo('footer');
2205
+ * I.scrollTo('#submit', 5, 5);
2332
2206
  * ```
2333
- * @param locator - element to scroll to, or an X coordinate if no element.
2334
- * @param [offsetX = 0] - X offset, or Y coordinate if `locator` is a number.
2335
- * @param [offsetY = 0] - Y offset applied when scrolling to an element.
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.
2336
2210
  */
2337
- scrollTo(locator: CodeceptJS.LocatorOrString | number, offsetX?: number, offsetY?: number): Promise<void>;
2211
+ scrollTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): Promise<any>;
2338
2212
  /**
2339
- * Retrieves a CSS property from an element located by CSS or XPath.
2213
+ * Grab CSS property for given locator
2214
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2340
2215
  * If more than one element is found - value of first element is returned.
2341
2216
  *
2342
2217
  * ```js
@@ -2348,79 +2223,94 @@ declare namespace CodeceptJS {
2348
2223
  */
2349
2224
  grabCssPropertyFrom(locator: CodeceptJS.LocatorOrString, cssProperty: string): Promise<string>;
2350
2225
  /**
2351
- * Retrieves an array of CSS properties from elements located by CSS or XPath.
2226
+ * Grab array of CSS properties for given locator
2227
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2352
2228
  *
2353
2229
  * ```js
2354
2230
  * const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
2355
2231
  * ```
2356
2232
  * @param locator - element located by CSS|XPath|strict locator.
2357
2233
  * @param cssProperty - CSS property name.
2358
- * @returns array of CSS values
2234
+ * @returns CSS value
2359
2235
  */
2360
2236
  grabCssPropertyFromAll(locator: CodeceptJS.LocatorOrString, cssProperty: string): Promise<string[]>;
2361
2237
  /**
2362
- * Checks that all elements matched by locator have the given CSS properties.
2238
+ * Checks that all elements with given locator have given CSS properties.
2363
2239
  *
2364
2240
  * ```js
2365
- * I.seeCssPropertiesOnElements('h3', { 'font-weight': 'bold', display: 'block' });
2241
+ * I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
2366
2242
  * ```
2367
- * @param locator - element located by CSS|XPath|strict locator.
2243
+ * @param locator - located by CSS|XPath|strict locator.
2368
2244
  * @param cssProperties - object with CSS properties and their values to check.
2369
2245
  */
2370
- seeCssPropertiesOnElements(locator: CodeceptJS.LocatorOrString, cssProperties: any): Promise<void>;
2246
+ seeCssPropertiesOnElements(locator: CodeceptJS.LocatorOrString, cssProperties: any): Promise<any>;
2371
2247
  /**
2372
- * Checks that all elements matched by locator have the given attribute values.
2373
- * 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.
2374
2249
  *
2375
2250
  * ```js
2376
- * I.seeAttributesOnElements('//form', { method: 'post' });
2251
+ * I.seeAttributesOnElements('//form', { method: "post"});
2377
2252
  * ```
2378
- * @param locator - element located by CSS|XPath|strict locator.
2379
- * @param attributes - object with attribute names and expected values.
2253
+ * @param locator - located by CSS|XPath|strict locator.
2254
+ * @param attributes - attributes and their values to check.
2380
2255
  */
2381
- seeAttributesOnElements(locator: CodeceptJS.LocatorOrString, attributes: any): Promise<void>;
2256
+ seeAttributesOnElements(locator: CodeceptJS.LocatorOrString, attributes: any): Promise<any>;
2382
2257
  /**
2383
- * Focuses a given element.
2258
+ * Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the matching element.
2259
+ *
2260
+ * Examples:
2384
2261
  *
2385
2262
  * ```js
2386
- * I.focus('#name');
2263
+ * I.dontSee('#add-to-cart-btn');
2264
+ * I.focus('#product-tile')
2265
+ * I.see('#add-to-cart-bnt');
2387
2266
  * ```
2388
- * @param locator - element located by CSS|XPath|strict 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.
2389
2269
  */
2390
- focus(locator: CodeceptJS.LocatorOrString): Promise<void>;
2270
+ focus(locator: CodeceptJS.LocatorOrString, options?: any): Promise<any>;
2391
2271
  /**
2392
- * Removes focus from a given element.
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:
2393
2276
  *
2394
2277
  * ```js
2395
- * I.blur('#name');
2278
+ * I.blur('.text-area')
2396
2279
  * ```
2397
- * @param locator - element located by CSS|XPath|strict locator.
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.
2398
2288
  */
2399
- blur(locator: CodeceptJS.LocatorOrString): Promise<void>;
2289
+ blur(locator: CodeceptJS.LocatorOrString, options?: any): Promise<any>;
2400
2290
  /**
2401
- * Types characters into the currently focused element (as set by `click`, `focus`, etc). Each
2402
- * character dispatches a real `keydown` → `keypress` → (value mutated) → `input` → `keyup`
2403
- * sequence, and mutates a `contenteditable` host's `textContent` instead of `.value`, so this
2404
- * works on rich-text/contenteditable targets as well as `input`/`textarea`. Mirrors Puppeteer's
2405
- * `type(text, options)` semantics.
2406
- *
2407
- * Without a `delay`, every character is dispatched in a single round-trip to the page. With a
2408
- * `delay`, characters are dispatched one round-trip at a time so the requested pause actually
2409
- * 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.
2410
2294
  *
2411
2295
  * ```js
2412
- * I.click('Name');
2413
- * I.type('CodeceptJS');
2414
- * I.type(['C', 'o', 'd', 'e']);
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'));
2415
2307
  * ```
2416
- * @param keys - characters to type, either as a string or an array of characters.
2417
- * @param [delay = null] - (optional) delay in milliseconds between key presses.
2308
+ * @param key - or array of keys to type.
2309
+ * @param [delay = null] - (optional) delay in ms between key presses
2418
2310
  */
2419
- type(keys: string | string[], delay?: number): Promise<void>;
2311
+ type(key: string | string[], delay?: number): Promise<any>;
2420
2312
  /**
2421
- * Presses a key or key combination on the currently focused element.
2422
- * Under `options.strict`, a modifier+editing-key combination (e.g. `Ctrl+A`) dispatched with no
2423
- * element focused throws `NonFocusedType`, mirroring `focusCheck.js`'s behavior on other helpers.
2313
+ * Presses a key or a key combination on the focused element.
2424
2314
  *
2425
2315
  * ```js
2426
2316
  * I.pressKey('Enter');
@@ -2428,171 +2318,186 @@ declare namespace CodeceptJS {
2428
2318
  * ```
2429
2319
  * @param key - a key or an array of keys to combine (modifiers first).
2430
2320
  */
2431
- pressKey(key: string | string[]): Promise<void>;
2321
+ pressKey(key: string | string[]): Promise<any>;
2432
2322
  /**
2433
- * Resizes the browser viewport.
2434
- *
2435
- * ```js
2436
- * I.resizeWindow(1024, 768);
2437
- * ```
2438
- * @param width - window width, or `'maximize'`.
2439
- * @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.
2440
2327
  */
2441
- resizeWindow(width: number | 'maximize', height?: number): Promise<void>;
2328
+ resizeWindow(width: number, height: number): Promise<any>;
2442
2329
  /**
2443
- * Performs a double-click on an element matched by locator.
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.
2444
2332
  *
2445
2333
  * ```js
2446
2334
  * I.doubleClick('Edit');
2335
+ * I.doubleClick('Edit', '.actions');
2336
+ * I.doubleClick({css: 'button.accept'});
2337
+ * I.doubleClick('.btn.edit');
2447
2338
  * ```
2448
- * @param locator - clickable element located by text, or any element located by CSS|XPath|strict locator.
2449
- * @param [context = null] - (optional, `null` by default, currently ignored by this helper).
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.
2450
2341
  */
2451
- doubleClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
2342
+ doubleClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
2452
2343
  /**
2453
- * Performs a right-click on an element matched by locator.
2344
+ * Performs right click on a clickable element matched by semantic locator, CSS or XPath.
2454
2345
  *
2455
2346
  * ```js
2456
- * I.rightClick('Menu');
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');
2457
2353
  * ```
2458
- * @param locator - clickable element located by text, or any element located by CSS|XPath|strict locator.
2459
- * @param [context = null] - (optional, `null` by default, currently ignored by this helper).
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.
2460
2356
  */
2461
- rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<void>;
2357
+ rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
2462
2358
  /**
2463
- * Clicks at global page coordinates, or at coordinates relative to an element.
2464
- * Dispatches a real CDP mouse click and therefore requires a real layout engine.
2359
+ * Clicks at page coordinates, or at coordinates relative to an element.
2360
+ * Requires a browser that renders layout.
2465
2361
  *
2466
2362
  * ```js
2467
- * I.clickXY(100, 200); // global coordinates
2363
+ * I.clickXY(100, 200); // page coordinates
2468
2364
  * I.clickXY('#area', 50, 30); // relative to #area
2469
2365
  * ```
2470
- * @param locator - element to click relative to, or a global X coordinate.
2471
- * @param [x] - X coordinate relative to element, or global Y coordinate if `locator` is a number.
2472
- * @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.
2473
2369
  */
2474
- clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<void>;
2370
+ clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<any>;
2475
2371
  /**
2476
- * Waits for an element to become visible (by default waits for `options.waitForTimeout` seconds).
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.
2477
2374
  *
2478
2375
  * ```js
2479
- * I.waitForVisible('#popup', 5);
2376
+ * I.waitForVisible('#popup');
2480
2377
  * ```
2481
2378
  * @param locator - element located by CSS|XPath|strict locator.
2482
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2379
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2483
2380
  */
2484
- waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<void>;
2381
+ waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
2485
2382
  /**
2486
- * Waits for an element to become invisible (by default waits for `options.waitForTimeout` seconds).
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.
2487
2385
  *
2488
2386
  * ```js
2489
- * I.waitForInvisible('#popup', 5);
2387
+ * I.waitForInvisible('#popup');
2490
2388
  * ```
2491
2389
  * @param locator - element located by CSS|XPath|strict locator.
2492
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2390
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2493
2391
  */
2494
- waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<void>;
2392
+ waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
2495
2393
  /**
2496
- * Waits for an element to be hidden. Alias of `waitForInvisible`.
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
+ * ```
2497
2400
  * @param locator - element located by CSS|XPath|strict locator.
2498
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2401
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2499
2402
  */
2500
- waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<void>;
2403
+ waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
2501
2404
  /**
2502
- * Waits for an element to be removed from the DOM (by default waits for `options.waitForTimeout` seconds).
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.
2503
2407
  *
2504
2408
  * ```js
2505
- * I.waitForDetached('#popup', 5);
2409
+ * I.waitForDetached('#popup');
2506
2410
  * ```
2507
2411
  * @param locator - element located by CSS|XPath|strict locator.
2508
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2412
+ * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
2509
2413
  */
2510
- waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<void>;
2414
+ waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
2511
2415
  /**
2512
- * Checks that a cookie with the given name is set.
2416
+ * Checks that cookie with given name exists.
2417
+ *
2418
+ * ```js
2419
+ * I.seeCookie('Auth');
2420
+ * ```
2513
2421
  * @param name - cookie name.
2514
2422
  */
2515
- seeCookie(name: string): Promise<void>;
2423
+ seeCookie(name: string): Promise<any>;
2516
2424
  /**
2517
- * Checks that a cookie with the given name is not set.
2425
+ * Checks that cookie with given name does not exist.
2426
+ *
2427
+ * ```js
2428
+ * I.dontSeeCookie('auth'); // no auth cookie
2429
+ * ```
2518
2430
  * @param name - cookie name.
2519
2431
  */
2520
- dontSeeCookie(name: string): Promise<void>;
2432
+ dontSeeCookie(name: string): Promise<any>;
2521
2433
  /**
2522
- * Waits for a cookie with the given name to be set (by default waits for `options.waitForTimeout` seconds).
2434
+ * Waits for the specified cookie in the cookies.
2523
2435
  *
2524
2436
  * ```js
2525
- * I.waitForCookie('auth', 5);
2437
+ * I.waitForCookie("token");
2526
2438
  * ```
2527
- * @param name - cookie name.
2528
- * @param [sec = null] - (optional, `options.waitForTimeout` by default) time in seconds to wait
2439
+ * @param name - expected cookie name.
2440
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
2529
2441
  */
2530
- waitForCookie(name: string, sec?: number): Promise<void>;
2442
+ waitForCookie(name: string, sec?: number): Promise<any>;
2531
2443
  /**
2532
- * Retrieves the inner HTML from an element located by CSS or XPath.
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.
2533
2446
  * If more than one element is found - HTML of first element is returned.
2534
2447
  *
2535
2448
  * ```js
2536
2449
  * let postHTML = await I.grabHTMLFrom('#post');
2537
2450
  * ```
2538
- * @param locator - element located by CSS|XPath|strict locator.
2451
+ * @param element - located by CSS|XPath|strict locator.
2452
+ * @returns HTML code for an element
2453
+ */
2454
+ grabHTMLFrom(element: CodeceptJS.LocatorOrString): Promise<string>;
2455
+ /**
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.
2458
+ *
2459
+ * ```js
2460
+ * let postHTMLs = await I.grabHTMLFromAll('.post');
2461
+ * ```
2462
+ * @param element - located by CSS|XPath|strict locator.
2539
2463
  * @returns HTML code for an element
2540
2464
  */
2541
- grabHTMLFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
2465
+ grabHTMLFromAll(element: CodeceptJS.LocatorOrString): Promise<string[]>;
2542
2466
  /**
2543
- * Retrieves the inner HTML from elements located by CSS or XPath.
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).
2544
2471
  *
2545
2472
  * ```js
2546
- * let postHTMLs = await I.grabHTMLFromAll('.post');
2473
+ * I.executeAsyncScript(function(done) {
2474
+ * Vue.nextTick(done); // waiting for next tick
2475
+ * });
2547
2476
  * ```
2548
- * @param locator - element located by CSS|XPath|strict locator.
2549
- * @returns HTML code for matched elements
2550
- */
2551
- grabHTMLFromAll(locator: CodeceptJS.LocatorOrString): Promise<string[]>;
2552
- /**
2553
- * Executes an asynchronous script (callback-style, in the same way `window.setTimeout` works)
2554
- * in the browser context and returns the value passed to `done`.
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.
2555
2480
  *
2556
2481
  * ```js
2557
- * const val = await I.executeAsyncScript(function(val, done) {
2558
- * setTimeout(() => done(val + 1), 100)
2559
- * }, 5)
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/');
2560
2486
  * ```
2561
- * @param fn - an asynchronous function to be executed in the browser context; its last argument is a `done` callback.
2562
- * @param args - arguments to pass into the function (before `done`).
2563
- * @returns the value passed to `done`.
2487
+ * @param fn - function to be executed in browser context.
2488
+ * @param args - to be passed to function.
2489
+ * @returns script return value
2564
2490
  */
2565
- executeAsyncScript(fn: (...params: any[]) => any, ...args: any[]): Promise<any>;
2491
+ executeAsyncScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
2566
2492
  /**
2567
- * Starts recording network traffic via CDP's `Network.requestWillBeSent`/`responseReceived`
2568
- * events, in the same shape (`{url, method, requestHeaders, requestPostData, response}` per
2569
- * request, `response` a promise of `{url(), status(), statusText(), body()}`) the shared
2570
- * `lib/helper/network` actions expect from Puppeteer/Playwright. The CDP listeners are
2571
- * installed once (lazily) and left in place afterwards, since `CDPConnection` has no listener
2572
- * removal and `this.cdp` is reused across tests; they filter by `this.sessionId`, so only the
2573
- * currently active test/page's requests are recorded.
2493
+ * Starts recording the network traffics.
2494
+ * This also resets recorded network requests.
2574
2495
  *
2575
2496
  * ```js
2576
2497
  * I.startRecordingTraffic();
2577
2498
  * ```
2578
2499
  */
2579
- startRecordingTraffic(): Promise<void>;
2580
- /**
2581
- * `Network.requestWillBeSent` handler, pushed into `this.requests` when it belongs to the
2582
- * currently active session and recording is on.
2583
- */
2584
- protected _onTrafficRequest(): Promise<any>;
2585
- /**
2586
- * `Network.responseReceived` handler, resolving the matching pending `response` promise pushed
2587
- * by `_onTrafficRequest` with a Puppeteer-`HTTPResponse`-like object.
2588
- */
2589
- protected _onTrafficResponse(): Promise<any>;
2590
- /**
2591
- * `Network.loadingFailed` handler, resolving a still-pending `response` promise to `null`
2592
- * (matching Puppeteer's `request.response()` for a failed request) so `grabRecordedNetworkTraffics`
2593
- * never awaits a promise that would otherwise never settle.
2594
- */
2595
- protected _onTrafficLoadingFailed(): Promise<any>;
2500
+ startRecordingTraffic(): Promise<any>;
2596
2501
  /**
2597
2502
  * Grab the recording network traffics
2598
2503
  *
@@ -2665,8 +2570,7 @@ declare namespace CodeceptJS {
2665
2570
  url: string | RegExp;
2666
2571
  }): Promise<any>;
2667
2572
  /**
2668
- * Stops recording network traffic started by `startRecordingTraffic`. Already-recorded requests
2669
- * in `this.requests` are kept; only new requests stop being appended.
2573
+ * Stops recording of network traffic. Recorded traffic is not flashed.
2670
2574
  *
2671
2575
  * ```js
2672
2576
  * I.stopRecordingTraffic();
@@ -2682,46 +2586,134 @@ declare namespace CodeceptJS {
2682
2586
  */
2683
2587
  flushNetworkTraffics(): Promise<any>;
2684
2588
  /**
2685
- * Starts recording a CDP `Page.startScreencast` session for the current test's target: frames
2686
- * arrive as `Page.screencastFrame` events, are acknowledged immediately (`Page.screencastFrameAck`,
2687
- * required or the browser stops sending more), and buffered in `this._screencastFrames`. The
2688
- * underlying `Page.screencastFrame` listener is installed once (lazily) and left in place, like
2689
- * `startRecordingTraffic`'s listeners, since `CDPConnection` has no listener-removal API; it
2690
- * filters by `this.sessionId` so only the currently active test's frames are buffered. Call
2691
- * `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.
2692
2591
  *
2693
2592
  * ```js
2694
2593
  * I.startScreencast();
2695
2594
  * ```
2696
- * @param [options] - {maxWidth: number, maxHeight: number, quality: number, everyNthFrame: number} — CDP `Page.startScreencast` pass-throughs. `format` is always `'png'`.
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.
2697
2606
  */
2698
- startScreencast(options?: any): Promise<void>;
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 {
2699
2690
  /**
2700
- * `Page.screencastFrame` handler: ignores frames from a session other than the currently active
2701
- * one (stale frames from a previous test, since the listener is never removed), acknowledges the
2702
- * frame so the browser keeps sending more, and buffers `{data, timestamp}` for `stopScreencast`
2703
- * to assemble.
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.
2704
2702
  */
2705
- protected _onScreencastFrame(): Promise<any>;
2703
+ decide(statements: string | string[]): Promise<number | number[] | undefined>;
2706
2704
  /**
2707
- * Stops the screencast started by `startScreencast` and assembles the buffered frames into a
2708
- * single APNG (Animated PNG) file, returned as a Buffer. Frame delays are derived from the CDP
2709
- * frame metadata's `timestamp` deltas (frame arrival is activity-driven — Obscura and Chrome both
2710
- * only emit a frame on damage — so this reproduces the actual pacing of what happened, not a
2711
- * fixed frame rate); the last frame is held for `options.lastFrameDelayMs` (default 1000ms) since
2712
- * it has no "next" frame to derive a delay from. Every frame is checked for the PNG signature
2713
- * before assembly — CDP's `format: 'png'` is honored by both Chrome and Obscura (verified
2714
- * directly), but if some other engine ever sends a different format regardless, this reports it
2715
- * via `debugSection` and returns `null` instead of muxing a broken file. Returns `null` if no
2716
- * 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.
2717
2708
  *
2718
2709
  * ```js
2719
- * const apngBuffer = await I.stopScreencast();
2710
+ * I.decideVisually('sidebar is shown');
2711
+ * I.decideVisually(['logo is in the header', 'page uses dark theme']);
2720
2712
  * ```
2721
- * @param [options] - {lastFrameDelayMs: number} — hold time in milliseconds for the final frame (default 1000).
2722
- * @returns a Buffer with the assembled APNG, or null if there was nothing to assemble.
2713
+ * @param statements - statement or list of statements to verify.
2714
+ * @returns probability of each statement, `undefined` in `skip` mode.
2723
2715
  */
2724
- stopScreencast(options?: any): Promise<object>;
2716
+ decideVisually(statements: string | string[]): Promise<number | number[] | undefined>;
2725
2717
  }
2726
2718
  /**
2727
2719
  * Helper for testing filesystem.
@@ -3298,15 +3290,14 @@ declare namespace CodeceptJS {
3298
3290
  /**
3299
3291
  * ## Configuration
3300
3292
  *
3301
- * This helper should be configured in codecept.conf.js. It accepts everything `CDPBrowser`
3302
- * accepts (see its config table), plus:
3293
+ * This helper should be configured in codecept.conf.js
3303
3294
  * @property [url = http://localhost] - base URL for tests
3304
3295
  * @property [accountId] - Cloudflare account ID; defaults to CF_ACCOUNT_ID env var
3305
3296
  * @property [apiToken] - Cloudflare API token; defaults to CF_API_TOKEN env var
3306
3297
  * @property [keepAlive = 240000] - session keep-alive time in milliseconds
3307
3298
  * @property [apiBase = https://api.cloudflare.com/client/v4] - Cloudflare API base URL
3308
- * @property [input = cdp] - input method for user actions; defaults to 'cdp' for Kitesurf's real layout engine, but can be overridden
3309
- * @property [capabilities] - pre-configured capabilities; Kitesurf uses { layout: 'real', screenshot: true }
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 }`.
3310
3301
  */
3311
3302
  type KitesurfConfig = {
3312
3303
  url?: string;
@@ -3373,55 +3364,146 @@ declare namespace CodeceptJS {
3373
3364
  */
3374
3365
  class KitesurfTs {
3375
3366
  constructor(config: KitesurfConfig);
3376
- /**
3377
- * Acquires a Kitesurf browser session from the Cloudflare Browser Run API and resolves it to
3378
- * the `wss://` debugger URL `CDPConnection` connects to. Overrides `CDPBrowser._resolveEndpoint`,
3379
- * which resolves a fixed local endpoint instead of provisioning a cloud session per test.
3380
- * @returns a `wss://` debugger URL ready to be passed to `CDPConnection`.
3381
- */
3382
- protected _resolveEndpoint(): Promise<string>;
3383
- /**
3384
- * Closes the target as `CDPBrowser._finishTest` does, then releases the cloud session acquired
3385
- * in `_resolveEndpoint` via the Cloudflare API so it does not linger for the full `keepAlive`
3386
- * window. The release runs in a `finally` so a rejection while closing the CDP connection still
3387
- * frees the cloud session instead of leaving the browser alive until `keepAlive` expires; the
3388
- * session id is cleared before the request, so a repeated call never releases it twice.
3389
- */
3390
- protected _finishTest(): Promise<any>;
3391
3367
  }
3392
3368
  /**
3393
3369
  * ## Configuration
3394
3370
  *
3395
- * This helper should be configured in codecept.conf.js. It accepts everything `CDPBrowser`
3396
- * accepts (see its config table), plus:
3371
+ * This helper should be configured in codecept.conf.js
3397
3372
  * @property [endpoint] - explicit CDP endpoint. Setting this switches the helper to ATTACH
3398
3373
  * mode: it only connects, and never spawns or kills a process, no matter what else is configured.
3399
3374
  * Leave it unset for SELF-MANAGED mode (see below).
3400
- * @property [binaryPath] - path to the `obscura` executable, used in SELF-MANAGED mode
3401
- * (`endpoint` unset). Checked before `OBSCURA_PATH` and `PATH`.
3402
- * @property [port] - port `obscura serve` listens on, in SELF-MANAGED mode. When unset, a
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
3403
3378
  * free port is picked automatically, which is what makes `run-workers` collision-free — every
3404
3379
  * worker gets its own instance on its own port with zero config.
3405
- * @property [serverStartTimeout = 15000] - milliseconds to wait for a spawned `obscura serve`
3380
+ * @property [serverStartTimeout = 15000] - milliseconds to wait for a spawned `lightpanda serve`
3406
3381
  * to answer `/json/version` before `_connect` gives up.
3407
3382
  */
3408
- type ObscuraConfig = {
3383
+ type LightpandaConfig = {
3409
3384
  endpoint?: string;
3410
3385
  binaryPath?: string;
3411
3386
  port?: number;
3412
3387
  serverStartTimeout?: number;
3413
3388
  };
3414
3389
  /**
3415
- * Obscura drives [Obscura](https://github.com/h4ckf0r0day/obscura), a minimal headless
3416
- * browser exposed over the Chrome DevTools Protocol. From v0.2.0, default release builds ship a
3417
- * real rendering engine (layout, paint, screenshots); `-no-render` variants and v0.1.x builds keep
3418
- * the original single-V8-isolate, nothing-rendered mode. This helper does not hardcode which mode a
3419
- * given binary is in — `CDPBrowser._probeCapabilities` detects `layout`/`screenshot` per binary at
3420
- * 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.
3421
3394
  *
3422
3395
  * This helper is a thin `CDPBrowser` subclass: it changes nothing about how locating or acting on
3423
- * elements works, it only pins the config presets Obscura requires and manages the `obscura serve`
3424
- * 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.
3425
3507
  *
3426
3508
  * > Obscura support is experimental in CodeceptJS 4.2. Pin the browser version in CI and keep a
3427
3509
  * > Playwright/WebDriver job for browser-compatibility coverage.
@@ -3441,8 +3523,8 @@ declare namespace CodeceptJS {
3441
3523
  * - **SELF-LAUNCH** — `endpoint` is unset and a binary can be resolved, in order: `binaryPath` in
3442
3524
  * the config, then the `OBSCURA_PATH` environment variable, then `obscura` on `PATH`. The helper
3443
3525
  * spawns `obscura serve --port <port> --allow-private-network --allow-file-access` (`port` from
3444
- * the config, or a free port picked automatically), waits for it to answer, connects, and kills
3445
- * it in `_finishTest`.
3526
+ * the config, or a free port picked automatically), waits for it to answer, connects, and stops
3527
+ * it when tests finish.
3446
3528
  * - **COURTESY-ATTACH** — `endpoint` is unset and no binary can be resolved, but something already
3447
3529
  * answers `http://127.0.0.1:9222/json/version` (e.g. `obscura serve` started by hand, or by CI
3448
3530
  * before this process ever ran). The helper attaches to it and never kills it — it isn't the
@@ -3481,13 +3563,11 @@ declare namespace CodeceptJS {
3481
3563
  *
3482
3564
  * | option | value | why |
3483
3565
  * | --- | --- | --- |
3484
- * | `input` | `synthetic` | coordinate-click navigation is unreliable over CDP on Obscura even on rendering builds (no `frameNavigated` event, stale `page.url()`); `click` always takes the `forceClick` path — on Obscura, `click` and `forceClick` are the same thing |
3485
- * | `xpathPolyfill` | `auto` | probed per binary/page: Obscura's native `document.evaluate` still doesn't support attribute selection or `not()`, so the polyfill is used until that lands |
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 |
3486
3568
  *
3487
- * `capabilities.layout`/`capabilities.screenshot`/`capabilities.xpath` are intentionally left
3488
- * unset here — `CDPBrowser._probeCapabilities` detects them at runtime from the actual binary
3489
- * (`'real'`/`true` on v0.2.0+ default builds, `'none'`/`false` on `-no-render` builds and v0.1.x).
3490
- * 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.
3491
3571
  *
3492
3572
  * ## Limitations
3493
3573
  *
@@ -3534,62 +3614,6 @@ declare namespace CodeceptJS {
3534
3614
  */
3535
3615
  class ObscuraTs {
3536
3616
  constructor(config: ObscuraConfig);
3537
- /**
3538
- * In ATTACH mode, connects exactly as `CDPBrowser._connect` would. In SELF-MANAGED mode,
3539
- * resolves and spawns `obscura serve` (or courtesy-attaches to an already-running one on
3540
- * :9222) exactly once via `_resolveSelfManaged`, then connects.
3541
- *
3542
- * A spawn failure (e.g. a bad binary) is delivered asynchronously by Node as an `error`
3543
- * event; it is recorded on `this.serverError` and surfaced as a rejection from `_waitForServer`
3544
- * instead of crashing the process as an uncaught exception.
3545
- */
3546
- protected _connect(): Promise<any>;
3547
- /**
3548
- * Resolves how to reach Obscura when no explicit `endpoint` was configured, trying, in order:
3549
- * spawn a binary (`binaryPath` config, then `OBSCURA_PATH` env, then `obscura` on `PATH`),
3550
- * courtesy-attach to `http://127.0.0.1:9222` if something already answers there, or throw a
3551
- * loud, actionable error. Sets `this.options.endpoint` as a side effect.
3552
- */
3553
- protected _resolveSelfManaged(): Promise<any>;
3554
- /**
3555
- * Resolves the `obscura` binary to spawn, in priority order: `options.binaryPath`, then the
3556
- * `OBSCURA_PATH` environment variable, then `obscura` on `PATH`. The `PATH` lookup walks the
3557
- * directories itself instead of shelling out to `which`, which does not exist on Windows: on
3558
- * Windows every `PATHEXT` suffix is tried, so an `obscura.exe` on `PATH` is found too.
3559
- */
3560
- protected _resolveBinary(): Promise<any>;
3561
- /**
3562
- * Picks a free TCP port on 127.0.0.1 by briefly listening on port 0 and reading back the OS-assigned
3563
- * port. Used as the SELF-LAUNCH default when `options.port` isn't explicitly set, so multiple
3564
- * `run-workers` workers never collide on the same port.
3565
- * @returns a free port.
3566
- */
3567
- protected _findFreePort(): Promise<number>;
3568
- /**
3569
- * Probes a `/json/version`-style URL with a short timeout, used for the COURTESY-ATTACH check.
3570
- * @returns true if the URL answered.
3571
- */
3572
- protected _probeUp(url: string): Promise<boolean>;
3573
- /**
3574
- * Polls `http://127.0.0.1:<port>/json/version` until `obscura serve` responds, `this.serverError`
3575
- * is set by the spawned process' `error` event, or `options.serverStartTimeout` elapses. The
3576
- * process typically comes up within tens of milliseconds — a 20ms retry interval (down from a
3577
- * previous 200ms) keeps the wasted tail after the server is actually ready small, since this cost
3578
- * is paid once per run and counts directly toward real-world startup latency.
3579
- */
3580
- protected _waitForServer(): Promise<any>;
3581
- /**
3582
- * Closes the CDP connection (via `CDPBrowser._finishTest`), then kills the `obscura serve`
3583
- * process spawned by `_connect`, if any (never runs in ATTACH or COURTESY-ATTACH mode, since
3584
- * `this.serverProcess` is only ever set in SELF-LAUNCH mode). Runs in a `finally` so the process
3585
- * is always reaped even if closing the CDP connection throws. Sends `SIGTERM` first and waits for
3586
- * the process to exit; a process that ignores `SIGTERM` is escalated to `SIGKILL` after 5s. The
3587
- * promise only resolves once the child has actually exited (confirmed via the `exit` event, not
3588
- * merely once `SIGKILL` was sent — the kernel needs a moment to reap it), with a final safety-net
3589
- * timeout so a stuck child can never keep the event loop alive even if that confirmation is
3590
- * somehow lost.
3591
- */
3592
- protected _finishTest(): Promise<any>;
3593
3617
  }
3594
3618
  /**
3595
3619
  * ## Configuration
@@ -5107,6 +5131,55 @@ declare namespace CodeceptJS {
5107
5131
  * @param [cookie = null] - (optional, `null` by default) cookie name
5108
5132
  */
5109
5133
  clearCookie(cookie?: string): Promise<any>;
5134
+ /**
5135
+ * Checks that the system clipboard contains the given text.
5136
+ *
5137
+ * ```js
5138
+ * I.click('Copy to clipboard');
5139
+ * I.seeInClipboard('https://codecept.io');
5140
+ * ```
5141
+ *
5142
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5143
+ * in Chromium-based browsers, where read access is granted automatically.
5144
+ * @param text - value to check.
5145
+ */
5146
+ seeInClipboard(text: string): Promise<any>;
5147
+ /**
5148
+ * Checks that the system clipboard is equal to the given text.
5149
+ *
5150
+ * ```js
5151
+ * I.click('Copy to clipboard');
5152
+ * I.seeClipboardEquals('https://codecept.io');
5153
+ * ```
5154
+ *
5155
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5156
+ * in Chromium-based browsers, where read access is granted automatically.
5157
+ * @param text - value to check.
5158
+ */
5159
+ seeClipboardEquals(text: string): Promise<any>;
5160
+ /**
5161
+ * Grabs the text content of the system clipboard and returns it to test.
5162
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
5163
+ *
5164
+ * ```js
5165
+ * I.click('Copy to clipboard');
5166
+ * let url = await I.grabFromClipboard();
5167
+ * ```
5168
+ *
5169
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
5170
+ * in Chromium-based browsers, where read access is granted automatically.
5171
+ * @returns the system clipboard contents.
5172
+ */
5173
+ grabFromClipboard(): Promise<string>;
5174
+ /**
5175
+ * Clears the system clipboard.
5176
+ *
5177
+ * ```js
5178
+ * I.clearClipboard();
5179
+ * I.seeClipboardEquals('');
5180
+ * ```
5181
+ */
5182
+ clearClipboard(): Promise<any>;
5110
5183
  /**
5111
5184
  * Executes a script on the page:
5112
5185
  *
@@ -7188,6 +7261,55 @@ declare namespace CodeceptJS {
7188
7261
  * @param [cookie = null] - (optional, `null` by default) cookie name
7189
7262
  */
7190
7263
  clearCookie(cookie?: string): Promise<any>;
7264
+ /**
7265
+ * Checks that the system clipboard contains the given text.
7266
+ *
7267
+ * ```js
7268
+ * I.click('Copy to clipboard');
7269
+ * I.seeInClipboard('https://codecept.io');
7270
+ * ```
7271
+ *
7272
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7273
+ * in Chromium-based browsers, where read access is granted automatically.
7274
+ * @param text - value to check.
7275
+ */
7276
+ seeInClipboard(text: string): Promise<any>;
7277
+ /**
7278
+ * Checks that the system clipboard is equal to the given text.
7279
+ *
7280
+ * ```js
7281
+ * I.click('Copy to clipboard');
7282
+ * I.seeClipboardEquals('https://codecept.io');
7283
+ * ```
7284
+ *
7285
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7286
+ * in Chromium-based browsers, where read access is granted automatically.
7287
+ * @param text - value to check.
7288
+ */
7289
+ seeClipboardEquals(text: string): Promise<any>;
7290
+ /**
7291
+ * Grabs the text content of the system clipboard and returns it to test.
7292
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
7293
+ *
7294
+ * ```js
7295
+ * I.click('Copy to clipboard');
7296
+ * let url = await I.grabFromClipboard();
7297
+ * ```
7298
+ *
7299
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
7300
+ * in Chromium-based browsers, where read access is granted automatically.
7301
+ * @returns the system clipboard contents.
7302
+ */
7303
+ grabFromClipboard(): Promise<string>;
7304
+ /**
7305
+ * Clears the system clipboard.
7306
+ *
7307
+ * ```js
7308
+ * I.clearClipboard();
7309
+ * I.seeClipboardEquals('');
7310
+ * ```
7311
+ */
7312
+ clearClipboard(): Promise<any>;
7191
7313
  /**
7192
7314
  * If a function returns a Promise, tt will wait for its resolution.
7193
7315
  *
@@ -9505,6 +9627,55 @@ declare namespace CodeceptJS {
9505
9627
  * @param [name = null] - cookie name.
9506
9628
  */
9507
9629
  grabCookie(name?: string): Promise<any>;
9630
+ /**
9631
+ * Checks that the system clipboard contains the given text.
9632
+ *
9633
+ * ```js
9634
+ * I.click('Copy to clipboard');
9635
+ * I.seeInClipboard('https://codecept.io');
9636
+ * ```
9637
+ *
9638
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9639
+ * in Chromium-based browsers, where read access is granted automatically.
9640
+ * @param text - value to check.
9641
+ */
9642
+ seeInClipboard(text: string): Promise<any>;
9643
+ /**
9644
+ * Checks that the system clipboard is equal to the given text.
9645
+ *
9646
+ * ```js
9647
+ * I.click('Copy to clipboard');
9648
+ * I.seeClipboardEquals('https://codecept.io');
9649
+ * ```
9650
+ *
9651
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9652
+ * in Chromium-based browsers, where read access is granted automatically.
9653
+ * @param text - value to check.
9654
+ */
9655
+ seeClipboardEquals(text: string): Promise<any>;
9656
+ /**
9657
+ * Grabs the text content of the system clipboard and returns it to test.
9658
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
9659
+ *
9660
+ * ```js
9661
+ * I.click('Copy to clipboard');
9662
+ * let url = await I.grabFromClipboard();
9663
+ * ```
9664
+ *
9665
+ * Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
9666
+ * in Chromium-based browsers, where read access is granted automatically.
9667
+ * @returns the system clipboard contents.
9668
+ */
9669
+ grabFromClipboard(): Promise<string>;
9670
+ /**
9671
+ * Clears the system clipboard.
9672
+ *
9673
+ * ```js
9674
+ * I.clearClipboard();
9675
+ * I.seeClipboardEquals('');
9676
+ * ```
9677
+ */
9678
+ clearClipboard(): Promise<any>;
9508
9679
  /**
9509
9680
  * Waits for the specified cookie in the cookies.
9510
9681
  *