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