@testim/testim-cli 3.267.0 → 3.269.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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.267.0",
3
+ "version": "3.269.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@testim/testim-cli",
9
- "version": "3.267.0",
9
+ "version": "3.269.0",
10
10
  "license": "Proprietary",
11
11
  "dependencies": {
12
12
  "@applitools/eyes-sdk-core": "13.11.21",
@@ -1460,9 +1460,9 @@
1460
1460
  }
1461
1461
  },
1462
1462
  "node_modules/@wdio/types/node_modules/@types/node": {
1463
- "version": "18.11.11",
1464
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
1465
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
1463
+ "version": "18.11.15",
1464
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
1465
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
1466
1466
  },
1467
1467
  "node_modules/@wdio/utils": {
1468
1468
  "version": "7.24.0",
@@ -4416,9 +4416,9 @@
4416
4416
  "integrity": "sha512-+iipnm2hvmlWs4MVNx7HwSTxhDxsXnQyK5F1OalZVXeUhdPgP/23T42NCyg0TK3wL/Yg92SVrSuGKqdg12o54w=="
4417
4417
  },
4418
4418
  "node_modules/devtools/node_modules/@types/node": {
4419
- "version": "18.11.11",
4420
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
4421
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
4419
+ "version": "18.11.15",
4420
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
4421
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
4422
4422
  },
4423
4423
  "node_modules/devtools/node_modules/ua-parser-js": {
4424
4424
  "version": "1.0.32",
@@ -6216,9 +6216,9 @@
6216
6216
  }
6217
6217
  },
6218
6218
  "node_modules/got": {
6219
- "version": "11.8.5",
6220
- "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
6221
- "integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==",
6219
+ "version": "11.8.6",
6220
+ "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
6221
+ "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==",
6222
6222
  "dependencies": {
6223
6223
  "@sindresorhus/is": "^4.0.0",
6224
6224
  "@szmarczak/http-timer": "^4.0.5",
@@ -15393,9 +15393,9 @@
15393
15393
  }
15394
15394
  },
15395
15395
  "node_modules/vm2": {
15396
- "version": "3.9.12",
15397
- "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.12.tgz",
15398
- "integrity": "sha512-OMmRsKh1gmdosFzuqmj6O43hqIStqXA24YbwjtUTO0TkOBP8yLNHLplbr4odnAzEcMnm9lt2r3R8kTivn8urMg==",
15396
+ "version": "3.9.13",
15397
+ "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.13.tgz",
15398
+ "integrity": "sha512-0rvxpB8P8Shm4wX2EKOiMp7H2zq+HUE/UwodY0pCZXs9IffIKZq6vUti5OgkVCTakKo9e/fgO4X1fkwfjWxE3Q==",
15399
15399
  "dependencies": {
15400
15400
  "acorn": "^8.7.0",
15401
15401
  "acorn-walk": "^8.2.0"
@@ -15468,9 +15468,9 @@
15468
15468
  }
15469
15469
  },
15470
15470
  "node_modules/webdriver/node_modules/@types/node": {
15471
- "version": "18.11.11",
15472
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
15473
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
15471
+ "version": "18.11.15",
15472
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
15473
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
15474
15474
  },
15475
15475
  "node_modules/webdriverio": {
15476
15476
  "version": "7.24.0",
@@ -15510,9 +15510,9 @@
15510
15510
  }
15511
15511
  },
15512
15512
  "node_modules/webdriverio/node_modules/@types/node": {
15513
- "version": "18.11.11",
15514
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
15515
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
15513
+ "version": "18.11.15",
15514
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
15515
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
15516
15516
  },
15517
15517
  "node_modules/webdriverio/node_modules/brace-expansion": {
15518
15518
  "version": "2.0.1",
@@ -17129,9 +17129,9 @@
17129
17129
  },
17130
17130
  "dependencies": {
17131
17131
  "@types/node": {
17132
- "version": "18.11.11",
17133
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
17134
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
17132
+ "version": "18.11.15",
17133
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
17134
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
17135
17135
  }
17136
17136
  }
17137
17137
  },
@@ -19496,9 +19496,9 @@
19496
19496
  },
19497
19497
  "dependencies": {
19498
19498
  "@types/node": {
19499
- "version": "18.11.11",
19500
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
19501
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
19499
+ "version": "18.11.15",
19500
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
19501
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
19502
19502
  },
19503
19503
  "ua-parser-js": {
19504
19504
  "version": "1.0.32",
@@ -20937,9 +20937,9 @@
20937
20937
  }
20938
20938
  },
20939
20939
  "got": {
20940
- "version": "11.8.5",
20941
- "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz",
20942
- "integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==",
20940
+ "version": "11.8.6",
20941
+ "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
20942
+ "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==",
20943
20943
  "requires": {
20944
20944
  "@sindresorhus/is": "^4.0.0",
20945
20945
  "@szmarczak/http-timer": "^4.0.5",
@@ -27933,9 +27933,9 @@
27933
27933
  }
27934
27934
  },
27935
27935
  "vm2": {
27936
- "version": "3.9.12",
27937
- "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.12.tgz",
27938
- "integrity": "sha512-OMmRsKh1gmdosFzuqmj6O43hqIStqXA24YbwjtUTO0TkOBP8yLNHLplbr4odnAzEcMnm9lt2r3R8kTivn8urMg==",
27936
+ "version": "3.9.13",
27937
+ "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.13.tgz",
27938
+ "integrity": "sha512-0rvxpB8P8Shm4wX2EKOiMp7H2zq+HUE/UwodY0pCZXs9IffIKZq6vUti5OgkVCTakKo9e/fgO4X1fkwfjWxE3Q==",
27939
27939
  "requires": {
27940
27940
  "acorn": "^8.7.0",
27941
27941
  "acorn-walk": "^8.2.0"
@@ -27994,9 +27994,9 @@
27994
27994
  },
27995
27995
  "dependencies": {
27996
27996
  "@types/node": {
27997
- "version": "18.11.11",
27998
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
27999
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
27997
+ "version": "18.11.15",
27998
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
27999
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
28000
28000
  }
28001
28001
  }
28002
28002
  },
@@ -28035,9 +28035,9 @@
28035
28035
  },
28036
28036
  "dependencies": {
28037
28037
  "@types/node": {
28038
- "version": "18.11.11",
28039
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
28040
- "integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g=="
28038
+ "version": "18.11.15",
28039
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.15.tgz",
28040
+ "integrity": "sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw=="
28041
28041
  },
28042
28042
  "brace-expansion": {
28043
28043
  "version": "2.0.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.267.0",
3
+ "version": "3.269.0",
4
4
  "description": "Command line interface for running Testing on your CI",
5
5
  "author": "Oren Rubin",
6
6
  "contributors": [{
@@ -1,6 +1,6 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- const Promise = require('bluebird');
3
+ const utils = require('../utils');
4
4
  const WebDriver = require('./webdriver');
5
5
 
6
6
  class ExtensionTestPlayer {
@@ -11,10 +11,12 @@ class ExtensionTestPlayer {
11
11
 
12
12
  onDone() {
13
13
  const END_DRIVER_TIMEOUT = 1000 * 60 * 2;
14
- return this.driver.end()
15
- .timeout(END_DRIVER_TIMEOUT)
16
- .catch(Promise.TimeoutError, () => {
17
- return this.driver.forceEnd();
14
+ return utils.promiseTimeout(this.driver.end(), END_DRIVER_TIMEOUT)
15
+ .catch((error) => {
16
+ if (error instanceof utils.TimeoutError) {
17
+ return this.driver.forceEnd();
18
+ }
19
+ throw error;
18
20
  })
19
21
  .catch(() => {})
20
22
  .then(() => {
@@ -22,6 +22,7 @@ const WebDriver = require('./webdriver');
22
22
  // delete after https://github.com/testimio/clickim/pull/3430 release to the store
23
23
  const CryptoJS = require('crypto-js');
24
24
  const StepActionUtils = require('./utils/stepActionUtils');
25
+ const utils = require('../utils');
25
26
 
26
27
  class SeleniumTestPlayer {
27
28
  //eslint-disable-next-line default-param-last
@@ -83,7 +84,7 @@ class SeleniumTestPlayer {
83
84
  }
84
85
 
85
86
  onStepCompleted(result, testId, resultId, step) {
86
- if (step && step.isTabOpener) {
87
+ if (step?.isTabOpener) {
87
88
  this.tabService.addNewPopup(this.id, step.id)
88
89
  .catch(() => { });
89
90
  }
@@ -91,10 +92,13 @@ class SeleniumTestPlayer {
91
92
 
92
93
  onDone() {
93
94
  const END_DRIVER_TIMEOUT = 1000 * 60 * 2;
94
- return this.driver.end()
95
- .timeout(END_DRIVER_TIMEOUT)
96
- .catch(Promise.TimeoutError, () => this.driver.forceEnd())
97
- .catch(() => { })
95
+ return utils.promiseTimeout(this.driver.end(), END_DRIVER_TIMEOUT)
96
+ .catch(error => {
97
+ if (error instanceof utils.TimeoutError) {
98
+ return this.driver.forceEnd().catch(() => null);
99
+ }
100
+ return undefined;
101
+ })
98
102
  .then(() => {
99
103
  this.sessionPlayer.playbackManager.off(commonConstants.playback.RESULT, this.onStepCompleted);
100
104
  this.sessionPlayer = null;
@@ -108,10 +112,11 @@ class SeleniumTestPlayer {
108
112
  this.tabService.clearAllTabs(this.id);
109
113
  }
110
114
 
111
- addTab(openerStepId, options = { loadInfo: true }) {
112
- return this.driver.getTabIds()
113
- .tap(ids => this.tabService.addNewTab(this.id, ids[ids.length - 1], openerStepId, options))
114
- .then(ids => this.sessionPlayer.addPlaybackFrameHandler(ids[ids.length - 1], undefined, { emptyPage: true }));
115
+ async addTab(openerStepId, options = { loadInfo: true }) {
116
+ const ids = await this.driver.getTabIds();
117
+ const lastId = ids.at(-1);
118
+ await this.tabService.addNewTab(this.id, lastId, openerStepId, options);
119
+ return this.sessionPlayer.addPlaybackFrameHandler(lastId, undefined, { emptyPage: true });
115
120
  }
116
121
 
117
122
  async addAllTabs(openerStepId, options = { loadInfo: true, checkForMainTab: true, takeScreenshots: true }, blackList = []) {
@@ -132,8 +137,8 @@ class SeleniumTestPlayer {
132
137
  // if we only have one tab because we removed the editor tab - we have to switchTab to one of the other tabs, otherwise
133
138
  // tabService will assume it's on a good context but it's not.
134
139
  const tabInfo = this.tabService.getMainTabInfo(this.id);
135
- const utils = this.tabService.getTabUtils(this.id, tabInfo);
136
- await this.tabService.switchTab(utils.tabId, this.id, { forceSwitch: true });
140
+ const tabUtils = this.tabService.getTabUtils(this.id, tabInfo);
141
+ await this.tabService.switchTab(tabUtils.tabId, this.id, { forceSwitch: true });
137
142
  }
138
143
  // deal with checkForMainTab failing due to the page refreshing or JavaScript not responding or a similar issue
139
144
  this.tabService.fixMissingMainTab(this.id);
@@ -12,6 +12,7 @@ const guid = require('../../utils').guid;
12
12
 
13
13
  const UrlUtils = sessionPlayer.urlUtils;
14
14
  const semver = require('semver');
15
+ const utils = require('../../utils');
15
16
 
16
17
  const constants = sessionPlayer.commonConstants.stepResult;
17
18
  const tabMatcher = sessionPlayer.tabMatcher;
@@ -156,55 +157,49 @@ class TabService {
156
157
  Object.values(this.getAllTabInfos(sessionId))[0].isMain = true;
157
158
  }
158
159
 
159
- buildTabInfo(sessionId, tabId, order, openerStepId, options = {}) {
160
- return this.getTabDetails(tabId, sessionId, options)
161
- .then(tab => {
162
- const infoId = guid();
163
-
164
- function isMainTab(tabService) {
165
- if (options.checkForMainTab) {
166
- return tab.isMainTab;
167
- }
168
-
169
- if (!tab.isMainTab || tab.isMainTab === 'unknown') {
170
- const missingMainTab = !tabService.getMainTabInfo(sessionId);
171
- return missingMainTab;
172
- }
173
- return tab.isMainTab;
174
- }
175
- this.sessionTabs[sessionId].tabInfos[tabId] = {
176
- infoId,
177
- url: tab.url,
178
- title: tab.title,
179
- favIconUrl: tab.favIconUrl,
180
- order,
181
- from: this.getTabInfo(sessionId, tab.openerTabId),
182
- isMain: isMainTab(this),
183
- openerStepId,
184
- };
185
-
186
- return infoId;
187
- });
188
- }
160
+ async buildTabInfo(sessionId, tabId, order, openerStepId, options = {}) {
161
+ const tab = await this.getTabDetails(tabId, sessionId, options);
162
+ const infoId = guid();
163
+ function isMainTab(tabService) {
164
+ if (options.checkForMainTab) {
165
+ return tab.isMainTab;
166
+ }
189
167
 
190
- addTab(sessionId, id, order, openerStepId, options = {}) {
191
- return this.buildTabInfo(sessionId, id, order, openerStepId, options)
192
- .then(infoId => {
193
- const _windowUtils = new WindowUtils(id, this.driver);
194
- this._utils[infoId] = {
195
- attachDebugger: () => Promise.resolve(),
196
- detachDebugger: () => Promise.resolve(),
197
- onDebuggerDetached: () => {},
198
- tabId: id,
199
- domUtils: { getDOM: () => Promise.resolve() },
200
- windowUtils: _windowUtils,
201
- imageCaptureUtils: new ImageCaptureUtils(
202
- id,
203
- _windowUtils,
204
- new ScreenshotUtils(id, this.driver, { takeScreenshots: options.takeScreenshots })
205
- ),
206
- };
207
- });
168
+ if (!tab.isMainTab || tab.isMainTab === 'unknown') {
169
+ const missingMainTab = !tabService.getMainTabInfo(sessionId);
170
+ return missingMainTab;
171
+ }
172
+ return tab.isMainTab;
173
+ }
174
+ this.sessionTabs[sessionId].tabInfos[tabId] = {
175
+ infoId,
176
+ url: tab.url,
177
+ title: tab.title,
178
+ favIconUrl: tab.favIconUrl,
179
+ order,
180
+ from: this.getTabInfo(sessionId, tab.openerTabId),
181
+ isMain: isMainTab(this),
182
+ openerStepId,
183
+ };
184
+ return infoId;
185
+ }
186
+
187
+ async addTab(sessionId, id, order, openerStepId, options = {}) {
188
+ const infoId = await this.buildTabInfo(sessionId, id, order, openerStepId, options);
189
+ const _windowUtils = new WindowUtils(id, this.driver);
190
+ this._utils[infoId] = {
191
+ attachDebugger: () => Promise.resolve(),
192
+ detachDebugger: () => Promise.resolve(),
193
+ onDebuggerDetached: () => {},
194
+ tabId: id,
195
+ domUtils: { getDOM: () => Promise.resolve() },
196
+ windowUtils: _windowUtils,
197
+ imageCaptureUtils: new ImageCaptureUtils(
198
+ id,
199
+ _windowUtils,
200
+ new ScreenshotUtils(id, this.driver, { takeScreenshots: options.takeScreenshots })
201
+ ),
202
+ };
208
203
  }
209
204
 
210
205
  getTabUtilsByTabIdAndSessionId(sessionId, tabId) {
@@ -295,20 +290,20 @@ class TabService {
295
290
  }
296
291
 
297
292
  const infos = this.getAllTabInfos(sessionId);
298
- const alltopFrameUrls = Object.keys(infos)
293
+ const allTopFrameUrls = Object.keys(infos)
299
294
  .map(tabId => infos[tabId].url);
300
295
 
301
- if (this.exactUrlMatch(first, second, alltopFrameUrls)) {
296
+ if (this.exactUrlMatch(first, second, allTopFrameUrls)) {
302
297
  return true;
303
298
  }
304
299
 
305
300
  const combineDomainAndPath = urlParts => (`${urlParts.domain}/${urlParts.path.join('/')}`);
306
- if (this.singleExactMatchForParts(first, second, alltopFrameUrls, combineDomainAndPath)) {
301
+ if (this.singleExactMatchForParts(first, second, allTopFrameUrls, combineDomainAndPath)) {
307
302
  return true;
308
303
  }
309
304
 
310
305
  const combineDomainPathAndHash = urlParts => (`${urlParts.domain}/${urlParts.path.join('/')}#${urlParts.hash}`);
311
- if (this.singleExactMatchForParts(first, second, alltopFrameUrls, combineDomainPathAndHash)) {
306
+ if (this.singleExactMatchForParts(first, second, allTopFrameUrls, combineDomainPathAndHash)) {
312
307
  return true;
313
308
  }
314
309
 
@@ -409,32 +404,32 @@ class TabService {
409
404
  });
410
405
  }
411
406
 
412
- getUnregisteredTabId(sessionId) {
413
- return this.driver.getTabIds()
414
- .then(ids => ids.find(tabId => !this.getAllTabIds(sessionId).includes(tabId)));
407
+ async getUnregisteredTabId(sessionId) {
408
+ const ids = await this.driver.getTabIds();
409
+ return ids.find(tabId => !this.getAllTabIds(sessionId).includes(tabId));
415
410
  }
416
411
 
417
- waitForTabToOpen(sessionId) {
418
- return this.getUnregisteredTabId(sessionId)
419
- .then(newId => (newId ?
420
- Promise.resolve(newId) :
421
- Promise.delay(500).then(() => this.waitForTabToOpen(sessionId))));
412
+ async waitForTabToOpen(sessionId) {
413
+ const newId = await this.getUnregisteredTabId(sessionId);
414
+ if (newId) {
415
+ return newId;
416
+ }
417
+ await utils.delay(500);
418
+ return await this.waitForTabToOpen(sessionId);
422
419
  }
423
420
 
424
- tryToAddTab(sessionId, openerStepId) {
421
+ async tryToAddTab(sessionId, openerStepId) {
425
422
  if (this.pendingTabs[sessionId]) {
426
423
  // don't mess with the main flow
427
- return Promise.resolve();
424
+ return;
428
425
  }
429
- return this.getUnregisteredTabId(sessionId)
430
- .then(newId => {
431
- if (!newId) {
432
- return Promise.resolve();
433
- }
434
- return this.addNewTab(sessionId, newId)
435
- .then(() => this.addFrameHandler(newId))
436
- .then(() => (this.sessionTabs[sessionId].currentTab = null));
437
- });
426
+ const newId = await this.getUnregisteredTabId(sessionId);
427
+ if (!newId) {
428
+ return;
429
+ }
430
+ await this.addNewTab(sessionId, newId);
431
+ await this.addFrameHandler(newId);
432
+ this.sessionTabs[sessionId].currentTab = null;
438
433
  }
439
434
 
440
435
  addNewPopup(id, openerStepId) {
@@ -507,7 +502,7 @@ class TabService {
507
502
  errorType: constants.INVALID_TEST_VERSION,
508
503
  });
509
504
  }
510
- const openerStepId = (step.tabInfo || {}).openerStepId;
505
+ const openerStepId = step.tabInfo?.openerStepId;
511
506
  return this.waitToPendingTabs(sessionId, openerStepId)
512
507
  .then(() => {
513
508
  let tabId;
@@ -529,10 +524,10 @@ class TabService {
529
524
 
530
525
  if (!tabId) {
531
526
  return this.tryToAddTab(sessionId, openerStepId)
532
- .then(() => Promise.reject(new Error('No tab ID found')));
527
+ .then(() => { throw new Error('No tab ID found'); });
533
528
  }
534
529
  if (this.sessionTabs[sessionId].currentTab === tabId) {
535
- return Promise.resolve(tabId);
530
+ return tabId;
536
531
  }
537
532
  return this.switchTab(tabId, sessionId)
538
533
  .then(() => {
@@ -541,7 +536,7 @@ class TabService {
541
536
  })
542
537
  .catch(err => {
543
538
  const windowClosedErrors = ['no such window', 'no window found', 'the window could not be found'];
544
- if (err.message && windowClosedErrors.find(errorString => err.message.toLowerCase().includes(errorString))) {
539
+ if (err.message && windowClosedErrors.some(errorString => err.message.toLowerCase().includes(errorString))) {
545
540
  this.sessionTabs[sessionId].tabCount--;
546
541
  this.sessionTabs[sessionId].tabInfos[tabId].isClosed = true;
547
542
  return this.getTabIdByTabInfo(sessionId, step);
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const _ = require('lodash');
3
4
  const BaseJsStepAction = require('./baseJsStepAction');
4
- const Bluebird = require('bluebird');
5
5
  const service = require('../../agent/routers/cliJsCode/service');
6
6
  const sessionPlayer = require('../../commons/getSessionPlayerRequire');
7
- const _ = require('lodash');
7
+ const utils = require('../../utils');
8
8
 
9
9
  const constants = sessionPlayer.commonConstants.stepResult;
10
10
 
@@ -36,7 +36,7 @@ class BaseCliJsStepAction extends BaseJsStepAction {
36
36
  try {
37
37
  return await this.executeCliCode();
38
38
  } catch (err) {
39
- if (err instanceof Bluebird.TimeoutError) {
39
+ if (err instanceof utils.TimeoutError) {
40
40
  return {
41
41
  success: false,
42
42
  errorType: constants.ACTION_TIMEOUT,
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const StepAction = require('./stepAction');
4
- const Bluebird = require('bluebird');
5
4
  const { NpmPackageError } = require('../../errors');
6
5
 
7
6
  const service = require('../../agent/routers/cliJsCode/service');
7
+ const utils = require('../../utils');
8
8
 
9
9
  class NodePackageStepAction extends StepAction {
10
10
  async performAction() {
@@ -29,7 +29,7 @@ class NodePackageStepAction extends StepAction {
29
29
  message: err.message,
30
30
  };
31
31
  }
32
- if (err instanceof Bluebird.TimeoutError) {
32
+ if (err instanceof utils.TimeoutError) {
33
33
  return {
34
34
  success: false,
35
35
  code: 'timeout',
@@ -6,6 +6,7 @@ const Promise = require('bluebird');
6
6
  const pRetry = require('p-retry');
7
7
  const { delay } = require('../../utils');
8
8
  const { PageNotAvailableError } = require('../../errors');
9
+ const utils = require('../../utils');
9
10
  const logger = require('../../commons/logger').getLogger('window-utils');
10
11
 
11
12
  class WindowUtils {
@@ -18,6 +19,7 @@ class WindowUtils {
18
19
  this.driver = driver;
19
20
  }
20
21
 
22
+ // Seems unused and not working since bad args to executeJS
21
23
  getElementFromPoint(x, y) {
22
24
  /* eslint-disable */
23
25
  function elementFromPoint(x, y) {
@@ -47,7 +49,7 @@ class WindowUtils {
47
49
 
48
50
  scrollToPositionWithoutAnimation(pos) {
49
51
  /* eslint-disable */
50
- // if scroll behaviour is not supported, then the scrolling is not animated anyway
52
+ // if scroll behavior is not supported, then the scrolling is not animated anyway
51
53
  function scrollWithoutAnimation(position) {
52
54
  var scrollBehaviorSupported = 'scrollBehavior' in document.documentElement.style;
53
55
  if (scrollBehaviorSupported) {
@@ -126,15 +128,13 @@ class WindowUtils {
126
128
  return Promise.resolve();
127
129
  }
128
130
 
129
- checkSize(size) {
130
- return Promise.delay(1000)
131
- .then(() => this.getViewportSize())
132
- .then(actualSize => {
133
- if (actualSize.width !== size.width || actualSize.height !== size.height) {
134
- return Promise.reject({ actualSize, expectedSize: size });
135
- }
136
- return { actualSize, expectedSize: size };
137
- });
131
+ async checkSize(size) {
132
+ await utils.delay(1000);
133
+ const actualSize = await this.getViewportSize();
134
+ if (actualSize.width !== size.width || actualSize.height !== size.height) {
135
+ return Promise.reject({ actualSize, expectedSize: size });
136
+ }
137
+ return { actualSize, expectedSize: size };
138
138
  }
139
139
 
140
140
  async setViewportSize(size) {
@@ -155,12 +155,19 @@ class WindowUtils {
155
155
  return false;
156
156
  }
157
157
 
158
- return locationObj.href !== 'chrome-error://chromewebdata/' && locationObj.href !== 'safari-resource:/ErrorPage.html' && locationObj.href.indexOf('res://ieframe.dll/http_404.htm') !== 0 && locationObj.href.indexOf('ms-appx-web://microsoft.microsoftedge/assets/errorpages/') !== 0;
158
+ return (
159
+ locationObj.href !== 'chrome-error://chromewebdata/' &&
160
+ locationObj.href !== 'safari-resource:/ErrorPage.html' &&
161
+ locationObj.href.indexOf('res://ieframe.dll/http_404.htm') !== 0 &&
162
+ locationObj.href.indexOf('ms-appx-web://microsoft.microsoftedge/assets/errorpages/') !== 0
163
+ );
159
164
  }
160
165
  /* eslint-enable */
161
166
 
162
167
  const result = await this.driver.executeJS(pageIsAvailable);
163
- return await (result.value ? Promise.resolve() : Promise.reject(new PageNotAvailableError()));
168
+ if (!result.value) {
169
+ throw new PageNotAvailableError('validatePageIsAvailable:PageNotAvailableError');
170
+ }
164
171
  }
165
172
 
166
173
  focusTab() {
@@ -8,6 +8,8 @@ const featureAvailabilityService = require('../commons/featureAvailabilityServic
8
8
  const { getAbortedTests, getFailedTests, getPassedTests, getFailureEvaluatingCount, getSkippedCount } = require('./reporterUtils');
9
9
 
10
10
  const colorize = { success: chalk.green, warn: chalk.yellow, error: chalk.red };
11
+ const { CLI_MODE } = constants;
12
+ const DEVICE = 'device';
11
13
 
12
14
  class ConsoleReporter {
13
15
  constructor(options, branchToUse) {
@@ -143,13 +145,15 @@ class ConsoleReporter {
143
145
 
144
146
  onGetSlot(workerId, browser) {
145
147
  const gridNameOrId = this.options.grid || this.options.gridId;
148
+ const instanceType = this.options.mode === CLI_MODE.APPIUM ? DEVICE : browser;
146
149
  if (gridNameOrId) {
147
- console.log(this.toWorkerIdPrefix(workerId), `Get ${chalk.underline(browser)} slot from ${chalk.underline(gridNameOrId)}`);
150
+ console.log(this.toWorkerIdPrefix(workerId), `Get ${chalk.underline(instanceType)} slot from ${chalk.underline(gridNameOrId)}`);
148
151
  }
149
152
  }
150
153
 
151
154
  onGetSession(workerId, testName, mode) {
152
- console.log(this.toWorkerIdPrefix(workerId), `Get browser to run ${chalk.underline(testName)}`);
155
+ const instanceType = mode === CLI_MODE.APPIUM ? DEVICE : 'browser';
156
+ console.log(this.toWorkerIdPrefix(workerId), `Get ${instanceType} to run ${chalk.underline(testName)}`);
153
157
  }
154
158
 
155
159
  onWaitToTestStart(workerId) {
package/runOptions.d.ts CHANGED
@@ -109,9 +109,10 @@ interface RunnerOptions extends Partial<Omit<TunnelOptions, 'tunnelOnlyMode' | '
109
109
  retries?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
110
110
 
111
111
  //# region mobile flags
112
- deviceModel: string;
113
- deviceUdid: string;
114
- osVersion: string;
112
+ deviceModel?: string;
113
+ deviceUdid?: string;
114
+ osVersion?: string;
115
+ appId?: string;
115
116
  // #endregion
116
117
 
117
118