@applitools/spec-driver-puppeteer 1.3.4 → 1.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-puppeteer@1.3.5...js/spec-driver-puppeteer@1.4.0) (2024-02-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * added support for puppeteer >= 22 ([#2185](https://github.com/applitools/eyes.sdk.javascript1/issues/2185)) ([59d23a9](https://github.com/applitools/eyes.sdk.javascript1/commit/59d23a9689d77c7db06df53b67fa293a3b3f166e))
9
+
10
+ ## [1.3.5](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-puppeteer@1.3.4...js/spec-driver-puppeteer@1.3.5) (2024-01-30)
11
+
12
+
13
+ ### Dependencies
14
+
15
+ * @applitools/snippets bumped to 2.4.25
16
+ #### Bug Fixes
17
+
18
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
19
+ * @applitools/driver bumped to 1.16.2
20
+ #### Bug Fixes
21
+
22
+ * losing root context after layout breakpoints reload ([#2113](https://github.com/applitools/eyes.sdk.javascript1/issues/2113)) ([afa1473](https://github.com/applitools/eyes.sdk.javascript1/commit/afa14735e5539ab0f79aa610e6ec1ea8989a5922))
23
+
24
+
25
+
26
+
3
27
  ## [1.3.4](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-puppeteer@1.3.3...js/spec-driver-puppeteer@1.3.4) (2023-12-19)
4
28
 
5
29
 
@@ -100,6 +100,26 @@ const XPATH_SELECTOR_START = ['/', '(', '../', './', '*/'];
100
100
  function isXpathSelector(selector) {
101
101
  return XPATH_SELECTOR_START.some(start => selector.startsWith(start));
102
102
  }
103
+ function getFrameworkMajorVersion() {
104
+ let frameworkManifestPath;
105
+ try {
106
+ frameworkManifestPath = require.resolve('puppeteer/package.json', { paths: [`${process.cwd()}/node_modules`] });
107
+ }
108
+ catch {
109
+ frameworkManifestPath = 'puppeteer/package.json';
110
+ }
111
+ return Number.parseInt(require(frameworkManifestPath).version);
112
+ }
113
+ function getPuppeteer() {
114
+ let frameworkPath;
115
+ try {
116
+ frameworkPath = require.resolve('puppeteer', { paths: [`${process.cwd()}/node_modules`] });
117
+ }
118
+ catch {
119
+ frameworkPath = 'puppeteer';
120
+ }
121
+ return require(frameworkPath);
122
+ }
103
123
  function isDriver(page) {
104
124
  if (!page)
105
125
  return false;
@@ -155,12 +175,22 @@ async function executeScript(frame, script, arg) {
155
175
  exports.executeScript = executeScript;
156
176
  async function findElement(frame, selector, parent) {
157
177
  const root = parent !== null && parent !== void 0 ? parent : frame;
158
- return (isXpathSelector(selector) ? root.$x(selector).then(elements => elements[0]) : root.$(selector));
178
+ if (isXpathSelector(selector)) {
179
+ return getFrameworkMajorVersion() < 22
180
+ ? root.$x(selector).then(elements => elements[0])
181
+ : root.$(`xpath/${selector}`);
182
+ }
183
+ return root.$(selector);
159
184
  }
160
185
  exports.findElement = findElement;
161
186
  async function findElements(frame, selector, parent) {
162
187
  const root = parent !== null && parent !== void 0 ? parent : frame;
163
- return (isXpathSelector(selector) ? root.$x(selector) : root.$$(selector));
188
+ if (isXpathSelector(selector)) {
189
+ return getFrameworkMajorVersion() < 22
190
+ ? root.$x(selector)
191
+ : root.$$(`xpath/${selector}`);
192
+ }
193
+ return root.$$(selector);
164
194
  }
165
195
  exports.findElements = findElements;
166
196
  async function setElementText(_frame, element, text) {
@@ -250,14 +280,8 @@ const browserNames = ['chrome', 'firefox'];
250
280
  * installed in the SDK, then this function will error.
251
281
  */
252
282
  async function build(env) {
253
- let frameworkPath;
254
- try {
255
- frameworkPath = require.resolve('puppeteer', { paths: [`${process.cwd()}/node_modules`] });
256
- }
257
- catch {
258
- frameworkPath = 'puppeteer';
259
- }
260
- const puppeteer = require(frameworkPath);
283
+ const puppeteer = getPuppeteer();
284
+ const puppeteerVersion = getFrameworkMajorVersion();
261
285
  const parseEnv = require('@applitools/test-utils/src/parse-env');
262
286
  const { browser, attach, proxy, args = [], headless } = parseEnv(env, 'cdp');
263
287
  if (!browserNames.includes(browser))
@@ -278,6 +302,8 @@ async function build(env) {
278
302
  product: browser,
279
303
  protocol: 'cdp',
280
304
  };
305
+ if (puppeteerVersion >= 22 && options.headless === true)
306
+ options.headless = 'shell';
281
307
  if (proxy) {
282
308
  options.proxy = {
283
309
  server: proxy.https || proxy.http || proxy.server,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/spec-driver-puppeteer",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "keywords": [
5
5
  "puppeteer",
6
6
  "chrome devtools protocol",
@@ -40,14 +40,14 @@
40
40
  "up:framework": "echo \"$(jq '.devDependencies.puppeteer = $ENV.APPLITOOLS_FRAMEWORK_VERSION' ./package.json)\" > ./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@applitools/driver": "1.16.1",
43
+ "@applitools/driver": "1.16.2",
44
44
  "@applitools/utils": "1.7.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@applitools/api-extractor": "^1.2.22",
48
48
  "@applitools/test-utils": "^1.5.17",
49
49
  "@types/node": "^12.20.55",
50
- "puppeteer": "^21.5.0"
50
+ "puppeteer": "^22.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "puppeteer": ">=5.3.0"