@applitools/eyes-webdriverio 5.45.2 → 5.45.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,151 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.45.3](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-webdriverio@5.45.2...js/eyes-webdriverio@5.45.3) (2023-08-18)
4
+
5
+
6
+ ### Code Refactoring
7
+
8
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/utils bumped to 1.5.1
14
+ #### Code Refactoring
15
+
16
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
17
+ * @applitools/logger bumped to 2.0.8
18
+ #### Code Refactoring
19
+
20
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
21
+
22
+
23
+
24
+ * @applitools/socket bumped to 1.1.8
25
+ #### Code Refactoring
26
+
27
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
28
+
29
+
30
+
31
+ * @applitools/req bumped to 1.5.3
32
+ #### Code Refactoring
33
+
34
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
35
+
36
+
37
+
38
+ * @applitools/image bumped to 1.1.3
39
+ #### Code Refactoring
40
+
41
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
42
+
43
+
44
+
45
+ * @applitools/snippets bumped to 2.4.23
46
+ #### Code Refactoring
47
+
48
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
49
+ * @applitools/spec-driver-webdriver bumped to 1.0.42
50
+ #### Code Refactoring
51
+
52
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
53
+
54
+
55
+
56
+ * @applitools/spec-driver-selenium bumped to 1.5.56
57
+ #### Code Refactoring
58
+
59
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
60
+
61
+
62
+
63
+ * @applitools/spec-driver-puppeteer bumped to 1.1.73
64
+ #### Code Refactoring
65
+
66
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
67
+
68
+
69
+
70
+ * @applitools/driver bumped to 1.13.5
71
+ #### Bug Fixes
72
+
73
+ * optimize driver usage in close ([#1867](https://github.com/applitools/eyes.sdk.javascript1/issues/1867)) ([60dff6b](https://github.com/applitools/eyes.sdk.javascript1/commit/60dff6b160e69d3893c91a1125d668fa18b43072))
74
+
75
+
76
+ #### Code Refactoring
77
+
78
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
79
+
80
+
81
+
82
+ * @applitools/screenshoter bumped to 3.8.8
83
+ #### Code Refactoring
84
+
85
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
86
+
87
+
88
+
89
+ * @applitools/nml-client bumped to 1.5.8
90
+ #### Code Refactoring
91
+
92
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
93
+
94
+
95
+
96
+ * @applitools/tunnel-client bumped to 1.2.0
97
+ #### Features
98
+
99
+ * replace and destroy tunnels by tunnel id ([#1878](https://github.com/applitools/eyes.sdk.javascript1/issues/1878)) ([22bcc15](https://github.com/applitools/eyes.sdk.javascript1/commit/22bcc15b31457e3da56cdb6f73bee3dcb7e051a1))
100
+
101
+
102
+ #### Code Refactoring
103
+
104
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
105
+
106
+
107
+
108
+ * @applitools/ufg-client bumped to 1.7.1
109
+ #### Code Refactoring
110
+
111
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
112
+
113
+
114
+
115
+ * @applitools/ec-client bumped to 1.7.5
116
+ #### Code Refactoring
117
+
118
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
119
+
120
+
121
+
122
+ * @applitools/core-base bumped to 1.5.1
123
+ #### Code Refactoring
124
+
125
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
126
+
127
+
128
+
129
+ * @applitools/core bumped to 3.9.1
130
+ #### Bug Fixes
131
+
132
+ * optimize driver usage in close ([#1867](https://github.com/applitools/eyes.sdk.javascript1/issues/1867)) ([60dff6b](https://github.com/applitools/eyes.sdk.javascript1/commit/60dff6b160e69d3893c91a1125d668fa18b43072))
133
+
134
+
135
+ #### Code Refactoring
136
+
137
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
138
+
139
+
140
+
141
+ * @applitools/eyes bumped to 1.7.3
142
+ #### Code Refactoring
143
+
144
+ * refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
145
+
146
+
147
+
148
+
3
149
  ## [5.45.2](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-webdriverio@5.45.1...js/eyes-webdriverio@5.45.2) (2023-08-10)
4
150
 
5
151
 
package/dist/api.js CHANGED
@@ -29,11 +29,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.closeBatch = exports.BatchClose = exports.Configuration = exports.Target = exports.TargetAutomation = exports.CheckSettings = exports.CheckSettingsAutomation = exports.Eyes = void 0;
30
30
  const extract_environment_1 = require("./extract-environment");
31
31
  const eyes = __importStar(require("@applitools/eyes"));
32
- const spec = __importStar(require("@applitools/spec-driver-webdriverio"));
32
+ const spec = __importStar(require("./spec-driver"));
33
33
  __exportStar(require("@applitools/eyes"), exports);
34
34
  __exportStar(require("./legacy"), exports);
35
- const environment = (0, extract_environment_1.extractEnvironment)();
36
- const sdk = { spec, agentId: `eyes-webdriverio/${require('../package.json').version}`, environment };
35
+ const sdk = {
36
+ spec: spec,
37
+ agentId: `eyes-webdriverio/${require('../package.json').version}`,
38
+ environment: (0, extract_environment_1.extractEnvironment)(),
39
+ };
37
40
  class Eyes extends eyes.Eyes {
38
41
  }
39
42
  exports.Eyes = Eyes;
@@ -41,16 +44,16 @@ Eyes._sdk = sdk;
41
44
  class CheckSettingsAutomation extends eyes.CheckSettingsAutomation {
42
45
  }
43
46
  exports.CheckSettingsAutomation = CheckSettingsAutomation;
44
- CheckSettingsAutomation._spec = spec;
47
+ CheckSettingsAutomation._spec = sdk.spec;
45
48
  class CheckSettings extends CheckSettingsAutomation {
46
49
  }
47
50
  exports.CheckSettings = CheckSettings;
48
- exports.TargetAutomation = { ...eyes.TargetAutomation, spec };
49
- exports.Target = { ...eyes.Target, spec };
51
+ exports.TargetAutomation = { ...eyes.TargetAutomation, spec: sdk.spec };
52
+ exports.Target = { ...eyes.Target, spec: sdk.spec };
50
53
  class Configuration extends eyes.Configuration {
51
54
  }
52
55
  exports.Configuration = Configuration;
53
- Configuration._spec = spec;
56
+ Configuration._spec = sdk.spec;
54
57
  class BatchClose extends eyes.BatchClose {
55
58
  }
56
59
  exports.BatchClose = BatchClose;
@@ -10,6 +10,13 @@ function extractEnvironment() {
10
10
  catch {
11
11
  // NOTE: ignore error
12
12
  }
13
+ try {
14
+ const { name, version } = require('webdriver/package.json');
15
+ versions[name] = version;
16
+ }
17
+ catch {
18
+ // NOTE: ignore error
19
+ }
13
20
  return { versions };
14
21
  }
15
22
  exports.extractEnvironment = extractEnvironment;
package/dist/legacy.js CHANGED
@@ -17,7 +17,7 @@ class By {
17
17
  static attributeValue(attr, value) {
18
18
  return new By(`*[${attr}="${value}"]`);
19
19
  }
20
- // @ts-ignore
20
+ // @ts-expect-error
21
21
  static name(name) {
22
22
  return By.attributeValue('name', name);
23
23
  }
@@ -10,8 +10,272 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
13
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
27
  };
16
28
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@applitools/spec-driver-webdriverio"), exports);
29
+ exports.build = exports.findElements = exports.findElement = exports.executeScript = exports.extractSelector = exports.toSimpleCommonSelector = exports.toSelector = exports.toElement = exports.toDriver = exports.isSecondarySelector = exports.isSelector = exports.isSecondaryElement = exports.isSecondaryDriver = void 0;
30
+ const spec = __importStar(require("@applitools/spec-driver-webdriver"));
31
+ const utils = __importStar(require("@applitools/utils"));
32
+ __exportStar(require("@applitools/spec-driver-webdriver"), exports);
33
+ const LEGACY_ELEMENT_ID = 'ELEMENT';
34
+ const ELEMENT_ID = 'element-6066-11e4-a52e-4f735466cecf';
35
+ const SHADOW_ROOT_ID = 'shadow-6066-11e4-a52e-4f735466cecf';
36
+ const DIRECT_SELECTOR_REGEXP = /^(id|css selector|xpath|link text|partial link text|name|tag name|class name|-android uiautomator|-android datamatcher|-android viewmatcher|-android viewtag|-ios uiautomation|-ios predicate string|-ios class chain|accessibility id):(.+)/;
37
+ async function getSearchRoot(driver, parent) {
38
+ const root = driver.original;
39
+ if (parent) {
40
+ const elementId = parent[SHADOW_ROOT_ID] || parent[ELEMENT_ID] || parent[LEGACY_ELEMENT_ID];
41
+ return root.$({ [ELEMENT_ID]: elementId });
42
+ }
43
+ return root;
44
+ }
45
+ function isSecondaryDriver(driver) {
46
+ if (!driver)
47
+ return false;
48
+ return spec.isSecondaryDriver(driver) || utils.types.instanceOf(driver, 'Browser');
49
+ }
50
+ exports.isSecondaryDriver = isSecondaryDriver;
51
+ function isSecondaryElement(element) {
52
+ return !!(element === null || element === void 0 ? void 0 : element.elementId);
53
+ }
54
+ exports.isSecondaryElement = isSecondaryElement;
55
+ function isSelector(selector) {
56
+ return utils.types.isString(selector) || utils.types.has(selector, 'strategyName') || utils.types.isFunction(selector);
57
+ }
58
+ exports.isSelector = isSelector;
59
+ function isSecondarySelector(selector) {
60
+ return spec.isSelector(selector);
61
+ }
62
+ exports.isSecondarySelector = isSecondarySelector;
63
+ function toDriver(driver) {
64
+ if (spec.isSecondaryDriver(driver))
65
+ return spec.toDriver(driver);
66
+ if (driver.isDevTools) {
67
+ driver.addCommand('sendCommandAndGetResult', async (name, options) => {
68
+ const puppeteer = await driver.getPuppeteer();
69
+ const [page] = await puppeteer.pages();
70
+ const session = await page.target().createCDPSession();
71
+ return session.send(name, options);
72
+ });
73
+ }
74
+ const transformedDriver = Object.create(driver, {
75
+ original: { enumerable: false, get: () => driver },
76
+ });
77
+ return transformedDriver;
78
+ }
79
+ exports.toDriver = toDriver;
80
+ function toElement(element) {
81
+ if (utils.types.has(element, 'elementId')) {
82
+ return {
83
+ [ELEMENT_ID]: element.elementId,
84
+ [LEGACY_ELEMENT_ID]: element.elementId,
85
+ selector: isSelector(element.selector) ? element.selector : undefined,
86
+ };
87
+ }
88
+ return element;
89
+ }
90
+ exports.toElement = toElement;
91
+ function toSelector(selector) {
92
+ if (utils.types.has(selector, 'selector')) {
93
+ if (utils.types.has(selector, 'type') && selector.type && utils.types.isString(selector.selector)) {
94
+ return `${selector.type === 'css' ? 'css selector' : selector.type}:${selector.selector}`;
95
+ }
96
+ else if (isSelector(selector.selector)) {
97
+ return selector.selector;
98
+ }
99
+ else {
100
+ selector = selector.selector;
101
+ }
102
+ }
103
+ if (utils.types.has(selector, ['using', 'value'])) {
104
+ return `${selector.using}:${selector.value}`;
105
+ }
106
+ return selector;
107
+ }
108
+ exports.toSelector = toSelector;
109
+ function toSimpleCommonSelector(selector) {
110
+ if (utils.types.isFunction(selector) || utils.types.has(selector, 'strategyName'))
111
+ return null;
112
+ else if (utils.types.isString(selector)) {
113
+ const match = selector.match(DIRECT_SELECTOR_REGEXP);
114
+ if (!match)
115
+ return { selector };
116
+ const [, using, value] = match;
117
+ return { type: using === 'css selector' ? 'css' : using, selector: value };
118
+ }
119
+ return selector;
120
+ }
121
+ exports.toSimpleCommonSelector = toSimpleCommonSelector;
122
+ function extractSelector(element) {
123
+ var _a;
124
+ return (_a = element.selector) !== null && _a !== void 0 ? _a : null;
125
+ }
126
+ exports.extractSelector = extractSelector;
127
+ async function executeScript(driver, script, arg) {
128
+ if (driver.original.isDevTools) {
129
+ script = script.toString();
130
+ script = script.startsWith('function') ? `return (${script}).apply(null, arguments)` : script;
131
+ return driver.original.execute(runner, script.toString(), ...unwrap(arg));
132
+ }
133
+ return spec.executeScript(driver, script, arg);
134
+ function runner(script, arg, ...elements) {
135
+ return new Function(script).call(null, wrap(arg));
136
+ function wrap(value) {
137
+ if (value === 'pptr-element-marker') {
138
+ return elements.shift();
139
+ }
140
+ else if (Array.isArray(value)) {
141
+ return value.map(wrap);
142
+ }
143
+ else if (value && typeof value === 'object') {
144
+ return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, wrap(value)]));
145
+ }
146
+ else {
147
+ return value;
148
+ }
149
+ }
150
+ }
151
+ function unwrap(arg) {
152
+ if (!arg)
153
+ return [];
154
+ const elements = [];
155
+ return [unwrap(arg), ...elements];
156
+ function unwrap(value) {
157
+ if (spec.isElement(value)) {
158
+ elements.push(value);
159
+ return 'pptr-element-marker';
160
+ }
161
+ else if (utils.types.isArray(value)) {
162
+ return value.map(unwrap);
163
+ }
164
+ else if (utils.types.isObject(value)) {
165
+ return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, unwrap(value)]));
166
+ }
167
+ else {
168
+ return value;
169
+ }
170
+ }
171
+ }
172
+ }
173
+ exports.executeScript = executeScript;
174
+ async function findElement(driver, selector, parent) {
175
+ const root = await getSearchRoot(driver, parent);
176
+ try {
177
+ const element = await root.$(selector);
178
+ return !utils.types.has(element, 'error') ? spec.toElement(element) : null;
179
+ }
180
+ catch (error) {
181
+ return null;
182
+ }
183
+ }
184
+ exports.findElement = findElement;
185
+ async function findElements(driver, selector, parent) {
186
+ const root = await getSearchRoot(driver, parent);
187
+ const elements = await root.$$(selector);
188
+ return Array.from(elements, spec.toElement);
189
+ }
190
+ exports.findElements = findElements;
191
+ const browserOptionsNames = {
192
+ chrome: 'goog:chromeOptions',
193
+ firefox: 'moz:firefoxOptions',
194
+ };
195
+ async function build(env) {
196
+ let frameworkPath;
197
+ try {
198
+ frameworkPath = require.resolve('webdriverio', { paths: [`${process.cwd()}/node_modules`] });
199
+ }
200
+ catch {
201
+ frameworkPath = 'webdriverio';
202
+ }
203
+ const { remote } = require(frameworkPath);
204
+ const chromedriver = require('chromedriver');
205
+ const parseEnv = require('@applitools/test-utils/src/parse-env');
206
+ const { protocol, browser = '', emulation, capabilities, url, attach, proxy, configurable = true, args = [], headless, logLevel = 'silent', } = parseEnv(env, process.env.APPLITOOLS_WEBDRIVERIO_PROTOCOL);
207
+ const options = {
208
+ capabilities: { browserName: browser, ...capabilities },
209
+ logLevel,
210
+ connectionRetryCount: 5,
211
+ connectionRetryTimeout: 180000,
212
+ };
213
+ if (browser === 'chrome' && protocol === 'cdp') {
214
+ options.automationProtocol = 'devtools';
215
+ options.capabilities[browserOptionsNames.chrome] = { args };
216
+ options.capabilities['wdio:devtoolsOptions'] = {
217
+ headless,
218
+ ignoreDefaultArgs: ['--hide-scrollbars'],
219
+ };
220
+ }
221
+ else if (protocol === 'wd') {
222
+ options.automationProtocol = 'webdriver';
223
+ options.protocol = url.protocol ? url.protocol.replace(/:$/, '') : undefined;
224
+ options.hostname = url.hostname;
225
+ if (url.port)
226
+ options.port = Number(url.port);
227
+ else if (options.protocol === 'http')
228
+ options.port = 80;
229
+ else if (options.protocol === 'https')
230
+ options.port = 443;
231
+ options.path = url.pathname;
232
+ if (configurable) {
233
+ if (browser === 'chrome' && attach) {
234
+ await chromedriver.start(['--port=9515'], true);
235
+ options.protocol = 'http';
236
+ options.hostname = 'localhost';
237
+ options.port = 9515;
238
+ options.path = '/';
239
+ }
240
+ const browserOptionsName = browserOptionsNames[browser || options.capabilities.browserName];
241
+ if (browserOptionsName) {
242
+ const browserOptions = options.capabilities[browserOptionsName] || {};
243
+ browserOptions.args = [...(browserOptions.args || []), ...args];
244
+ if (headless)
245
+ browserOptions.args.push('headless');
246
+ if (attach) {
247
+ browserOptions.debuggerAddress = attach === true ? 'localhost:9222' : attach;
248
+ if (browser !== 'firefox')
249
+ browserOptions.w3c = false;
250
+ }
251
+ options.capabilities[browserOptionsName] = browserOptions;
252
+ }
253
+ }
254
+ }
255
+ if (proxy) {
256
+ options.capabilities.proxy = {
257
+ proxyType: 'manual',
258
+ httpProxy: proxy.http || proxy.server,
259
+ sslProxy: proxy.https || proxy.server,
260
+ ftpProxy: proxy.ftp,
261
+ noProxy: proxy.bypass.join(','),
262
+ };
263
+ }
264
+ const driver = await remote(options);
265
+ if (driver.isDevTools && emulation) {
266
+ const puppeteer = await driver.getPuppeteer();
267
+ const [page] = await puppeteer.pages();
268
+ if (emulation.deviceMetrics) {
269
+ await page.setViewport({
270
+ width: emulation.deviceMetrics.width,
271
+ height: emulation.deviceMetrics.height,
272
+ deviceScaleFactor: emulation.deviceMetrics.pixelRatio,
273
+ });
274
+ }
275
+ if (emulation.userAgent) {
276
+ await page.setUserAgent(emulation.userAgent);
277
+ }
278
+ }
279
+ return [driver, () => driver.deleteSession().then(() => chromedriver.stop())];
280
+ }
281
+ exports.build = build;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-webdriverio",
3
- "version": "5.45.2",
3
+ "version": "5.45.3",
4
4
  "description": "Applitools Eyes SDK for WebdriverIO",
5
5
  "keywords": [
6
6
  "eyes-webdriverio",
@@ -87,33 +87,37 @@
87
87
  "lint": "run --top-level eslint '**/*.ts'",
88
88
  "build": "run --top-level tspc --project tsconfig.build.v$([ ! -z $APPLITOOLS_FRAMEWORK_VERSION ] && echo $APPLITOOLS_FRAMEWORK_VERSION | cut -f1 -d'.' || echo 8).json",
89
89
  "generate:tests": "NODE_OPTIONS='--experimental-import-meta-resolve --experimental-loader=@applitools/generic/dist/code-loader.js' generic ./test/generic/config.mjs",
90
- "test": "run test:service && run test:coverage",
91
- "test:local": "run test:service && MOCHA_OMIT_TAGS=sauce run test:coverage",
90
+ "test": "run test:it && run test:service && run test:coverage",
91
+ "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/*.spec.ts' -r @applitools/test-utils/mocha-hooks/docker",
92
+ "test:local": "run test:it && run test:service && MOCHA_OMIT_TAGS=sauce run test:coverage",
93
+ "test:local:cdp": "APPLITOOLS_WEBDRIVERIO_PROTOCOL=cdp run test:local",
92
94
  "test:sauce": "MOCHA_ONLY_TAGS=sauce run test:coverage",
93
- "test:service": "MOCHA_GROUP=service run --top-level mocha './test/service/unit/*.spec.js' && wdio run ./test/service/wdio.conf.js && wdio run ./test/service/no-config/wdio.no-config.conf.js && wdio run ./test/service/vg/wdio.vg.conf.js",
95
+ "test:service": "MOCHA_GROUP=service run --top-level mocha './test/service/unit/*.spec.js' && wdio run ./test/service/wdio.conf.js --autoCompileOpts.autoCompile=0 && wdio run ./test/service/no-config/wdio.no-config.conf.js --autoCompileOpts.autoCompile=0 && wdio run ./test/service/vg/wdio.vg.conf.js --autoCompileOpts.autoCompile=0",
94
96
  "test:coverage": "APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-webdriverio' APPLITOOLS_BATCH_ID=$(uuidgen) MOCHA_GROUP=coverage run --top-level mocha './test/generated-coverage/*.spec.js' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
95
97
  "setup": "run --top-level browsers:setup",
96
- "up:framework": "run --top-level add-silent webdriverio"
98
+ "up:framework": "yarn add --dev --caret webdriverio${APPLITOOLS_FRAMEWORK_VERSION:+@$APPLITOOLS_FRAMEWORK_VERSION}"
97
99
  },
98
100
  "dependencies": {
99
- "@applitools/eyes": "1.7.2",
100
- "@applitools/spec-driver-webdriverio": "1.5.10"
101
+ "@applitools/driver": "1.13.5",
102
+ "@applitools/eyes": "1.7.3",
103
+ "@applitools/spec-driver-webdriver": "1.0.42"
101
104
  },
102
105
  "devDependencies": {
103
106
  "@applitools/api-extractor": "^1.2.21",
104
- "@applitools/bongo": "^5.4.3",
105
- "@applitools/generic": "^3.3.8",
107
+ "@applitools/bongo": "^5.6.1",
108
+ "@applitools/generic": "^3.3.9",
106
109
  "@applitools/test-utils": "^1.5.17",
107
110
  "@types/node": "^16.18.14",
108
- "@wdio/cli": "^8.3.9",
109
- "@wdio/dot-reporter": "^8.3.0",
110
- "@wdio/globals": "^8.3.9",
111
- "@wdio/local-runner": "^8.3.9",
112
- "@wdio/mocha-framework": "^8.3.0",
113
- "chromedriver": "^114.0.3",
111
+ "@wdio/cli": "^8.14.4",
112
+ "@wdio/dot-reporter": "^8.14.0",
113
+ "@wdio/globals": "^8.14.3",
114
+ "@wdio/local-runner": "^8.14.3",
115
+ "@wdio/mocha-framework": "^8.14.0",
116
+ "chromedriver": "^115.0.1",
117
+ "devtools": "^8.15.4",
114
118
  "expect-webdriverio": "^4.0.1",
115
119
  "geckodriver": "^1.20.0",
116
- "webdriverio": "^8.10.7"
120
+ "webdriverio": "^8.15.4"
117
121
  },
118
122
  "peerDependencies": {
119
123
  "webdriverio": ">=5.0.0"
package/types/index.d.ts CHANGED
@@ -1,7 +1,13 @@
1
1
  export type Driver = Applitools.WebdriverIO.Browser & { __applitoolsBrand?: undefined; };
2
- export type Element = (Applitools.WebdriverIO.Element | { ELEMENT: string; } | { 'element-6066-11e4-a52e-4f735466cecf': string; }) & { __applitoolsBrand?: undefined; };
3
- export type Selector = (Applitools.WebdriverIO.Selector | { using: string; value: string; }) & { __applitoolsBrand?: undefined; };
4
- export type SpecType = { driver: Driver; context: Driver; element: Element; selector: Selector; };
2
+ export type Element = Applitools.WebdriverIO.Element & { __applitoolsBrand?: undefined; };
3
+ export type Selector = Applitools.WebdriverIO.Selector & { __applitoolsBrand?: undefined; };
4
+ export type SpecType = {
5
+ driver: Driver;
6
+ context: Driver;
7
+ element: Element;
8
+ selector: Selector;
9
+ secondary: never;
10
+ };
5
11
  export class Eyes {
6
12
  static setViewportSize: (driver: Driver, viewportSize: RectangleSize) => Promise<void>;
7
13
  static getExecutionCloudUrl(config?: undefined | ConfigurationPlain): Promise<string>;
@@ -351,7 +357,7 @@ export type TargetAutomation = {
351
357
  webview(webview?: undefined | string): CheckSettingsAutomation;
352
358
  webview(webview?: undefined | boolean): CheckSettingsAutomation;
353
359
  };
354
- export const Target: TargetImage & TargetAutomation;
360
+ export type Target = TargetImage & TargetAutomation;
355
361
  export type OCRRegion = { target: Element | RegionPlain | EyesSelector<Selector>; hint?: undefined | string; minMatch?: undefined | number; language?: undefined | string; };
356
362
  export type ConfigurationPlain = {
357
363
  debugScreenshots?: undefined | { save: boolean; path?: undefined | string; prefix?: undefined | string; };
@@ -664,7 +670,7 @@ export class BatchClose {
664
670
  setProxy(proxy: ProxySettingsPlain): BatchClose;
665
671
  }
666
672
  export const closeBatch: (options: { batchIds: Array<string>; serverUrl: string; apiKey: string; proxy?: undefined | ProxySettingsPlain; }) => Promise<void>;
667
- export type BrowserTypePlain = "chrome" | "chrome-one-version-back" | "chrome-two-versions-back" | "firefox" | "firefox-one-version-back" | "firefox-two-versions-back" | "ie" | "ie10" | "edge" | "edgechromium" | "edgelegacy" | "edgechromium-one-version-back" | "edgechromium-two-versions-back" | "safari" | "safari-earlyaccess" | "safari-one-version-back" | "safari-two-versions-back";
673
+ export type BrowserTypePlain = "chrome" | "firefox" | "chrome-one-version-back" | "chrome-two-versions-back" | "firefox-one-version-back" | "firefox-two-versions-back" | "ie" | "ie10" | "edge" | "edgechromium" | "edgelegacy" | "edgechromium-one-version-back" | "edgechromium-two-versions-back" | "safari" | "safari-earlyaccess" | "safari-one-version-back" | "safari-two-versions-back";
668
674
  export enum BrowserType {
669
675
  CHROME = 'chrome',
670
676
  CHROME_ONE_VERSION_BACK = 'chrome-one-version-back',
@@ -1,34 +1,20 @@
1
- import type {
2
- Element,
3
- Selector,
4
- Eyes,
5
- ConfigurationPlain,
6
- Configuration,
7
- CheckSettingsPlain,
8
- CheckSettings,
9
- TestResults,
10
- TestResultsSummary,
11
- } from './index'
12
-
13
- declare global {
14
- namespace WebdriverIO {
15
- interface ServiceOption extends ConfigurationPlain {
16
- useVisualGrid?: boolean
17
- concurrency?: number
18
- eyes?: ServiceOption
19
- }
20
- interface Browser {
21
- getEyes(): Eyes
22
- eyesCheck(checkSettings?: CheckSettingsPlain): Promise<void>
23
- eyesCheck(title: string, checkSettings: CheckSettings): Promise<void>
24
- eyesSetScrollRootElement(element: Element | Selector): void
25
- eyesAddProperty(key: string, value: string): void
26
- eyesClearProperties(): void
27
- eyesGetTestResults(): Promise<TestResults>
28
- eyesSetConfiguration(configuration: ConfigurationPlain): void
29
- eyesGetConfiguration(): Configuration
30
- eyesGetIsOpen(): boolean
31
- eyesGetAllTestResults(throwErr: boolean): Promise<TestResultsSummary>
32
- }
33
- }
1
+ import { ConfigurationPlain } from './api';
2
+ interface EyesServiceOptions extends ConfigurationPlain {
3
+ useVisualGrid?: boolean;
4
+ concurrency?: number;
5
+ eyes?: EyesServiceOptions;
34
6
  }
7
+ declare class EyesService {
8
+ private _eyes;
9
+ private _appName?;
10
+ private _testResults?;
11
+ constructor({ useVisualGrid, concurrency, eyes, ...config }: EyesServiceOptions);
12
+ private _eyesOpen;
13
+ private _eyesClose;
14
+ beforeSession(config: Record<string, unknown>): void;
15
+ before(): void;
16
+ beforeTest(test: any): void;
17
+ afterTest(): Promise<void>;
18
+ after(): Promise<void>;
19
+ }
20
+ export = EyesService;
@@ -1 +1,32 @@
1
- /// <reference types="@applitools/spec-driver-webdriverio/v5/async"/>
1
+ // @ts-nocheck
2
+
3
+ declare namespace Applitools {
4
+ namespace WebdriverIO {
5
+ interface Browser extends globalThis.WebdriverIOAsync.BrowserObject {
6
+ isDevTools: boolean,
7
+ getSession(): Promise<Record<string, any>>
8
+ getPuppeteer(): Promise<any>
9
+ getUrl(): Promise<string>
10
+ getTitle(): Promise<string>
11
+ getOrientation(): Promise<string>
12
+ setOrientation(orientation: string): Promise<void>
13
+ getSystemBars(): Promise<object[]>
14
+ getContext(): Promise<string>
15
+ getElementAttribute(elementId: string, attr: string): Promise<string>
16
+ getWindowRect(): Promise<{x: number; y: number; width: number; height: number}>
17
+ getWindowPosition(): Promise<{x: number; y: number}>
18
+ _getWindowSize(): Promise<{width: number; height: number}>
19
+ setWindowRect(x: number, y: number, width: number, height: number): Promise<void>
20
+ setWindowPosition(x: number, y: number): Promise<void>
21
+ _setWindowSize(width: number, height: number): Promise<void>
22
+ switchToFrame(frameId?: any): Promise<void>
23
+ switchToParentFrame(): Promise<void>
24
+ takeScreenshot(): Promise<string>
25
+ sendCommandAndGetResult(command: string, params: Record<string, any>): Promise<Record<string, any>>
26
+ switchContext(id: string): Promise<void>
27
+ getContexts(): Promise<string[]>
28
+ }
29
+ interface Element extends globalThis.WebdriverIOAsync.Element {}
30
+ type Selector = string | ((element: HTMLElement) => HTMLElement) | ((element: HTMLElement) => HTMLElement[])
31
+ }
32
+ }
@@ -1 +1,32 @@
1
- /// <reference types="@applitools/spec-driver-webdriverio/v5/sync"/>
1
+ // @ts-nocheck
2
+
3
+ declare namespace Applitools {
4
+ namespace WebdriverIO {
5
+ interface Browser extends globalThis.WebdriverIO.BrowserObject {
6
+ isDevTools: boolean
7
+ getSession(): Record<string, any>
8
+ getPuppeteer(): any
9
+ getUrl(): string
10
+ getTitle(): string
11
+ getOrientation(): string
12
+ setOrientation(orientation: string): void
13
+ getSystemBars(): object[]
14
+ getContext(): string
15
+ getElementAttribute(elementId: string, attr: string): string
16
+ getWindowRect(): {x: number; y: number; width: number; height: number}
17
+ getWindowPosition(): {x: number; y: number}
18
+ _getWindowSize(): {width: number; height: number}
19
+ setWindowRect(x: number, y: number, width: number, height: number): void
20
+ setWindowPosition(x: number, y: number): void
21
+ _setWindowSize(width: number, height: number): void
22
+ switchToFrame(frameId?: any): void
23
+ switchToParentFrame(): void
24
+ takeScreenshot(): string
25
+ sendCommandAndGetResult(command: string, params: Record<string, any>): Record<string, any>
26
+ switchContext(id: string): void
27
+ getContexts(): string[]
28
+ }
29
+ interface Element extends globalThis.WebdriverIO.Element {}
30
+ type Selector = string | ((element: HTMLElement) => HTMLElement) | ((element: HTMLElement) => HTMLElement[])
31
+ }
32
+ }
package/types/v6.d.ts CHANGED
@@ -1 +1,9 @@
1
- /// <reference types="@applitools/spec-driver-webdriverio/v6"/>
1
+ // @ts-nocheck
2
+
3
+ declare namespace Applitools {
4
+ namespace WebdriverIO {
5
+ interface Browser extends globalThis.WebdriverIO.BrowserObject {}
6
+ interface Element extends globalThis.WebdriverIO.Element {}
7
+ type Selector = string | ((element: HTMLElement) => HTMLElement) | ((element: HTMLElement) => HTMLElement[])
8
+ }
9
+ }
package/types/v7.d.ts CHANGED
@@ -1 +1,9 @@
1
- /// <reference types="@applitools/spec-driver-webdriverio/v7"/>
1
+ // @ts-nocheck
2
+
3
+ declare namespace Applitools {
4
+ namespace WebdriverIO {
5
+ interface Browser extends globalThis.WebdriverIO.Browser {}
6
+ interface Element extends globalThis.WebdriverIO.Element {}
7
+ type Selector = string | ((element: HTMLElement) => HTMLElement) | ((element: HTMLElement) => HTMLElement[])
8
+ }
9
+ }
package/types/v8.d.ts CHANGED
@@ -1 +1,9 @@
1
- /// <reference types="@applitools/spec-driver-webdriverio/v8"/>
1
+ // @ts-nocheck
2
+
3
+ declare namespace Applitools {
4
+ namespace WebdriverIO {
5
+ interface Browser extends globalThis.WebdriverIO.Browser {}
6
+ interface Element extends globalThis.WebdriverIO.Element {}
7
+ type Selector = string | import('webdriverio').ElementFunction | import('webdriverio').CustomStrategyReference
8
+ }
9
+ }