codeceptjs 3.6.5-beta.5 → 3.6.5

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 CHANGED
@@ -9,7 +9,6 @@ Build Status:
9
9
 
10
10
  Appium Helper:
11
11
  [![Appium V2 Tests - Android](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_Android.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_Android.yml)
12
- [![Appium V2 Tests - iOS](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_iOS.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appiumV2_iOS.yml)
13
12
 
14
13
  Web Helper:
15
14
  [![Playwright Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/playwright.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/playwright.yml)
@@ -0,0 +1,6 @@
1
+ Waits for element to become disabled (by default waits for 1sec).
2
+ Element can be located by CSS or XPath.
3
+
4
+ @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
5
+ @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
6
+ @returns {void} automatically synchronized promise through #recorder
@@ -2476,7 +2476,7 @@ class Playwright extends Helper {
2476
2476
  async waitForEnabled(locator, sec) {
2477
2477
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2478
2478
  locator = new Locator(locator, 'css')
2479
- const matcher = await this.context
2479
+
2480
2480
  let waiter
2481
2481
  const context = await this._getContext()
2482
2482
  if (!locator.isXPath()) {
@@ -2498,6 +2498,34 @@ class Playwright extends Helper {
2498
2498
  })
2499
2499
  }
2500
2500
 
2501
+ /**
2502
+ * {{> waitForDisabled }}
2503
+ */
2504
+ async waitForDisabled(locator, sec) {
2505
+ const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2506
+ locator = new Locator(locator, 'css')
2507
+
2508
+ let waiter
2509
+ const context = await this._getContext()
2510
+ if (!locator.isXPath()) {
2511
+ const valueFn = function ([locator]) {
2512
+ return Array.from(document.querySelectorAll(locator)).filter((el) => el.disabled).length > 0
2513
+ }
2514
+ waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout })
2515
+ } else {
2516
+ const disabledFn = function ([locator, $XPath]) {
2517
+ eval($XPath) // eslint-disable-line no-eval
2518
+ return $XPath(null, locator).filter((el) => el.disabled).length > 0
2519
+ }
2520
+ waiter = context.waitForFunction(disabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout })
2521
+ }
2522
+ return waiter.catch((err) => {
2523
+ throw new Error(
2524
+ `element (${locator.toString()}) is still enabled after ${waitTimeout / 1000} sec\n${err.message}`,
2525
+ )
2526
+ })
2527
+ }
2528
+
2501
2529
  /**
2502
2530
  * {{> waitForValue }}
2503
2531
  */
@@ -206,7 +206,7 @@ class REST extends Helper {
206
206
  : this.debugSection('Request', JSON.stringify(_debugRequest))
207
207
 
208
208
  if (this.options.printCurl) {
209
- this.debugSection('CURL Request', curlize(request));
209
+ this.debugSection('CURL Request', curlize(request))
210
210
  }
211
211
 
212
212
  let response
@@ -393,8 +393,13 @@ class REST extends Helper {
393
393
  module.exports = REST
394
394
 
395
395
  function curlize(request) {
396
- if (request.data?.constructor.name.toLowerCase() === 'formdata') return 'cURL is not printed as the request body is not a JSON'
397
- let curl = `curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace("'", '')
396
+ if (request.data?.constructor.name.toLowerCase() === 'formdata')
397
+ return 'cURL is not printed as the request body is not a JSON'
398
+ let curl =
399
+ `curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace(
400
+ "'",
401
+ '',
402
+ )
398
403
 
399
404
  if (request.headers) {
400
405
  Object.entries(request.headers).forEach(([key, value]) => {
@@ -411,4 +416,3 @@ function curlize(request) {
411
416
  }
412
417
  return curl
413
418
  }
414
-
package/lib/locator.js CHANGED
@@ -175,7 +175,7 @@ class Locator {
175
175
  */
176
176
  toXPath(pseudoSelector = '') {
177
177
  const locator = `${this.value}${pseudoSelector}`;
178
- const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang', ':nth-child'];
178
+ const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang', ':nth-child', ':has'];
179
179
 
180
180
  if (limitation.some(item => locator.includes(item))) {
181
181
  cssToXPath = require('css-to-xpath');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.6.5-beta.5",
3
+ "version": "3.6.5",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -75,7 +75,7 @@
75
75
  "@cucumber/gherkin": "26",
76
76
  "@cucumber/messages": "25.0.1",
77
77
  "@xmldom/xmldom": "0.8.10",
78
- "acorn": "8.11.3",
78
+ "acorn": "8.12.1",
79
79
  "arrify": "2.0.1",
80
80
  "axios": "1.7.2",
81
81
  "chai": "5.1.1",
@@ -90,7 +90,7 @@
90
90
  "cross-spawn": "7.0.3",
91
91
  "css-to-xpath": "0.1.0",
92
92
  "csstoxpath": "1.6.0",
93
- "devtools": "8.39.0",
93
+ "devtools": "8.39.1",
94
94
  "envinfo": "7.11.1",
95
95
  "escape-string-regexp": "4.0.0",
96
96
  "figures": "3.2.0",
@@ -99,13 +99,13 @@
99
99
  "glob": "6.0.1",
100
100
  "html-minifier-terser": "7.2.0",
101
101
  "inquirer": "6.5.2",
102
- "joi": "17.13.1",
102
+ "joi": "17.13.3",
103
103
  "js-beautify": "1.15.1",
104
104
  "lodash.clonedeep": "4.5.0",
105
105
  "lodash.merge": "4.6.2",
106
106
  "mkdirp": "1.0.4",
107
- "mocha": "10.5.2",
108
- "monocart-coverage-reports": "2.8.3",
107
+ "mocha": "10.6.0",
108
+ "monocart-coverage-reports": "2.10.0",
109
109
  "ms": "2.1.3",
110
110
  "ora-classic": "5.4.2",
111
111
  "pactum": "3.6.9",
@@ -127,7 +127,7 @@
127
127
  "@types/chai": "4.3.16",
128
128
  "@types/inquirer": "9.0.3",
129
129
  "@types/node": "20.11.30",
130
- "@wdio/sauce-service": "8.39.0",
130
+ "@wdio/sauce-service": "8.39.1",
131
131
  "@wdio/selenium-standalone-service": "8.3.2",
132
132
  "@wdio/utils": "8.38.2",
133
133
  "@xmldom/xmldom": "0.8.10",
@@ -136,7 +136,7 @@
136
136
  "chai-subset": "1.6.0",
137
137
  "contributor-faces": "1.1.0",
138
138
  "documentation": "12.3.0",
139
- "electron": "30.1.0",
139
+ "electron": "31.3.0",
140
140
  "eslint": "8.57.0",
141
141
  "eslint-config-airbnb-base": "15.0.0",
142
142
  "eslint-plugin-import": "2.29.1",
@@ -144,12 +144,12 @@
144
144
  "expect": "29.7.0",
145
145
  "express": "4.19.2",
146
146
  "graphql": "16.9.0",
147
- "husky": "8.0.3",
147
+ "husky": "9.1.1",
148
148
  "inquirer-test": "2.0.1",
149
149
  "jsdoc": "4.0.3",
150
150
  "jsdoc-typeof-plugin": "1.0.0",
151
151
  "json-server": "0.10.1",
152
- "playwright": "1.45.0",
152
+ "playwright": "1.45.3",
153
153
  "prettier": "^3.3.2",
154
154
  "puppeteer": "22.12.1",
155
155
  "qrcode-terminal": "0.12.0",
@@ -162,11 +162,11 @@
162
162
  "ts-node": "10.9.2",
163
163
  "tsd": "^0.31.0",
164
164
  "tsd-jsdoc": "2.5.0",
165
- "typedoc": "0.25.13",
166
- "typedoc-plugin-markdown": "4.0.3",
167
- "typescript": "5.4.5",
165
+ "typedoc": "0.26.5",
166
+ "typedoc-plugin-markdown": "4.2.1",
167
+ "typescript": "5.5.3",
168
168
  "wdio-docker-service": "1.5.0",
169
- "webdriverio": "8.38.2",
169
+ "webdriverio": "8.39.1",
170
170
  "xml2js": "0.6.2",
171
171
  "xpath": "0.0.34"
172
172
  },
@@ -1180,8 +1180,6 @@ declare namespace CodeceptJS {
1180
1180
  *
1181
1181
  * ## Methods
1182
1182
  */
1183
- // @ts-ignore
1184
- // @ts-ignore
1185
1183
  class ExpectHelper {
1186
1184
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
1187
1185
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
@@ -1293,8 +1291,6 @@ declare namespace CodeceptJS {
1293
1291
  *
1294
1292
  * ## Methods
1295
1293
  */
1296
- // @ts-ignore
1297
- // @ts-ignore
1298
1294
  class ExpectHelper {
1299
1295
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
1300
1296
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
@@ -1966,8 +1962,6 @@ declare namespace CodeceptJS {
1966
1962
  * @property [host = "0.0.0.0"] - Mock server host
1967
1963
  * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1968
1964
  */
1969
- // @ts-ignore
1970
- // @ts-ignore
1971
1965
  type MockServerConfig = {
1972
1966
  port?: number;
1973
1967
  host?: string;
@@ -2092,8 +2086,6 @@ declare namespace CodeceptJS {
2092
2086
  *
2093
2087
  * ## Methods
2094
2088
  */
2095
- // @ts-ignore
2096
- // @ts-ignore
2097
2089
  class MockServer {
2098
2090
  /**
2099
2091
  * Start the mock server
@@ -3167,8 +3159,6 @@ declare namespace CodeceptJS {
3167
3159
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
3168
3160
  * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
3169
3161
  */
3170
- // @ts-ignore
3171
- // @ts-ignore
3172
3162
  type PlaywrightConfig = {
3173
3163
  url?: string;
3174
3164
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -4762,6 +4752,13 @@ declare namespace CodeceptJS {
4762
4752
  * @param [sec = 1] - (optional) time in seconds to wait, 1 by default.
4763
4753
  */
4764
4754
  waitForEnabled(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
4755
+ /**
4756
+ * Waits for element to become disabled (by default waits for 1sec).
4757
+ * Element can be located by CSS or XPath.
4758
+ * @param locator - element located by CSS|XPath|strict locator.
4759
+ * @param [sec = 1] - (optional) time in seconds to wait, 1 by default.
4760
+ */
4761
+ waitForDisabled(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
4765
4762
  /**
4766
4763
  * Waits for the specified value to be in value attribute.
4767
4764
  *
@@ -6538,8 +6535,6 @@ declare namespace CodeceptJS {
6538
6535
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
6539
6536
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6540
6537
  */
6541
- // @ts-ignore
6542
- // @ts-ignore
6543
6538
  type PuppeteerConfig = {
6544
6539
  url: string;
6545
6540
  basicAuth?: any;
@@ -8346,8 +8341,6 @@ declare namespace CodeceptJS {
8346
8341
  * @property [onResponse] - an async function which can update response object.
8347
8342
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
8348
8343
  */
8349
- // @ts-ignore
8350
- // @ts-ignore
8351
8344
  type RESTConfig = {
8352
8345
  endpoint?: string;
8353
8346
  prettyPrintJson?: boolean;
@@ -9466,8 +9459,6 @@ declare namespace CodeceptJS {
9466
9459
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
9467
9460
  * @property [devtoolsProtocol = false] - enable devtools protocol. Default: false. More info: https://webdriver.io/docs/automationProtocols/#devtools-protocol.
9468
9461
  */
9469
- // @ts-ignore
9470
- // @ts-ignore
9471
9462
  type WebDriverConfig = {
9472
9463
  url: string;
9473
9464
  browser: string;
@@ -1204,8 +1204,6 @@ declare namespace CodeceptJS {
1204
1204
  *
1205
1205
  * ## Methods
1206
1206
  */
1207
- // @ts-ignore
1208
- // @ts-ignore
1209
1207
  class ExpectHelper {
1210
1208
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1211
1209
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
@@ -1317,8 +1315,6 @@ declare namespace CodeceptJS {
1317
1315
  *
1318
1316
  * ## Methods
1319
1317
  */
1320
- // @ts-ignore
1321
- // @ts-ignore
1322
1318
  class ExpectHelper {
1323
1319
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1324
1320
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
@@ -1993,8 +1989,6 @@ declare namespace CodeceptJS {
1993
1989
  * @property [host = "0.0.0.0"] - Mock server host
1994
1990
  * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1995
1991
  */
1996
- // @ts-ignore
1997
- // @ts-ignore
1998
1992
  type MockServerConfig = {
1999
1993
  port?: number;
2000
1994
  host?: string;
@@ -2119,8 +2113,6 @@ declare namespace CodeceptJS {
2119
2113
  *
2120
2114
  * ## Methods
2121
2115
  */
2122
- // @ts-ignore
2123
- // @ts-ignore
2124
2116
  class MockServer {
2125
2117
  /**
2126
2118
  * Start the mock server
@@ -3260,8 +3252,6 @@ declare namespace CodeceptJS {
3260
3252
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
3261
3253
  * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
3262
3254
  */
3263
- // @ts-ignore
3264
- // @ts-ignore
3265
3255
  type PlaywrightConfig = {
3266
3256
  url?: string;
3267
3257
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -4914,6 +4904,14 @@ declare namespace CodeceptJS {
4914
4904
  * @returns automatically synchronized promise through #recorder
4915
4905
  */
4916
4906
  waitForEnabled(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4907
+ /**
4908
+ * Waits for element to become disabled (by default waits for 1sec).
4909
+ * Element can be located by CSS or XPath.
4910
+ * @param locator - element located by CSS|XPath|strict locator.
4911
+ * @param [sec = 1] - (optional) time in seconds to wait, 1 by default.
4912
+ * @returns automatically synchronized promise through #recorder
4913
+ */
4914
+ waitForDisabled(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4917
4915
  /**
4918
4916
  * Waits for the specified value to be in value attribute.
4919
4917
  *
@@ -6781,8 +6779,6 @@ declare namespace CodeceptJS {
6781
6779
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
6782
6780
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6783
6781
  */
6784
- // @ts-ignore
6785
- // @ts-ignore
6786
6782
  type PuppeteerConfig = {
6787
6783
  url: string;
6788
6784
  basicAuth?: any;
@@ -8725,8 +8721,6 @@ declare namespace CodeceptJS {
8725
8721
  * @property [onResponse] - an async function which can update response object.
8726
8722
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
8727
8723
  */
8728
- // @ts-ignore
8729
- // @ts-ignore
8730
8724
  type RESTConfig = {
8731
8725
  endpoint?: string;
8732
8726
  prettyPrintJson?: boolean;
@@ -9905,8 +9899,6 @@ declare namespace CodeceptJS {
9905
9899
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
9906
9900
  * @property [devtoolsProtocol = false] - enable devtools protocol. Default: false. More info: https://webdriver.io/docs/automationProtocols/#devtools-protocol.
9907
9901
  */
9908
- // @ts-ignore
9909
- // @ts-ignore
9910
9902
  type WebDriverConfig = {
9911
9903
  url: string;
9912
9904
  browser: string;