codeceptjs 2.4.3 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/README.md +32 -7
  3. package/bin/codecept.js +3 -0
  4. package/docs/basics.md +11 -5
  5. package/docs/bdd.md +4 -4
  6. package/docs/build/MockRequest.js +3 -0
  7. package/docs/build/Nightmare.js +10 -2
  8. package/docs/build/Playwright.js +3187 -0
  9. package/docs/build/Protractor.js +16 -2
  10. package/docs/build/Puppeteer.js +126 -19
  11. package/docs/build/REST.js +3 -1
  12. package/docs/build/TestCafe.js +11 -3
  13. package/docs/build/WebDriver.js +361 -28
  14. package/docs/changelog.md +116 -0
  15. package/docs/configuration.md +2 -2
  16. package/docs/custom-helpers.md +55 -10
  17. package/docs/helpers/Appium.md +81 -1
  18. package/docs/helpers/MockRequest.md +281 -38
  19. package/docs/helpers/Nightmare.md +10 -2
  20. package/docs/helpers/Playwright.md +1770 -0
  21. package/docs/helpers/Protractor.md +15 -3
  22. package/docs/helpers/Puppeteer-firefox.md +32 -1
  23. package/docs/helpers/Puppeteer.md +126 -76
  24. package/docs/helpers/TestCafe.md +10 -2
  25. package/docs/helpers/WebDriver.md +208 -118
  26. package/docs/locators.md +2 -0
  27. package/docs/playwright.md +306 -0
  28. package/docs/plugins.md +103 -0
  29. package/docs/reports.md +12 -0
  30. package/docs/shadow.md +68 -0
  31. package/docs/visual.md +0 -73
  32. package/docs/webapi/forceClick.mustache +27 -0
  33. package/docs/webapi/seeInPopup.mustache +7 -0
  34. package/docs/webapi/setCookie.mustache +10 -2
  35. package/docs/webapi/type.mustache +12 -0
  36. package/docs/webdriver.md +7 -3
  37. package/lib/codecept.js +1 -1
  38. package/lib/command/definitions.js +2 -2
  39. package/lib/command/generate.js +4 -4
  40. package/lib/command/gherkin/snippets.js +4 -4
  41. package/lib/command/init.js +1 -1
  42. package/lib/command/interactive.js +3 -0
  43. package/lib/command/run-multiple.js +2 -2
  44. package/lib/command/run-rerun.js +2 -0
  45. package/lib/command/run-workers.js +22 -8
  46. package/lib/command/run.js +2 -0
  47. package/lib/command/workers/runTests.js +1 -0
  48. package/lib/container.js +1 -1
  49. package/lib/event.js +2 -0
  50. package/lib/helper/MockRequest.js +3 -0
  51. package/lib/helper/Playwright.js +2422 -0
  52. package/lib/helper/Protractor.js +1 -2
  53. package/lib/helper/Puppeteer.js +84 -19
  54. package/lib/helper/REST.js +3 -1
  55. package/lib/helper/TestCafe.js +1 -1
  56. package/lib/helper/WebDriver.js +313 -26
  57. package/lib/helper/extras/PlaywrightPropEngine.js +53 -0
  58. package/lib/helper/scripts/isElementClickable.js +54 -14
  59. package/lib/interfaces/gherkin.js +1 -1
  60. package/lib/listener/helpers.js +3 -0
  61. package/lib/locator.js +5 -0
  62. package/lib/mochaFactory.js +12 -10
  63. package/lib/plugin/allure.js +8 -1
  64. package/lib/plugin/autoDelay.js +1 -8
  65. package/lib/plugin/commentStep.js +133 -0
  66. package/lib/plugin/screenshotOnFail.js +3 -10
  67. package/lib/plugin/selenoid.js +2 -2
  68. package/lib/plugin/standardActingHelpers.js +13 -0
  69. package/lib/plugin/stepByStepReport.js +1 -8
  70. package/lib/plugin/wdio.js +10 -1
  71. package/lib/reporter/cli.js +30 -1
  72. package/lib/session.js +7 -4
  73. package/package.json +13 -10
  74. package/typings/Mocha.d.ts +567 -16
  75. package/typings/index.d.ts +9 -5
  76. package/typings/types.d.ts +1634 -74
@@ -1871,18 +1871,26 @@ declare namespace CodeceptJS {
1871
1871
  */
1872
1872
  selectOption(select: CodeceptJS.LocatorOrString, option: string | any[]): void;
1873
1873
  /**
1874
- * Sets a cookie.
1874
+ * Sets cookie(s).
1875
+ *
1876
+ * Can be a single cookie object or an array of cookies:
1875
1877
  *
1876
1878
  * ```js
1877
1879
  * I.setCookie({name: 'auth', value: true});
1880
+ *
1881
+ * // as array
1882
+ * I.setCookie([
1883
+ * {name: 'auth', value: true},
1884
+ * {name: 'agree', value: true}
1885
+ * ]);
1878
1886
  * ```
1879
1887
  *
1880
- * @param {object} cookie a cookie object.
1888
+ * @param {object|array} cookie a cookie object or array of cookie objects.
1881
1889
  *
1882
1890
  * Wrapper for `.cookies.set(cookie)`.
1883
1891
  * [See more](https://github.com/segmentio/nightmare/blob/master/Readme.md#cookiessetcookie)
1884
1892
  */
1885
- setCookie(cookie: any): void;
1893
+ setCookie(cookie: any | any[]): void;
1886
1894
  /**
1887
1895
  * Checks that cookie with given name exists.
1888
1896
  *
@@ -1977,21 +1985,1361 @@ declare namespace CodeceptJS {
1977
1985
  *
1978
1986
  * @param {string }text to wait for.
1979
1987
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
1980
- * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
1988
+ * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
1989
+ */
1990
+ waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): void;
1991
+ /**
1992
+ * Waits for an element to become visible on a page (by default waits for 1sec).
1993
+ * Element can be located by CSS or XPath.
1994
+ *
1995
+ * ```js
1996
+ * I.waitForVisible('#popup');
1997
+ * ```
1998
+ *
1999
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2000
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2001
+ */
2002
+ waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2003
+ /**
2004
+ * Waits for an element to hide (by default waits for 1sec).
2005
+ * Element can be located by CSS or XPath.
2006
+ *
2007
+ * ```js
2008
+ * I.waitToHide('#popup');
2009
+ * ```
2010
+ *
2011
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2012
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2013
+ */
2014
+ waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2015
+ /**
2016
+ * Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
2017
+ * Element can be located by CSS or XPath.
2018
+ *
2019
+ * ```js
2020
+ * I.waitForInvisible('#popup');
2021
+ * ```
2022
+ *
2023
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2024
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2025
+ */
2026
+ waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2027
+ /**
2028
+ * Waits for element to be present on page (by default waits for 1sec).
2029
+ * Element can be located by CSS or XPath.
2030
+ *
2031
+ * ```js
2032
+ * I.waitForElement('.btn.continue');
2033
+ * I.waitForElement('.btn.continue', 5); // wait for 5 secs
2034
+ * ```
2035
+ *
2036
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2037
+ * @param {number} [sec] (optional, `1` by default) time in seconds to wait
2038
+ */
2039
+ waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2040
+ /**
2041
+ * Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
2042
+ * Element can be located by CSS or XPath.
2043
+ *
2044
+ * ```js
2045
+ * I.waitForDetached('#popup');
2046
+ * ```
2047
+ *
2048
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2049
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2050
+ */
2051
+ waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2052
+ /**
2053
+ * Reload the current page.
2054
+ *
2055
+ * ```js
2056
+ * I.refreshPage();
2057
+ * ```
2058
+ *
2059
+ */
2060
+ refreshPage(): void;
2061
+ /**
2062
+ * Reload the page
2063
+ */
2064
+ refresh(): void;
2065
+ /**
2066
+ * Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
2067
+ * Filename is relative to output folder.
2068
+ * Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
2069
+ *
2070
+ * ```js
2071
+ * I.saveScreenshot('debug.png');
2072
+ * I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
2073
+ * ```
2074
+ *
2075
+ * @param {string} fileName file name to save.
2076
+ * @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
2077
+ */
2078
+ saveScreenshot(fileName: string, fullPage?: boolean): void;
2079
+ /**
2080
+ * Scrolls to element matched by locator.
2081
+ * Extra shift can be set with offsetX and offsetY options.
2082
+ *
2083
+ * ```js
2084
+ * I.scrollTo('footer');
2085
+ * I.scrollTo('#submit', 5, 5);
2086
+ * ```
2087
+ *
2088
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2089
+ * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
2090
+ * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
2091
+ */
2092
+ scrollTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): void;
2093
+ /**
2094
+ * Scroll page to the top.
2095
+ *
2096
+ * ```js
2097
+ * I.scrollPageToTop();
2098
+ * ```
2099
+ *
2100
+ */
2101
+ scrollPageToTop(): void;
2102
+ /**
2103
+ * Scroll page to the bottom.
2104
+ *
2105
+ * ```js
2106
+ * I.scrollPageToBottom();
2107
+ * ```
2108
+ *
2109
+ */
2110
+ scrollPageToBottom(): void;
2111
+ /**
2112
+ * Retrieves a page scroll position and returns it to test.
2113
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2114
+ *
2115
+ * ```js
2116
+ * let { x, y } = await I.grabPageScrollPosition();
2117
+ * ```
2118
+ *
2119
+ * @returns {Promise<Object<string, *>>} scroll position
2120
+ */
2121
+ grabPageScrollPosition(): Promise<{
2122
+ [key: string]: any;
2123
+ }>;
2124
+ }
2125
+ class Playwright {
2126
+ /**
2127
+ * Set the automatic popup response to Accept.
2128
+ * This must be set before a popup is triggered.
2129
+ *
2130
+ * ```js
2131
+ * I.amAcceptingPopups();
2132
+ * I.click('#triggerPopup');
2133
+ * I.acceptPopup();
2134
+ * ```
2135
+ */
2136
+ amAcceptingPopups(): void;
2137
+ /**
2138
+ * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
2139
+ * Don't confuse popups with modal windows, as created by [various
2140
+ * libraries](http://jster.net/category/windows-modals-popups).
2141
+ */
2142
+ acceptPopup(): void;
2143
+ /**
2144
+ * Set the automatic popup response to Cancel/Dismiss.
2145
+ * This must be set before a popup is triggered.
2146
+ *
2147
+ * ```js
2148
+ * I.amCancellingPopups();
2149
+ * I.click('#triggerPopup');
2150
+ * I.cancelPopup();
2151
+ * ```
2152
+ */
2153
+ amCancellingPopups(): void;
2154
+ /**
2155
+ * Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
2156
+ */
2157
+ cancelPopup(): void;
2158
+ /**
2159
+ * Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
2160
+ * given string.
2161
+ *
2162
+ * ```js
2163
+ * I.seeInPopup('Popup text');
2164
+ * ```
2165
+ * @param {string} text value to check.
2166
+ *
2167
+ */
2168
+ seeInPopup(text: string): void;
2169
+ /**
2170
+ * Set current page
2171
+ * @param {object} page page to set
2172
+ */
2173
+ _setPage(page: any): void;
2174
+ /**
2175
+ * Add the 'dialog' event listener to a page
2176
+ * @page {playwright.Page}
2177
+ *
2178
+ * The popup listener handles the dialog with the predefined action when it appears on the page.
2179
+ * It also saves a reference to the object which is used in seeInPopup.
2180
+ */
2181
+ _addPopupListener(): void;
2182
+ /**
2183
+ * Gets page URL including hash.
2184
+ */
2185
+ _getPageUrl(): void;
2186
+ /**
2187
+ * Grab the text within the popup. If no popup is visible then it will return null
2188
+ *
2189
+ * ```js
2190
+ * await I.grabPopupText();
2191
+ * ```
2192
+ * @return {Promise<string | null>}
2193
+ */
2194
+ grabPopupText(): Promise<string | null>;
2195
+ /**
2196
+ * Opens a web page in a browser. Requires relative or absolute url.
2197
+ * If url starts with `/`, opens a web page of a site defined in `url` config parameter.
2198
+ *
2199
+ * ```js
2200
+ * I.amOnPage('/'); // opens main page of website
2201
+ * I.amOnPage('https://github.com'); // opens github
2202
+ * I.amOnPage('/login'); // opens a login page
2203
+ * ```
2204
+ *
2205
+ * @param {string} url url path or global url.
2206
+ */
2207
+ amOnPage(url: string): void;
2208
+ /**
2209
+ * Resize the current window to provided width and height.
2210
+ * First parameter can be set to `maximize`.
2211
+ *
2212
+ * @param {number} width width in pixels or `maximize`.
2213
+ * @param {number} height height in pixels.
2214
+ *
2215
+ * Unlike other drivers Playwright changes the size of a viewport, not the window!
2216
+ * Playwright does not control the window of a browser so it can't adjust its real size.
2217
+ * It also can't maximize a window.
2218
+ *
2219
+ * Update configuration to change real window size on start:
2220
+ *
2221
+ * ```js
2222
+ * // inside codecept.conf.js
2223
+ * // @codeceptjs/configure package must be installed
2224
+ * { setWindowSize } = require('@codeceptjs/configure');
2225
+ * ````
2226
+ */
2227
+ resizeWindow(width: number, height: number): void;
2228
+ /**
2229
+ * Set headers for all next requests
2230
+ *
2231
+ * ```js
2232
+ * I.haveRequestHeaders({
2233
+ * 'X-Sent-By': 'CodeceptJS',
2234
+ * });
2235
+ * ```
2236
+ *
2237
+ * @param {object} customHeaders headers to set
2238
+ */
2239
+ haveRequestHeaders(customHeaders: any): void;
2240
+ /**
2241
+ * Moves cursor to element matched by locator.
2242
+ * Extra shift can be set with offsetX and offsetY options.
2243
+ *
2244
+ * ```js
2245
+ * I.moveCursorTo('.tooltip');
2246
+ * I.moveCursorTo('#submit', 5,5);
2247
+ * ```
2248
+ *
2249
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2250
+ * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
2251
+ * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
2252
+ *
2253
+ *
2254
+ */
2255
+ moveCursorTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): void;
2256
+ /**
2257
+ * Drag an item to a destination element.
2258
+ *
2259
+ * ```js
2260
+ * I.dragAndDrop('#dragHandle', '#container');
2261
+ * ```
2262
+ *
2263
+ * @param {string|object} srcElement located by CSS|XPath|strict locator.
2264
+ * @param {string|object} destElement located by CSS|XPath|strict locator.
2265
+ */
2266
+ dragAndDrop(srcElement: string | any, destElement: string | any): void;
2267
+ /**
2268
+ * Reload the current page.
2269
+ *
2270
+ * ```js
2271
+ * I.refreshPage();
2272
+ * ```
2273
+ *
2274
+ */
2275
+ refreshPage(): void;
2276
+ /**
2277
+ * Scroll page to the top.
2278
+ *
2279
+ * ```js
2280
+ * I.scrollPageToTop();
2281
+ * ```
2282
+ *
2283
+ */
2284
+ scrollPageToTop(): void;
2285
+ /**
2286
+ * Scroll page to the bottom.
2287
+ *
2288
+ * ```js
2289
+ * I.scrollPageToBottom();
2290
+ * ```
2291
+ *
2292
+ */
2293
+ scrollPageToBottom(): void;
2294
+ /**
2295
+ * Scrolls to element matched by locator.
2296
+ * Extra shift can be set with offsetX and offsetY options.
2297
+ *
2298
+ * ```js
2299
+ * I.scrollTo('footer');
2300
+ * I.scrollTo('#submit', 5, 5);
2301
+ * ```
2302
+ *
2303
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2304
+ * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
2305
+ * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
2306
+ */
2307
+ scrollTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): void;
2308
+ /**
2309
+ * Checks that title contains text.
2310
+ *
2311
+ * ```js
2312
+ * I.seeInTitle('Home Page');
2313
+ * ```
2314
+ *
2315
+ * @param {string} text text value to check.
2316
+ */
2317
+ seeInTitle(text: string): void;
2318
+ /**
2319
+ * Retrieves a page scroll position and returns it to test.
2320
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2321
+ *
2322
+ * ```js
2323
+ * let { x, y } = await I.grabPageScrollPosition();
2324
+ * ```
2325
+ *
2326
+ * @returns {Promise<Object<string, *>>} scroll position
2327
+ */
2328
+ grabPageScrollPosition(): Promise<{
2329
+ [key: string]: any;
2330
+ }>;
2331
+ /**
2332
+ * Checks that title is equal to provided one.
2333
+ *
2334
+ * ```js
2335
+ * I.seeTitleEquals('Test title.');
2336
+ * ```
2337
+ */
2338
+ seeTitleEquals(): void;
2339
+ /**
2340
+ * Checks that title does not contain text.
2341
+ *
2342
+ * ```js
2343
+ * I.dontSeeInTitle('Error');
2344
+ * ```
2345
+ *
2346
+ * @param {string} text value to check.
2347
+ */
2348
+ dontSeeInTitle(text: string): void;
2349
+ /**
2350
+ * Retrieves a page title and returns it to test.
2351
+ * Resumes test execution, so **should be used inside async with `await`** operator.
2352
+ *
2353
+ * ```js
2354
+ * let title = await I.grabTitle();
2355
+ * ```
2356
+ *
2357
+ * @returns {Promise<string>} title
2358
+ */
2359
+ grabTitle(): Promise<string>;
2360
+ /**
2361
+ * Get elements by different locator types, including strict locator
2362
+ * Should be used in custom helpers:
2363
+ *
2364
+ * ```js
2365
+ * const elements = await this.helpers['Playwright']._locate({name: 'password'});
2366
+ * ```
2367
+ *
2368
+ *
2369
+ */
2370
+ _locate(): void;
2371
+ /**
2372
+ * Find a checkbox by providing human readable text:
2373
+ * NOTE: Assumes the checkable element exists
2374
+ *
2375
+ * ```js
2376
+ * this.helpers['Playwright']._locateCheckable('I agree with terms and conditions').then // ...
2377
+ * ```
2378
+ */
2379
+ _locateCheckable(): void;
2380
+ /**
2381
+ * Find a clickable element by providing human readable text:
2382
+ *
2383
+ * ```js
2384
+ * this.helpers['Playwright']._locateClickable('Next page').then // ...
2385
+ * ```
2386
+ */
2387
+ _locateClickable(): void;
2388
+ /**
2389
+ * Find field elements by providing human readable text:
2390
+ *
2391
+ * ```js
2392
+ * this.helpers['Playwright']._locateFields('Your email').then // ...
2393
+ * ```
2394
+ */
2395
+ _locateFields(): void;
2396
+ /**
2397
+ * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
2398
+ *
2399
+ * ```js
2400
+ * I.switchToNextTab();
2401
+ * I.switchToNextTab(2);
2402
+ * ```
2403
+ *
2404
+ * @param {number} [num=1]
2405
+ */
2406
+ switchToNextTab(num?: number): void;
2407
+ /**
2408
+ * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
2409
+ *
2410
+ * ```js
2411
+ * I.switchToPreviousTab();
2412
+ * I.switchToPreviousTab(2);
2413
+ * ```
2414
+ * @param {number} [num=1]
2415
+ */
2416
+ switchToPreviousTab(num?: number): void;
2417
+ /**
2418
+ * Close current tab and switches to previous.
2419
+ *
2420
+ * ```js
2421
+ * I.closeCurrentTab();
2422
+ * ```
2423
+ */
2424
+ closeCurrentTab(): void;
2425
+ /**
2426
+ * Close all tabs except for the current one.
2427
+ *
2428
+ * ```js
2429
+ * I.closeOtherTabs();
2430
+ * ```
2431
+ */
2432
+ closeOtherTabs(): void;
2433
+ /**
2434
+ * Open new tab and switch to it
2435
+ *
2436
+ * ```js
2437
+ * I.openNewTab();
2438
+ * ```
2439
+ *
2440
+ * You can pass in [page options](https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#browsernewpageoptions) to emulate device on this page
2441
+ *
2442
+ * ```js
2443
+ * // enable mobile
2444
+ * I.openNewTab({ isMobile: true });
2445
+ * ```
2446
+ */
2447
+ openNewTab(): void;
2448
+ /**
2449
+ * Grab number of open tabs.
2450
+ *
2451
+ * ```js
2452
+ * let tabs = await I.grabNumberOfOpenTabs();
2453
+ * ```
2454
+ *
2455
+ * @returns {Promise<number>} number of open tabs
2456
+ */
2457
+ grabNumberOfOpenTabs(): Promise<number>;
2458
+ /**
2459
+ * Checks that a given Element is visible
2460
+ * Element is located by CSS or XPath.
2461
+ *
2462
+ * ```js
2463
+ * I.seeElement('#modal');
2464
+ * ```
2465
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2466
+ *
2467
+ */
2468
+ seeElement(locator: CodeceptJS.LocatorOrString): void;
2469
+ /**
2470
+ * Opposite to `seeElement`. Checks that element is not visible (or in DOM)
2471
+ *
2472
+ * ```js
2473
+ * I.dontSeeElement('.modal'); // modal is not shown
2474
+ * ```
2475
+ *
2476
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
2477
+ *
2478
+ */
2479
+ dontSeeElement(locator: CodeceptJS.LocatorOrString): void;
2480
+ /**
2481
+ * Checks that a given Element is present in the DOM
2482
+ * Element is located by CSS or XPath.
2483
+ *
2484
+ * ```js
2485
+ * I.seeElementInDOM('#modal');
2486
+ * ```
2487
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2488
+ *
2489
+ */
2490
+ seeElementInDOM(locator: CodeceptJS.LocatorOrString): void;
2491
+ /**
2492
+ * Opposite to `seeElementInDOM`. Checks that element is not on page.
2493
+ *
2494
+ * ```js
2495
+ * I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
2496
+ * ```
2497
+ *
2498
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
2499
+ */
2500
+ dontSeeElementInDOM(locator: CodeceptJS.LocatorOrString): void;
2501
+ /**
2502
+ * Handles a file download.Aa file name is required to save the file on disk.
2503
+ * Files are saved to "output" directory.
2504
+ *
2505
+ * Should be used with [FileSystem helper](https://codecept.io/helpers/FileSystem) to check that file were downloaded correctly.
2506
+ *
2507
+ * ```js
2508
+ * I.handleDownloads('downloads/avatar.jpg');
2509
+ * I.click('Download Avatar');
2510
+ * I.amInPath('output/downloads');
2511
+ * I.waitForFile('downloads/avatar.jpg', 5);
2512
+ *
2513
+ * ```
2514
+ *
2515
+ * @param {string} [fileName] set filename for downloaded file
2516
+ */
2517
+ handleDownloads(fileName?: string): void;
2518
+ /**
2519
+ * Perform a click on a link or a button, given by a locator.
2520
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
2521
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
2522
+ * For images, the "alt" attribute and inner text of any parent links are searched.
2523
+ *
2524
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
2525
+ *
2526
+ * ```js
2527
+ * // simple link
2528
+ * I.click('Logout');
2529
+ * // button of form
2530
+ * I.click('Submit');
2531
+ * // CSS button
2532
+ * I.click('#form input[type=submit]');
2533
+ * // XPath
2534
+ * I.click('//form/*[@type=submit]');
2535
+ * // link in context
2536
+ * I.click('Logout', '#nav');
2537
+ * // using strict locator
2538
+ * I.click({css: 'nav a.login'});
2539
+ * ```
2540
+ *
2541
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
2542
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
2543
+ *
2544
+ *
2545
+ *
2546
+ */
2547
+ click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
2548
+ /**
2549
+ * Clicks link and waits for navigation (deprecated)
2550
+ */
2551
+ clickLink(): void;
2552
+ /**
2553
+ *
2554
+ * Force clicks an element without waiting for it to become visible and not animating.
2555
+ *
2556
+ * ```js
2557
+ * I.forceClick('#hiddenButton');
2558
+ * I.forceClick('Click me', '#hidden');
2559
+ * ```
2560
+ *
2561
+ */
2562
+ forceClick(): void;
2563
+ /**
2564
+ * Performs a double-click on an element matched by link|button|label|CSS or XPath.
2565
+ * Context can be specified as second parameter to narrow search.
2566
+ *
2567
+ * ```js
2568
+ * I.doubleClick('Edit');
2569
+ * I.doubleClick('Edit', '.actions');
2570
+ * I.doubleClick({css: 'button.accept'});
2571
+ * I.doubleClick('.btn.edit');
2572
+ * ```
2573
+ *
2574
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
2575
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
2576
+ *
2577
+ *
2578
+ *
2579
+ */
2580
+ doubleClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
2581
+ /**
2582
+ * Performs right click on a clickable element matched by semantic locator, CSS or XPath.
2583
+ *
2584
+ * ```js
2585
+ * // right click element with id el
2586
+ * I.rightClick('#el');
2587
+ * // right click link or button with text "Click me"
2588
+ * I.rightClick('Click me');
2589
+ * // right click button with text "Click me" inside .context
2590
+ * I.rightClick('Click me', '.context');
2591
+ * ```
2592
+ *
2593
+ * @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
2594
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
2595
+ *
2596
+ *
2597
+ *
2598
+ */
2599
+ rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
2600
+ /**
2601
+ * Selects a checkbox or radio button.
2602
+ * Element is located by label or name or CSS or XPath.
2603
+ *
2604
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
2605
+ *
2606
+ * ```js
2607
+ * I.checkOption('#agree');
2608
+ * I.checkOption('I Agree to Terms and Conditions');
2609
+ * I.checkOption('agree', '//form');
2610
+ * ```
2611
+ * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
2612
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
2613
+ */
2614
+ checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
2615
+ /**
2616
+ * Unselects a checkbox or radio button.
2617
+ * Element is located by label or name or CSS or XPath.
2618
+ *
2619
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
2620
+ *
2621
+ * ```js
2622
+ * I.uncheckOption('#agree');
2623
+ * I.uncheckOption('I Agree to Terms and Conditions');
2624
+ * I.uncheckOption('agree', '//form');
2625
+ * ```
2626
+ * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
2627
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
2628
+ */
2629
+ uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
2630
+ /**
2631
+ * Verifies that the specified checkbox is checked.
2632
+ *
2633
+ * ```js
2634
+ * I.seeCheckboxIsChecked('Agree');
2635
+ * I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
2636
+ * I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
2637
+ * ```
2638
+ *
2639
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2640
+ *
2641
+ */
2642
+ seeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): void;
2643
+ /**
2644
+ * Verifies that the specified checkbox is not checked.
2645
+ *
2646
+ * ```js
2647
+ * I.dontSeeCheckboxIsChecked('#agree'); // located by ID
2648
+ * I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
2649
+ * I.dontSeeCheckboxIsChecked('agree'); // located by name
2650
+ * ```
2651
+ *
2652
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2653
+ *
2654
+ */
2655
+ dontSeeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): void;
2656
+ /**
2657
+ * Presses a key in the browser and leaves it in a down state.
2658
+ *
2659
+ * To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`](#click)).
2660
+ *
2661
+ * ```js
2662
+ * I.pressKeyDown('Control');
2663
+ * I.click('#element');
2664
+ * I.pressKeyUp('Control');
2665
+ * ```
2666
+ *
2667
+ * @param {string} key name of key to press down.
2668
+ *
2669
+ */
2670
+ pressKeyDown(key: string): void;
2671
+ /**
2672
+ * Releases a key in the browser which was previously set to a down state.
2673
+ *
2674
+ * To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`](#click)).
2675
+ *
2676
+ * ```js
2677
+ * I.pressKeyDown('Control');
2678
+ * I.click('#element');
2679
+ * I.pressKeyUp('Control');
2680
+ * ```
2681
+ *
2682
+ * @param {string} key name of key to release.
2683
+ *
2684
+ */
2685
+ pressKeyUp(key: string): void;
2686
+ /**
2687
+ * Presses a key in the browser (on a focused element).
2688
+ *
2689
+ * _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
2690
+ *
2691
+ * ```js
2692
+ * I.pressKey('Backspace');
2693
+ * ```
2694
+ *
2695
+ * To press a key in combination with modifier keys, pass the sequence as an array. All modifier keys (`'Alt'`, `'Control'`, `'Meta'`, `'Shift'`) will be released afterwards.
2696
+ *
2697
+ * ```js
2698
+ * I.pressKey(['Control', 'Z']);
2699
+ * ```
2700
+ *
2701
+ * For specifying operation modifier key based on operating system it is suggested to use `'CommandOrControl'`.
2702
+ * This will press `'Command'` (also known as `'Meta'`) on macOS machines and `'Control'` on non-macOS machines.
2703
+ *
2704
+ * ```js
2705
+ * I.pressKey(['CommandOrControl', 'Z']);
2706
+ * ```
2707
+ *
2708
+ * Some of the supported key names are:
2709
+ * - `'AltLeft'` or `'Alt'`
2710
+ * - `'AltRight'`
2711
+ * - `'ArrowDown'`
2712
+ * - `'ArrowLeft'`
2713
+ * - `'ArrowRight'`
2714
+ * - `'ArrowUp'`
2715
+ * - `'Backspace'`
2716
+ * - `'Clear'`
2717
+ * - `'ControlLeft'` or `'Control'`
2718
+ * - `'ControlRight'`
2719
+ * - `'Command'`
2720
+ * - `'CommandOrControl'`
2721
+ * - `'Delete'`
2722
+ * - `'End'`
2723
+ * - `'Enter'`
2724
+ * - `'Escape'`
2725
+ * - `'F1'` to `'F12'`
2726
+ * - `'Home'`
2727
+ * - `'Insert'`
2728
+ * - `'MetaLeft'` or `'Meta'`
2729
+ * - `'MetaRight'`
2730
+ * - `'Numpad0'` to `'Numpad9'`
2731
+ * - `'NumpadAdd'`
2732
+ * - `'NumpadDecimal'`
2733
+ * - `'NumpadDivide'`
2734
+ * - `'NumpadMultiply'`
2735
+ * - `'NumpadSubtract'`
2736
+ * - `'PageDown'`
2737
+ * - `'PageUp'`
2738
+ * - `'Pause'`
2739
+ * - `'Return'`
2740
+ * - `'ShiftLeft'` or `'Shift'`
2741
+ * - `'ShiftRight'`
2742
+ * - `'Space'`
2743
+ * - `'Tab'`
2744
+ *
2745
+ * @param {string|string[]} key key or array of keys to press.
2746
+ *
2747
+ *
2748
+ * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313](https://github.com/GoogleChrome/Playwright/issues/1313)).
2749
+ */
2750
+ pressKey(key: string | string[]): void;
2751
+ /**
2752
+ * Fills a text field or textarea, after clearing its value, with the given string.
2753
+ * Field is located by name, label, CSS, or XPath.
2754
+ *
2755
+ * ```js
2756
+ * // by label
2757
+ * I.fillField('Email', 'hello@world.com');
2758
+ * // by name
2759
+ * I.fillField('password', secret('123456'));
2760
+ * // by CSS
2761
+ * I.fillField('form#login input[name=username]', 'John');
2762
+ * // or by strict locator
2763
+ * I.fillField({css: 'form#login input[name=username]'}, 'John');
2764
+ * ```
2765
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2766
+ * @param {string} value text value to fill.
2767
+ *
2768
+ *
2769
+ */
2770
+ fillField(field: CodeceptJS.LocatorOrString, value: string): void;
2771
+ /**
2772
+ * Clears a `<textarea>` or text `<input>` element's value.
2773
+ *
2774
+ * ```js
2775
+ * I.clearField('Email');
2776
+ * I.clearField('user[email]');
2777
+ * I.clearField('#email');
2778
+ * ```
2779
+ * @param {string|object} editable field located by label|name|CSS|XPath|strict locator.
2780
+ */
2781
+ clearField(editable: string | any): void;
2782
+ /**
2783
+ * Appends text to a input field or textarea.
2784
+ * Field is located by name, label, CSS or XPath
2785
+ *
2786
+ * ```js
2787
+ * I.appendField('#myTextField', 'appended');
2788
+ * ```
2789
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
2790
+ * @param {string} value text value to append.
2791
+ *
2792
+ *
2793
+ */
2794
+ appendField(field: CodeceptJS.LocatorOrString, value: string): void;
2795
+ /**
2796
+ * Checks that the given input field or textarea equals to given value.
2797
+ * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
2798
+ *
2799
+ * ```js
2800
+ * I.seeInField('Username', 'davert');
2801
+ * I.seeInField({css: 'form textarea'},'Type your comment here');
2802
+ * I.seeInField('form input[type=hidden]','hidden_value');
2803
+ * I.seeInField('#searchform input','Search');
2804
+ * ```
2805
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2806
+ * @param {string} value value to check.
2807
+ *
2808
+ */
2809
+ seeInField(field: CodeceptJS.LocatorOrString, value: string): void;
2810
+ /**
2811
+ * Checks that value of input field or textarea doesn't equal to given value
2812
+ * Opposite to `seeInField`.
2813
+ *
2814
+ * ```js
2815
+ * I.dontSeeInField('email', 'user@user.com'); // field by name
2816
+ * I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
2817
+ * ```
2818
+ *
2819
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2820
+ * @param {string} value value to check.
2821
+ */
2822
+ dontSeeInField(field: CodeceptJS.LocatorOrString, value: string): void;
2823
+ /**
2824
+ * Attaches a file to element located by label, name, CSS or XPath
2825
+ * Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
2826
+ * File will be uploaded to remote system (if tests are running remotely).
2827
+ *
2828
+ * ```js
2829
+ * I.attachFile('Avatar', 'data/avatar.jpg');
2830
+ * I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
2831
+ * ```
2832
+ *
2833
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2834
+ * @param {string} pathToFile local file path relative to codecept.json config file.
2835
+ *
2836
+ */
2837
+ attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string): void;
2838
+ /**
2839
+ * Selects an option in a drop-down select.
2840
+ * Field is searched by label | name | CSS | XPath.
2841
+ * Option is selected by visible text or by value.
2842
+ *
2843
+ * ```js
2844
+ * I.selectOption('Choose Plan', 'Monthly'); // select by label
2845
+ * I.selectOption('subscription', 'Monthly'); // match option by text
2846
+ * I.selectOption('subscription', '0'); // or by value
2847
+ * I.selectOption('//form/select[@name=account]','Premium');
2848
+ * I.selectOption('form select[name=account]', 'Premium');
2849
+ * I.selectOption({css: 'form select[name=account]'}, 'Premium');
2850
+ * ```
2851
+ *
2852
+ * Provide an array for the second argument to select multiple options.
2853
+ *
2854
+ * ```js
2855
+ * I.selectOption('Which OS do you use?', ['Android', 'iOS']);
2856
+ * ```
2857
+ * @param {CodeceptJS.LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
2858
+ * @param {string|Array<*>} option visible text or value of option.
2859
+ */
2860
+ selectOption(select: CodeceptJS.LocatorOrString, option: string | any[]): void;
2861
+ /**
2862
+ * Grab number of visible elements by locator.
2863
+ *
2864
+ * ```js
2865
+ * let numOfElements = await I.grabNumberOfVisibleElements('p');
2866
+ * ```
2867
+ *
2868
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2869
+ * @returns {Promise<number>} number of visible elements
2870
+ *
2871
+ */
2872
+ grabNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString): Promise<number>;
2873
+ /**
2874
+ * Checks that current url contains a provided fragment.
2875
+ *
2876
+ * ```js
2877
+ * I.seeInCurrentUrl('/register'); // we are on registration page
2878
+ * ```
2879
+ *
2880
+ * @param {string} url a fragment to check
2881
+ */
2882
+ seeInCurrentUrl(url: string): void;
2883
+ /**
2884
+ * Checks that current url does not contain a provided fragment.
2885
+ *
2886
+ * @param {string} url value to check.
2887
+ */
2888
+ dontSeeInCurrentUrl(url: string): void;
2889
+ /**
2890
+ * Checks that current url is equal to provided one.
2891
+ * If a relative url provided, a configured url will be prepended to it.
2892
+ * So both examples will work:
2893
+ *
2894
+ * ```js
2895
+ * I.seeCurrentUrlEquals('/register');
2896
+ * I.seeCurrentUrlEquals('http://my.site.com/register');
2897
+ * ```
2898
+ *
2899
+ * @param {string} url value to check.
2900
+ */
2901
+ seeCurrentUrlEquals(url: string): void;
2902
+ /**
2903
+ * Checks that current url is not equal to provided one.
2904
+ * If a relative url provided, a configured url will be prepended to it.
2905
+ *
2906
+ * ```js
2907
+ * I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
2908
+ * I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
2909
+ * ```
2910
+ *
2911
+ * @param {string} url value to check.
2912
+ */
2913
+ dontSeeCurrentUrlEquals(url: string): void;
2914
+ /**
2915
+ * Checks that a page contains a visible text.
2916
+ * Use context parameter to narrow down the search.
2917
+ *
2918
+ * ```js
2919
+ * I.see('Welcome'); // text welcome on a page
2920
+ * I.see('Welcome', '.content'); // text inside .content div
2921
+ * I.see('Register', {css: 'form.register'}); // use strict locator
2922
+ * ```
2923
+ * @param {string} text expected on page.
2924
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
2925
+ *
2926
+ *
2927
+ */
2928
+ see(text: string, context?: CodeceptJS.LocatorOrString): void;
2929
+ /**
2930
+ * Checks that text is equal to provided one.
2931
+ *
2932
+ * ```js
2933
+ * I.seeTextEquals('text', 'h1');
2934
+ * ```
2935
+ *
2936
+ * @param {string} text element value to check.
2937
+ * @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
2938
+ */
2939
+ seeTextEquals(text: string, context?: CodeceptJS.LocatorOrString): void;
2940
+ /**
2941
+ * Opposite to `see`. Checks that a text is not present on a page.
2942
+ * Use context parameter to narrow down the search.
2943
+ *
2944
+ * ```js
2945
+ * I.dontSee('Login'); // assume we are already logged in.
2946
+ * I.dontSee('Login', '.nav'); // no login inside .nav element
2947
+ * ```
2948
+ *
2949
+ * @param {string} text which is not present.
2950
+ * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
2951
+ *
2952
+ *
2953
+ *
2954
+ */
2955
+ dontSee(text: string, context?: CodeceptJS.LocatorOrString): void;
2956
+ /**
2957
+ * Retrieves page source and returns it to test.
2958
+ * Resumes test execution, so should be used inside an async function.
2959
+ *
2960
+ * ```js
2961
+ * let pageSource = await I.grabSource();
2962
+ * ```
2963
+ *
2964
+ * @returns {Promise<string>} source code
2965
+ */
2966
+ grabSource(): Promise<string>;
2967
+ /**
2968
+ * Get JS log from browser.
2969
+ *
2970
+ * ```js
2971
+ * let logs = await I.grabBrowserLogs();
2972
+ * console.log(JSON.stringify(logs))
2973
+ * ```
2974
+ * @return {Promise<any[]>}
2975
+ */
2976
+ grabBrowserLogs(): Promise<any[]>;
2977
+ /**
2978
+ * Get current URL from browser.
2979
+ * Resumes test execution, so should be used inside an async function.
2980
+ *
2981
+ * ```js
2982
+ * let url = await I.grabCurrentUrl();
2983
+ * console.log(`Current URL is [${url}]`);
2984
+ * ```
2985
+ *
2986
+ * @returns {Promise<string>} current URL
2987
+ */
2988
+ grabCurrentUrl(): Promise<string>;
2989
+ /**
2990
+ * Checks that the current page contains the given string in its raw source code.
2991
+ *
2992
+ * ```js
2993
+ * I.seeInSource('<h1>Green eggs &amp; ham</h1>');
2994
+ * ```
2995
+ * @param {string} text value to check.
2996
+ */
2997
+ seeInSource(text: string): void;
2998
+ /**
2999
+ * Checks that the current page does not contains the given string in its raw source code.
3000
+ *
3001
+ * ```js
3002
+ * I.dontSeeInSource('<!--'); // no comments in source
3003
+ * ```
3004
+ *
3005
+ * @param {string} value to check.
3006
+ *
3007
+ */
3008
+ dontSeeInSource(value: string): void;
3009
+ /**
3010
+ * Asserts that an element appears a given number of times in the DOM.
3011
+ * Element is located by label or name or CSS or XPath.
3012
+ *
3013
+ *
3014
+ * ```js
3015
+ * I.seeNumberOfElements('#submitBtn', 1);
3016
+ * ```
3017
+ *
3018
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3019
+ * @param {number} num number of elements.
3020
+ *
3021
+ *
3022
+ *
3023
+ */
3024
+ seeNumberOfElements(locator: CodeceptJS.LocatorOrString, num: number): void;
3025
+ /**
3026
+ * Asserts that an element is visible a given number of times.
3027
+ * Element is located by CSS or XPath.
3028
+ *
3029
+ * ```js
3030
+ * I.seeNumberOfVisibleElements('.buttons', 3);
3031
+ * ```
3032
+ *
3033
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3034
+ * @param {number} num number of elements.
3035
+ *
3036
+ *
3037
+ *
3038
+ */
3039
+ seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): void;
3040
+ /**
3041
+ * Sets cookie(s).
3042
+ *
3043
+ * Can be a single cookie object or an array of cookies:
3044
+ *
3045
+ * ```js
3046
+ * I.setCookie({name: 'auth', value: true});
3047
+ *
3048
+ * // as array
3049
+ * I.setCookie([
3050
+ * {name: 'auth', value: true},
3051
+ * {name: 'agree', value: true}
3052
+ * ]);
3053
+ * ```
3054
+ *
3055
+ * @param {object|array} cookie a cookie object or array of cookie objects.
3056
+ */
3057
+ setCookie(cookie: any | any[]): void;
3058
+ /**
3059
+ * Checks that cookie with given name exists.
3060
+ *
3061
+ * ```js
3062
+ * I.seeCookie('Auth');
3063
+ * ```
3064
+ *
3065
+ * @param {string} name cookie name.
3066
+ *
3067
+ *
3068
+ */
3069
+ seeCookie(name: string): void;
3070
+ /**
3071
+ * Checks that cookie with given name does not exist.
3072
+ *
3073
+ * ```js
3074
+ * I.dontSeeCookie('auth'); // no auth cookie
3075
+ * ```
3076
+ *
3077
+ * @param {string} name cookie name.
3078
+ */
3079
+ dontSeeCookie(name: string): void;
3080
+ /**
3081
+ * Gets a cookie object by name.
3082
+ * If none provided gets all cookies.
3083
+ * Resumes test execution, so **should be used inside async with `await`** operator.
3084
+ *
3085
+ * ```js
3086
+ * let cookie = await I.grabCookie('auth');
3087
+ * assert(cookie.value, '123456');
3088
+ * ```
3089
+ *
3090
+ * @param {?string} [name=null] cookie name.
3091
+ * @returns {Promise<string>} attribute value
3092
+ *
3093
+ * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
3094
+ */
3095
+ grabCookie(name?: string): Promise<string>;
3096
+ /**
3097
+ * Clears a cookie by name,
3098
+ * if none provided clears all cookies.
3099
+ *
3100
+ * ```js
3101
+ * I.clearCookie();
3102
+ * I.clearCookie('test');
3103
+ * ```
3104
+ *
3105
+ * @param {?string} [cookie=null] (optional, `null` by default) cookie name
3106
+ */
3107
+ clearCookie(cookie?: string): void;
3108
+ /**
3109
+ * Executes a script on the page:
3110
+ *
3111
+ * ```js
3112
+ * I.executeScript(() => window.alert('Hello world'));
3113
+ * ```
3114
+ *
3115
+ * Additional parameters of the function can be passed as an object argument:
3116
+ *
3117
+ * ```js
3118
+ * I.executeScript(({x, y}) => x + y, {x, y});
3119
+ * ```
3120
+ * You can pass only one parameter into a function
3121
+ * but you can pass in array or object.
3122
+ *
3123
+ * ```js
3124
+ * I.executeScript(([x, y]) => x + y, [x, y]);
3125
+ * ```
3126
+ * If a function returns a Promise it will wait for its resolution.
3127
+ */
3128
+ executeScript(): void;
3129
+ /**
3130
+ * Retrieves a text from an element located by CSS or XPath and returns it to test.
3131
+ * Resumes test execution, so **should be used inside async with `await`** operator.
3132
+ *
3133
+ * ```js
3134
+ * let pin = await I.grabTextFrom('#pin');
3135
+ * ```
3136
+ * If multiple elements found returns an array of texts.
3137
+ *
3138
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3139
+ * @returns {Promise<string|string[]>} attribute value
3140
+ *
3141
+ */
3142
+ grabTextFrom(locator: CodeceptJS.LocatorOrString): Promise<string | string[]>;
3143
+ /**
3144
+ * Retrieves a value from a form element located by CSS or XPath and returns it to test.
3145
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
3146
+ *
3147
+ * ```js
3148
+ * let email = await I.grabValueFrom('input[name=email]');
3149
+ * ```
3150
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
3151
+ * @returns {Promise<string>} attribute value
3152
+ */
3153
+ grabValueFrom(locator: CodeceptJS.LocatorOrString): Promise<string>;
3154
+ /**
3155
+ * Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
3156
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
3157
+ * If more than one element is found - an array of HTMLs returned.
3158
+ *
3159
+ * ```js
3160
+ * let postHTML = await I.grabHTMLFrom('#post');
3161
+ * ```
3162
+ *
3163
+ * @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
3164
+ * @returns {Promise<string>} HTML code for an element
3165
+ */
3166
+ grabHTMLFrom(element: CodeceptJS.LocatorOrString): Promise<string>;
3167
+ /**
3168
+ * Grab CSS property for given locator
3169
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
3170
+ *
3171
+ * ```js
3172
+ * const value = await I.grabCssPropertyFrom('h3', 'font-weight');
3173
+ * ```
3174
+ *
3175
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3176
+ * @param {string} cssProperty CSS property name.
3177
+ * @returns {Promise<string>} CSS value
3178
+ *
3179
+ */
3180
+ grabCssPropertyFrom(locator: CodeceptJS.LocatorOrString, cssProperty: string): Promise<string>;
3181
+ /**
3182
+ * Checks that all elements with given locator have given CSS properties.
3183
+ *
3184
+ * ```js
3185
+ * I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
3186
+ * ```
3187
+ *
3188
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
3189
+ * @param {object} cssProperties object with CSS properties and their values to check.
3190
+ *
3191
+ */
3192
+ seeCssPropertiesOnElements(locator: CodeceptJS.LocatorOrString, cssProperties: any): void;
3193
+ /**
3194
+ * Checks that all elements with given locator have given attributes.
3195
+ *
3196
+ * ```js
3197
+ * I.seeAttributesOnElements('//form', { method: "post"});
3198
+ * ```
3199
+ *
3200
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
3201
+ * @param {object} attributes attributes and their values to check.
3202
+ *
3203
+ */
3204
+ seeAttributesOnElements(locator: CodeceptJS.LocatorOrString, attributes: any): void;
3205
+ /**
3206
+ * Drag the scrubber of a slider to a given position
3207
+ * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
3208
+ *
3209
+ * ```js
3210
+ * I.dragSlider('#slider', 30);
3211
+ * I.dragSlider('#slider', -70);
3212
+ * ```
3213
+ *
3214
+ * @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
3215
+ * @param {number} offsetX position to drag.
3216
+ *
3217
+ */
3218
+ dragSlider(locator: CodeceptJS.LocatorOrString, offsetX: number): void;
3219
+ /**
3220
+ * Retrieves an attribute from an element located by CSS or XPath and returns it to test.
3221
+ * An array as a result will be returned if there are more than one matched element.
3222
+ * Resumes test execution, so **should be used inside async with `await`** operator.
3223
+ *
3224
+ * ```js
3225
+ * let hint = await I.grabAttributeFrom('#tooltip', 'title');
3226
+ * ```
3227
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3228
+ * @param {string} attr attribute name.
3229
+ * @returns {Promise<string>} attribute value
3230
+ *
3231
+ */
3232
+ grabAttributeFrom(locator: CodeceptJS.LocatorOrString, attr: string): Promise<string>;
3233
+ /**
3234
+ * Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
3235
+ * Filename is relative to output folder.
3236
+ * Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
3237
+ *
3238
+ * ```js
3239
+ * I.saveScreenshot('debug.png');
3240
+ * I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
3241
+ * ```
3242
+ *
3243
+ * @param {string} fileName file name to save.
3244
+ * @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
3245
+ */
3246
+ saveScreenshot(fileName: string, fullPage?: boolean): void;
3247
+ /**
3248
+ * Pauses execution for a number of seconds.
3249
+ *
3250
+ * ```js
3251
+ * I.wait(2); // wait 2 secs
3252
+ * ```
3253
+ *
3254
+ * @param {number} sec number of second to wait.
3255
+ */
3256
+ wait(sec: number): void;
3257
+ /**
3258
+ * Waits for element to become enabled (by default waits for 1sec).
3259
+ * Element can be located by CSS or XPath.
3260
+ *
3261
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3262
+ * @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
3263
+ */
3264
+ waitForEnabled(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3265
+ /**
3266
+ * Waits for the specified value to be in value attribute.
3267
+ *
3268
+ * ```js
3269
+ * I.waitForValue('//input', "GoodValue");
3270
+ * ```
3271
+ *
3272
+ * @param {string|object} field input field.
3273
+ * @param {string }value expected value.
3274
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3275
+ */
3276
+ waitForValue(field: string | any, value: string, sec?: number): void;
3277
+ /**
3278
+ * Waits for a specified number of elements on the page.
3279
+ *
3280
+ * ```js
3281
+ * I.waitNumberOfVisibleElements('a', 3);
3282
+ * ```
3283
+ *
3284
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3285
+ * @param {number} num number of elements.
3286
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3287
+ *
3288
+ */
3289
+ waitNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number, sec?: number): void;
3290
+ /**
3291
+ * Waits for element to be clickable (by default waits for 1sec).
3292
+ * Element can be located by CSS or XPath.
3293
+ *
3294
+ * ```js
3295
+ * I.waitForClickable('.btn.continue');
3296
+ * I.waitForClickable('.btn.continue', 5); // wait for 5 secs
3297
+ * ```
3298
+ *
3299
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3300
+ * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3301
+ */
3302
+ waitForClickable(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3303
+ /**
3304
+ * Waits for element to be present on page (by default waits for 1sec).
3305
+ * Element can be located by CSS or XPath.
3306
+ *
3307
+ * ```js
3308
+ * I.waitForElement('.btn.continue');
3309
+ * I.waitForElement('.btn.continue', 5); // wait for 5 secs
3310
+ * ```
3311
+ *
3312
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3313
+ * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3314
+ *
3315
+ */
3316
+ waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3317
+ /**
3318
+ * Waits for an element to become visible on a page (by default waits for 1sec).
3319
+ * Element can be located by CSS or XPath.
3320
+ *
3321
+ * ```js
3322
+ * I.waitForVisible('#popup');
3323
+ * ```
3324
+ *
3325
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3326
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3327
+ *
3328
+ * This method accepts [React selectors](https://codecept.io/react).
1981
3329
  */
1982
- waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): void;
3330
+ waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
1983
3331
  /**
1984
- * Waits for an element to become visible on a page (by default waits for 1sec).
3332
+ * Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1985
3333
  * Element can be located by CSS or XPath.
1986
3334
  *
1987
3335
  * ```js
1988
- * I.waitForVisible('#popup');
3336
+ * I.waitForInvisible('#popup');
1989
3337
  * ```
1990
3338
  *
1991
3339
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1992
3340
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
1993
3341
  */
1994
- waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3342
+ waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
1995
3343
  /**
1996
3344
  * Waits for an element to hide (by default waits for 1sec).
1997
3345
  * Element can be located by CSS or XPath.
@@ -2005,114 +3353,177 @@ declare namespace CodeceptJS {
2005
3353
  */
2006
3354
  waitToHide(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2007
3355
  /**
2008
- * Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
2009
- * Element can be located by CSS or XPath.
3356
+ * Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
2010
3357
  *
2011
3358
  * ```js
2012
- * I.waitForInvisible('#popup');
3359
+ * I.waitInUrl('/info', 2);
2013
3360
  * ```
2014
3361
  *
2015
- * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3362
+ * @param {string} urlPart value to check.
2016
3363
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2017
3364
  */
2018
- waitForInvisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3365
+ waitInUrl(urlPart: string, sec?: number): void;
2019
3366
  /**
2020
- * Waits for element to be present on page (by default waits for 1sec).
2021
- * Element can be located by CSS or XPath.
3367
+ * Waits for the entire URL to match the expected
2022
3368
  *
2023
3369
  * ```js
2024
- * I.waitForElement('.btn.continue');
2025
- * I.waitForElement('.btn.continue', 5); // wait for 5 secs
3370
+ * I.waitUrlEquals('/info', 2);
3371
+ * I.waitUrlEquals('http://127.0.0.1:8000/info');
2026
3372
  * ```
2027
3373
  *
2028
- * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2029
- * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3374
+ * @param {string} urlPart value to check.
3375
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2030
3376
  */
2031
- waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3377
+ waitUrlEquals(urlPart: string, sec?: number): void;
2032
3378
  /**
2033
- * Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
3379
+ * Waits for a text to appear (by default waits for 1sec).
2034
3380
  * Element can be located by CSS or XPath.
3381
+ * Narrow down search results by providing context.
2035
3382
  *
2036
3383
  * ```js
2037
- * I.waitForDetached('#popup');
3384
+ * I.waitForText('Thank you, form has been submitted');
3385
+ * I.waitForText('Thank you, form has been submitted', 5, '#modal');
2038
3386
  * ```
2039
3387
  *
2040
- * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3388
+ * @param {string }text to wait for.
2041
3389
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3390
+ * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
2042
3391
  */
2043
- waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): void;
3392
+ waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): void;
2044
3393
  /**
2045
- * Reload the current page.
3394
+ * Waits for a network request.
2046
3395
  *
2047
3396
  * ```js
2048
- * I.refreshPage();
3397
+ * I.waitForRequest('http://example.com/resource');
3398
+ * I.waitForRequest(request => request.url() === 'http://example.com' && request.method() === 'GET');
2049
3399
  * ```
2050
3400
  *
3401
+ * @param {string|function} urlOrPredicate
3402
+ * @param {?number} [sec=null] seconds to wait
2051
3403
  */
2052
- refreshPage(): void;
3404
+ waitForRequest(urlOrPredicate: string | ((...params: any[]) => any), sec?: number): void;
2053
3405
  /**
2054
- * Reload the page
3406
+ * Waits for a network request.
3407
+ *
3408
+ * ```js
3409
+ * I.waitForResponse('http://example.com/resource');
3410
+ * I.waitForResponse(request => request.url() === 'http://example.com' && request.method() === 'GET');
3411
+ * ```
3412
+ *
3413
+ * @param {string|function} urlOrPredicate
3414
+ * @param {?number} [sec=null] number of seconds to wait
2055
3415
  */
2056
- refresh(): void;
3416
+ waitForResponse(urlOrPredicate: string | ((...params: any[]) => any), sec?: number): void;
2057
3417
  /**
2058
- * Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
2059
- * Filename is relative to output folder.
2060
- * Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
3418
+ * Switches frame or in case of null locator reverts to parent.
2061
3419
  *
2062
3420
  * ```js
2063
- * I.saveScreenshot('debug.png');
2064
- * I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
3421
+ * I.switchTo('iframe'); // switch to first iframe
3422
+ * I.switchTo(); // switch back to main page
2065
3423
  * ```
2066
3424
  *
2067
- * @param {string} fileName file name to save.
2068
- * @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
3425
+ * @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
2069
3426
  */
2070
- saveScreenshot(fileName: string, fullPage?: boolean): void;
3427
+ switchTo(locator?: CodeceptJS.LocatorOrString): void;
2071
3428
  /**
2072
- * Scrolls to element matched by locator.
2073
- * Extra shift can be set with offsetX and offsetY options.
3429
+ * Waits for a function to return true (waits for 1 sec by default).
3430
+ * Running in browser context.
2074
3431
  *
2075
3432
  * ```js
2076
- * I.scrollTo('footer');
2077
- * I.scrollTo('#submit', 5, 5);
3433
+ * I.waitForFunction(fn[, [args[, timeout]])
2078
3434
  * ```
2079
3435
  *
2080
- * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2081
- * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
2082
- * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
3436
+ * ```js
3437
+ * I.waitForFunction(() => window.requests == 0);
3438
+ * I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
3439
+ * I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
3440
+ * ```
3441
+ *
3442
+ * @param {string|function} fn to be executed in browser context.
3443
+ * @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
3444
+ * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3445
+ *
2083
3446
  */
2084
- scrollTo(locator: CodeceptJS.LocatorOrString, offsetX?: number, offsetY?: number): void;
3447
+ waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): void;
2085
3448
  /**
2086
- * Scroll page to the top.
3449
+ * Waits for navigation to finish. By default takes configured `waitForNavigation` option.
3450
+ *
3451
+ * See [Pupeteer's reference](https://github.com/GoogleChrome/Playwright/blob/master/docs/api.md#pagewaitfornavigationoptions)
3452
+ *
3453
+ * @param {*} opts
3454
+ */
3455
+ waitForNavigation(opts: any): void;
3456
+ /**
3457
+ * Waits for a function to return true (waits for 1sec by default).
2087
3458
  *
2088
3459
  * ```js
2089
- * I.scrollPageToTop();
3460
+ * I.waitUntil(() => window.requests == 0);
3461
+ * I.waitUntil(() => window.requests == 0, 5);
2090
3462
  * ```
2091
3463
  *
3464
+ * @param {function|string} fn function which is executed in browser context.
3465
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3466
+ * @param {string} [timeoutMsg=''] message to show in case of timeout fail.
3467
+ * @param {?number} [interval=null]
2092
3468
  */
2093
- scrollPageToTop(): void;
3469
+ waitUntil(fn: ((...params: any[]) => any) | string, sec?: number, timeoutMsg?: string, interval?: number): void;
2094
3470
  /**
2095
- * Scroll page to the bottom.
3471
+ * Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
3472
+ * Element can be located by CSS or XPath.
2096
3473
  *
2097
3474
  * ```js
2098
- * I.scrollPageToBottom();
3475
+ * I.waitForDetached('#popup');
2099
3476
  * ```
2100
3477
  *
3478
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3479
+ * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
2101
3480
  */
2102
- scrollPageToBottom(): void;
3481
+ waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): void;
2103
3482
  /**
2104
- * Retrieves a page scroll position and returns it to test.
3483
+ * Grab the data from performance timing using Navigation Timing API.
3484
+ * The returned data will contain following things in ms:
3485
+ * - responseEnd,
3486
+ * - domInteractive,
3487
+ * - domContentLoadedEventEnd,
3488
+ * - loadEventEnd
2105
3489
  * Resumes test execution, so **should be used inside an async function with `await`** operator.
2106
3490
  *
2107
3491
  * ```js
2108
- * let { x, y } = await I.grabPageScrollPosition();
3492
+ * await I.amOnPage('https://example.com');
3493
+ * let data = await I.grabDataFromPerformanceTiming();
3494
+ * //Returned data
3495
+ * { // all results are in [ms]
3496
+ * responseEnd: 23,
3497
+ * domInteractive: 44,
3498
+ * domContentLoadedEventEnd: 196,
3499
+ * loadEventEnd: 241
3500
+ * }
2109
3501
  * ```
3502
+ */
3503
+ grabDataFromPerformanceTiming(): void;
3504
+ /**
3505
+ * Grab the width, height, location of given locator.
3506
+ * Provide `width` or `height`as second param to get your desired prop.
3507
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2110
3508
  *
2111
- * @returns {Promise<Object<string, *>>} scroll position
3509
+ * Returns an object with `x`, `y`, `width`, `height` keys.
3510
+ *
3511
+ * ```js
3512
+ * const value = await I.grabElementBoundingRect('h3');
3513
+ * // value is like { x: 226.5, y: 89, width: 527, height: 220 }
3514
+ * ```
3515
+ *
3516
+ * To get only one metric use second parameter:
3517
+ *
3518
+ * ```js
3519
+ * const width = await I.grabElementBoundingRect('h3', 'width');
3520
+ * // width == 527
3521
+ * ```
3522
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
3523
+ * @param {string} elementSize x, y, width or height of the given element.
3524
+ * @returns {object} Element bounding rectangle
2112
3525
  */
2113
- grabPageScrollPosition(): Promise<{
2114
- [key: string]: any;
2115
- }>;
3526
+ grabElementBoundingRect(locator: string | any, elementSize: string): any;
2116
3527
  }
2117
3528
  /**
2118
3529
  * This helper works the same as MockRequest helper. It has been included for backwards compatibility
@@ -2938,8 +4349,14 @@ declare namespace CodeceptJS {
2938
4349
  /**
2939
4350
  * Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
2940
4351
  * given string.
4352
+ *
4353
+ * ```js
4354
+ * I.seeInPopup('Popup text');
4355
+ * ```
4356
+ * @param {string} text value to check.
4357
+ *
2941
4358
  */
2942
- seeInPopup(): void;
4359
+ seeInPopup(text: string): void;
2943
4360
  /**
2944
4361
  * Grab the text within the popup. If no popup is visible then it will return null
2945
4362
  *
@@ -3300,15 +4717,23 @@ declare namespace CodeceptJS {
3300
4717
  */
3301
4718
  resetModule(): void;
3302
4719
  /**
3303
- * Sets a cookie.
4720
+ * Sets cookie(s).
4721
+ *
4722
+ * Can be a single cookie object or an array of cookies:
3304
4723
  *
3305
4724
  * ```js
3306
4725
  * I.setCookie({name: 'auth', value: true});
4726
+ *
4727
+ * // as array
4728
+ * I.setCookie([
4729
+ * {name: 'auth', value: true},
4730
+ * {name: 'agree', value: true}
4731
+ * ]);
3307
4732
  * ```
3308
4733
  *
3309
- * @param {object} cookie a cookie object.
4734
+ * @param {object|array} cookie a cookie object or array of cookie objects.
3310
4735
  */
3311
- setCookie(cookie: any): void;
4736
+ setCookie(cookie: any | any[]): void;
3312
4737
  }
3313
4738
  class Puppeteer {
3314
4739
  /**
@@ -3346,8 +4771,14 @@ declare namespace CodeceptJS {
3346
4771
  /**
3347
4772
  * Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
3348
4773
  * given string.
4774
+ *
4775
+ * ```js
4776
+ * I.seeInPopup('Popup text');
4777
+ * ```
4778
+ * @param {string} text value to check.
4779
+ *
3349
4780
  */
3350
- seeInPopup(): void;
4781
+ seeInPopup(text: string): void;
3351
4782
  /**
3352
4783
  * Set current page
3353
4784
  * @param {object} page page to set
@@ -3695,6 +5126,39 @@ declare namespace CodeceptJS {
3695
5126
  * {{ react }}
3696
5127
  */
3697
5128
  click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
5129
+ /**
5130
+ * Perform an emulated click on a link or a button, given by a locator.
5131
+ * Unlike normal click instead of sending native event, emulates a click with JavaScript.
5132
+ * This works on hidden, animated or inactive elements as well.
5133
+ *
5134
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
5135
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
5136
+ * For images, the "alt" attribute and inner text of any parent links are searched.
5137
+ *
5138
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
5139
+ *
5140
+ * ```js
5141
+ * // simple link
5142
+ * I.forceClick('Logout');
5143
+ * // button of form
5144
+ * I.forceClick('Submit');
5145
+ * // CSS button
5146
+ * I.forceClick('#form input[type=submit]');
5147
+ * // XPath
5148
+ * I.forceClick('//form/*[@type=submit]');
5149
+ * // link in context
5150
+ * I.forceClick('Logout', '#nav');
5151
+ * // using strict locator
5152
+ * I.forceClick({css: 'nav a.login'});
5153
+ * ```
5154
+ *
5155
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
5156
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
5157
+ *
5158
+ *
5159
+ * {{ react }}
5160
+ */
5161
+ forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
3698
5162
  /**
3699
5163
  * Performs a click on a link and waits for navigation before moving on.
3700
5164
  *
@@ -4003,6 +5467,8 @@ declare namespace CodeceptJS {
4003
5467
  *
4004
5468
  * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
4005
5469
  * @param {string} pathToFile local file path relative to codecept.json config file.
5470
+ *
5471
+ * > ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1](https://github.com/puppeteer/puppeteer/issues/5420), downgrade to 2.0.0 if you face it.
4006
5472
  */
4007
5473
  attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string): void;
4008
5474
  /**
@@ -4208,15 +5674,23 @@ declare namespace CodeceptJS {
4208
5674
  */
4209
5675
  seeNumberOfVisibleElements(locator: CodeceptJS.LocatorOrString, num: number): void;
4210
5676
  /**
4211
- * Sets a cookie.
5677
+ * Sets cookie(s).
5678
+ *
5679
+ * Can be a single cookie object or an array of cookies:
4212
5680
  *
4213
5681
  * ```js
4214
5682
  * I.setCookie({name: 'auth', value: true});
5683
+ *
5684
+ * // as array
5685
+ * I.setCookie([
5686
+ * {name: 'auth', value: true},
5687
+ * {name: 'agree', value: true}
5688
+ * ]);
4215
5689
  * ```
4216
5690
  *
4217
- * @param {object} cookie a cookie object.
5691
+ * @param {object|array} cookie a cookie object or array of cookie objects.
4218
5692
  */
4219
- setCookie(cookie: any): void;
5693
+ setCookie(cookie: any | any[]): void;
4220
5694
  /**
4221
5695
  * Checks that cookie with given name exists.
4222
5696
  *
@@ -5475,15 +6949,23 @@ declare namespace CodeceptJS {
5475
6949
  */
5476
6950
  switchTo(locator?: CodeceptJS.LocatorOrString): void;
5477
6951
  /**
5478
- * Sets a cookie.
6952
+ * Sets cookie(s).
6953
+ *
6954
+ * Can be a single cookie object or an array of cookies:
5479
6955
  *
5480
6956
  * ```js
5481
6957
  * I.setCookie({name: 'auth', value: true});
6958
+ *
6959
+ * // as array
6960
+ * I.setCookie([
6961
+ * {name: 'auth', value: true},
6962
+ * {name: 'agree', value: true}
6963
+ * ]);
5482
6964
  * ```
5483
6965
  *
5484
- * @param {object} cookie a cookie object.
6966
+ * @param {object|array} cookie a cookie object or array of cookie objects.
5485
6967
  */
5486
- setCookie(cookie: any): void;
6968
+ setCookie(cookie: any | any[]): void;
5487
6969
  /**
5488
6970
  * Checks that cookie with given name exists.
5489
6971
  *
@@ -5644,6 +7126,24 @@ declare namespace CodeceptJS {
5644
7126
  waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): void;
5645
7127
  }
5646
7128
  class WebDriver {
7129
+ /**
7130
+ * Check if locator is type of "Shadow"
7131
+ *
7132
+ * @param {object} locator
7133
+ */
7134
+ _isShadowLocator(locator: any): void;
7135
+ /**
7136
+ * Locate Element within the Shadow Dom
7137
+ *
7138
+ * @param {object} locator
7139
+ */
7140
+ _locateShadow(locator: any): void;
7141
+ /**
7142
+ * Smart Wait to locate an element
7143
+ *
7144
+ * @param {object} locator
7145
+ */
7146
+ _smartWait(locator: any): void;
5647
7147
  /**
5648
7148
  * Get elements by different locator types, including strict locator.
5649
7149
  * Should be used in custom helpers:
@@ -5670,7 +7170,8 @@ declare namespace CodeceptJS {
5670
7170
  * Find a clickable element by providing human readable text:
5671
7171
  *
5672
7172
  * ```js
5673
- * this.helpers['WebDriver']._locateClickable('Next page').then // ...
7173
+ * const els = await this.helpers.WebDriver._locateClickable('Next page');
7174
+ * const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
5674
7175
  * ```
5675
7176
  *
5676
7177
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
@@ -5743,6 +7244,39 @@ declare namespace CodeceptJS {
5743
7244
  * {{ react }}
5744
7245
  */
5745
7246
  click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
7247
+ /**
7248
+ * Perform an emulated click on a link or a button, given by a locator.
7249
+ * Unlike normal click instead of sending native event, emulates a click with JavaScript.
7250
+ * This works on hidden, animated or inactive elements as well.
7251
+ *
7252
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
7253
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
7254
+ * For images, the "alt" attribute and inner text of any parent links are searched.
7255
+ *
7256
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
7257
+ *
7258
+ * ```js
7259
+ * // simple link
7260
+ * I.forceClick('Logout');
7261
+ * // button of form
7262
+ * I.forceClick('Submit');
7263
+ * // CSS button
7264
+ * I.forceClick('#form input[type=submit]');
7265
+ * // XPath
7266
+ * I.forceClick('//form/*[@type=submit]');
7267
+ * // link in context
7268
+ * I.forceClick('Logout', '#nav');
7269
+ * // using strict locator
7270
+ * I.forceClick({css: 'nav a.login'});
7271
+ * ```
7272
+ *
7273
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
7274
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
7275
+ *
7276
+ *
7277
+ * {{ react }}
7278
+ */
7279
+ forceClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
5746
7280
  /**
5747
7281
  * Performs a double-click on an element matched by link|button|label|CSS or XPath.
5748
7282
  * Context can be specified as second parameter to narrow search.
@@ -6438,19 +7972,27 @@ declare namespace CodeceptJS {
6438
7972
  */
6439
7973
  saveScreenshot(fileName: string, fullPage?: boolean): void;
6440
7974
  /**
6441
- * Sets a cookie.
7975
+ * Sets cookie(s).
7976
+ *
7977
+ * Can be a single cookie object or an array of cookies:
6442
7978
  *
6443
7979
  * ```js
6444
7980
  * I.setCookie({name: 'auth', value: true});
7981
+ *
7982
+ * // as array
7983
+ * I.setCookie([
7984
+ * {name: 'auth', value: true},
7985
+ * {name: 'agree', value: true}
7986
+ * ]);
6445
7987
  * ```
6446
7988
  *
6447
- * @param {object} cookie a cookie object.
7989
+ * @param {object|array} cookie a cookie object or array of cookie objects.
6448
7990
  *
6449
7991
  *
6450
7992
  * Uses Selenium's JSON [cookie
6451
7993
  * format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
6452
7994
  */
6453
- setCookie(cookie: any): void;
7995
+ setCookie(cookie: any | any[]): void;
6454
7996
  /**
6455
7997
  * Clears a cookie by name,
6456
7998
  * if none provided clears all cookies.
@@ -6623,6 +8165,22 @@ declare namespace CodeceptJS {
6623
8165
  * _Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
6624
8166
  */
6625
8167
  pressKey(key: string | string[]): void;
8168
+ /**
8169
+ *
8170
+ * Types out the given string or the array of keys provided.
8171
+ * _Note:_ Should only be used when using [`fillField`](#fillfield) is not an option.
8172
+ *
8173
+ * ```js
8174
+ * // When passing in a string
8175
+ * I.type('Type this out.');
8176
+ * // When passing in an array
8177
+ * I.type(['T', 'E', 'X', 'T']);
8178
+ * ```
8179
+ *
8180
+ * @param {string|string[]} key or array of keys to type.
8181
+ * Type out given array of keys or a string of text
8182
+ */
8183
+ type(key: string | string[]): void;
6626
8184
  /**
6627
8185
  * Resize the current window to provided width and height.
6628
8186
  * First parameter can be set to `maximize`.
@@ -8430,9 +9988,9 @@ declare namespace CodeceptJS {
8430
9988
  * Get Mocha instance
8431
9989
  *
8432
9990
  * @api
8433
- * @returns {Mocha | {}}
9991
+ * @returns { * }
8434
9992
  */
8435
- static mocha(): Mocha | any;
9993
+ static mocha(): any;
8436
9994
  /**
8437
9995
  * Append new services to container
8438
9996
  *
@@ -8496,6 +10054,7 @@ declare namespace CodeceptJS {
8496
10054
  * @property {'test.passed'} passed
8497
10055
  * @property {'test.failed'} failed
8498
10056
  * @property {'test.finish'} finished
10057
+ * @property {'test.skipped'} skipped
8499
10058
  */
8500
10059
  const test: {
8501
10060
  started: 'test.start';
@@ -8504,6 +10063,7 @@ declare namespace CodeceptJS {
8504
10063
  passed: 'test.passed';
8505
10064
  failed: 'test.failed';
8506
10065
  finished: 'test.finish';
10066
+ skipped: 'test.skipped';
8507
10067
  };
8508
10068
  /**
8509
10069
  * @type {object}