codeceptjs 3.5.12-beta.1 → 3.5.12-beta.3

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 (2) hide show
  1. package/lib/locator.js +13 -4
  2. package/package.json +9 -8
package/lib/locator.js CHANGED
@@ -1,4 +1,4 @@
1
- const cssToXPath = require('csstoxpath');
1
+ let cssToXPath;
2
2
  const { sprintf } = require('sprintf-js');
3
3
 
4
4
  const { xpathLocator } = require('./utils');
@@ -162,8 +162,17 @@ class Locator {
162
162
  * @returns {string}
163
163
  */
164
164
  toXPath(pseudoSelector = '') {
165
+ const locator = `${this.value}${pseudoSelector}`;
166
+ const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang'];
167
+
168
+ if (limitation.some(item => locator.includes(item))) {
169
+ cssToXPath = require('css-to-xpath');
170
+ } else {
171
+ cssToXPath = require('csstoxpath');
172
+ }
173
+
165
174
  if (this.isXPath()) return this.value;
166
- if (this.isCSS()) return cssToXPath(`${this.value}${pseudoSelector}`);
175
+ if (this.isCSS()) return cssToXPath(locator);
167
176
 
168
177
  throw new Error('Can\'t be converted to XPath');
169
178
  }
@@ -250,7 +259,7 @@ class Locator {
250
259
  */
251
260
  withText(text) {
252
261
  text = xpathLocator.literal(text);
253
- const xpath = this.toXPath(`:text-contains-case(${text})`);
262
+ const xpath = sprintf('%s[%s]', this.toXPath(), `contains(., ${text})`);
254
263
  return new Locator({ xpath });
255
264
  }
256
265
 
@@ -261,7 +270,7 @@ class Locator {
261
270
  */
262
271
  withTextEquals(text) {
263
272
  text = xpathLocator.literal(text);
264
- const xpath = this.toXPath(`:text-case(${text})`);
273
+ const xpath = sprintf('%s[%s]', this.toXPath(), `.= ${text}`);
265
274
  return new Locator({ xpath });
266
275
  }
267
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.5.12-beta.1",
3
+ "version": "3.5.12-beta.3",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -76,14 +76,15 @@
76
76
  "axios": "1.6.3",
77
77
  "chai": "4.3.8",
78
78
  "chai-deep-match": "1.2.1",
79
- "chai-exclude": "^2.1.0",
80
- "chai-json-schema": "^1.5.1",
81
- "chai-json-schema-ajv": "^5.2.4",
82
- "chai-match-pattern": "^1.3.0",
83
- "chai-string": "^1.5.0",
79
+ "chai-exclude": "2.1.0",
80
+ "chai-json-schema": "1.5.1",
81
+ "chai-json-schema-ajv": "5.2.4",
82
+ "chai-match-pattern": "1.3.0",
83
+ "chai-string": "1.5.0",
84
84
  "chalk": "4.1.2",
85
85
  "commander": "11.1.0",
86
86
  "cross-spawn": "7.0.3",
87
+ "css-to-xpath": "0.1.0",
87
88
  "csstoxpath": "1.6.0",
88
89
  "devtools": "8.27.2",
89
90
  "envinfo": "7.11.0",
@@ -92,7 +93,7 @@
92
93
  "fn-args": "4.0.0",
93
94
  "fs-extra": "11.2.0",
94
95
  "glob": "6.0.1",
95
- "html-minifier-terser": "^7.2.0",
96
+ "html-minifier-terser": "7.2.0",
96
97
  "inquirer": "6.5.2",
97
98
  "joi": "17.11.0",
98
99
  "js-beautify": "1.14.11",
@@ -118,7 +119,7 @@
118
119
  "@faker-js/faker": "7.6.0",
119
120
  "@pollyjs/adapter-puppeteer": "6.0.6",
120
121
  "@pollyjs/core": "5.1.0",
121
- "@types/chai": "^4.3.7",
122
+ "@types/chai": "4.3.7",
122
123
  "@types/inquirer": "9.0.3",
123
124
  "@types/node": "20.10.7",
124
125
  "@wdio/sauce-service": "8.27.0",