@testim/testim-cli 3.247.0 → 3.250.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testim/testim-cli",
3
- "version": "3.247.0",
3
+ "version": "3.250.0",
4
4
  "description": "Command line interface for running Testing on your CI",
5
5
  "author": "Oren Rubin",
6
6
  "contributors": [{
@@ -17,15 +17,11 @@
17
17
  "@types/node": "10.17.24",
18
18
  "@types/selenium-webdriver": "4.0.9",
19
19
  "bundle-deps": "1.0.0",
20
- "chai": "4.3.6",
21
- "chai-as-promised": "7.1.1",
22
20
  "gulp": "4.0.2",
23
21
  "gulp-cli": "2.3.0",
24
22
  "gulp-json-editor": "2.5.6",
25
23
  "gulp-preprocess": "3.0.3",
26
24
  "merge-stream": "2.0.0",
27
- "mocha": "9.2.0",
28
- "nyc": "15.1.0",
29
25
  "proxyquire": "2.1.3",
30
26
  "request": "2.88.2",
31
27
  "sinon": "9.0.2",
@@ -4,7 +4,21 @@ const _ = require('lodash');
4
4
 
5
5
  const COMMUNICATION_BUFFER_TIME = 1000;
6
6
  const UI_VERIFICATION_STEPS = ['simple-ui-verification', 'wait-for-simple-ui-verification'];
7
- const FULL_TIMEOUT_STEP_TYPES = [...UI_VERIFICATION_STEPS, 'custom-validation', 'sfdc-step-login'];
7
+ const FULL_TIMEOUT_STEP_TYPES = [
8
+ ...UI_VERIFICATION_STEPS,
9
+ 'custom-validation',
10
+ 'sfdc-recorded-step',
11
+ 'sfdc-step-login',
12
+ 'sfdc-step-logout',
13
+ 'sfdc-step-sobjectcreate',
14
+ 'sfdc-step-sobjectdelete',
15
+ 'sfdc-step-findrecord',
16
+ 'sfdc-step-quickaction',
17
+ 'sfdc-step-sobjectvalidate',
18
+ 'sfdc-step-launchapp',
19
+ 'sfdc-step-closeconsoletabs',
20
+ 'sfdc-step-sobjectedit',
21
+ ];
8
22
 
9
23
  class PlaybackTimeoutCalculator {
10
24
  constructor(isDebuggerConnected) {
@@ -37,9 +37,11 @@ class ApiStepAction extends StepAction {
37
37
  body: context.apiBody,
38
38
  timeout: context.data.maxTotalStepTime,
39
39
  omitCookies: step.omitCookies,
40
+ formData: step.formData,
41
+ fileUrls: context.fileUrls,
40
42
  };
41
43
 
42
- return (step.sendViaWebApp ? this.runApiInAut(step, context) : this.runApiInBg(eventData))
44
+ return (step.sendViaWebApp ? this.runApiInAut(eventData) : this.runApiInBg(eventData))
43
45
  .then(resp => {
44
46
  const result = resp.result || {};
45
47
 
@@ -51,31 +53,31 @@ class ApiStepAction extends StepAction {
51
53
 
52
54
  if (resp.success) {
53
55
  if (result.status === 0) {
54
- return Promise.resolve({
56
+ return {
55
57
  result,
56
58
  resultInfo,
57
59
  shouldRetry: false,
58
60
  success: false,
59
61
  reason: 'Connection problem',
60
62
  errorType: constants.API_REQUEST_NETWORK_ERROR,
61
- });
63
+ };
62
64
  }
63
- return Promise.resolve({
65
+ return {
64
66
  result,
65
67
  resultInfo,
66
68
  shouldRetry: false,
67
69
  success: true,
68
- });
70
+ };
69
71
  }
70
72
 
71
- return Promise.resolve({
73
+ return {
72
74
  result,
73
75
  resultInfo,
74
76
  shouldRetry: false,
75
77
  success: false,
76
78
  reason: result.error || sessionPlayer.commonConstants.error.REQUEST_TIMED_OUT,
77
79
  errorType: result.error ? constants.API_FAILURE : constants.API_REQUEST_NETWORK_ERROR,
78
- });
80
+ };
79
81
  });
80
82
  }
81
83
  }
@@ -1,13 +1,18 @@
1
+ /* eslint-disable no-restricted-syntax */ // This code only runs in Safari, not in IE.
1
2
  module.exports = function (locatedElement, dispatchEventOnSelectElement) {
2
3
  function closest(el, selectors) {
4
+ var originalMatches = Element.prototype.matches;
5
+ /* eslint-disable-next-line no-proto, no-undef */ // Some customers override the native Element prototype, so we need to create a new one if they messed it up.
6
+ var matches = originalMatches && isNativeFunction(originalMatches) ? originalMatches : document.createElement(el.tagName).__proto__.matches;
3
7
  do {
4
- if (Element.prototype.matches.call(el, selectors)) return el;
8
+ if (matches.call(el, selectors)) return el;
5
9
  el = el.parentElement || el.parentNode;
6
10
  } while (el !== null && el.nodeType === 1);
7
11
  return null;
8
12
  }
9
13
 
10
14
  try {
15
+ /* eslint-disable-next-line no-undef */ // This code depends on pre-injecting this function as well.
11
16
  var optionEl = getLocatedElement(locatedElement);
12
17
  if (!optionEl) {
13
18
  return { success: false, status: 'failed', result: 'option element not found' };
@@ -2,42 +2,48 @@
2
2
 
3
3
  const StepAction = require('./stepAction');
4
4
  const { extractElementId } = require('../../utils');
5
- const { codeSnippets } = require('../../commons/getSessionPlayerRequire');
5
+ const { codeSnippets, utils } = require('../../commons/getSessionPlayerRequire');
6
6
  const selectOption = require('./scripts/selectOption');
7
7
  const featureFlags = require('../../commons/featureFlags');
8
8
 
9
9
  class SelectOptionStepAction extends StepAction {
10
- performAction() {
10
+ async performAction() {
11
11
  const target = this.context.data[this.step.targetId || 'targetId'];
12
12
  const { seleniumElement, locatedElement } = target;
13
13
 
14
- return this.driver.getBrowserAndOS()
15
- .then(browserAndOS => {
16
- const browserMajor = browserAndOS.browserMajor;
17
- const isSafari = this.driver.isSafari();
18
- const isShadowed = Boolean(this.step.element && this.step.element.isShadowed);
14
+ const browserAndOS = await this.driver.getBrowserAndOS();
19
15
 
20
- // TODO: Remove the special handling for safari < 12 after we upgrade our grid to safari 13.
21
- // force use js code when element is shadow dom
22
- if (!isSafari || (isSafari && browserMajor >= 13 && !isShadowed)) {
23
- return this.driver.elementIdClick(extractElementId(seleniumElement));
16
+ const browserMajor = browserAndOS.browserMajor;
17
+ const isSafari = this.driver.isSafari();
18
+ const isShadowed = Boolean(this.step.element && this.step.element.isShadowed);
19
+
20
+ // TODO: Remove the special handling for safari < 12 after we upgrade our grid to safari 13.
21
+ // force use js code when element is shadow dom
22
+ if (!isSafari || (isSafari && browserMajor >= 13 && !isShadowed)) {
23
+ try {
24
+ const res = await this.driver.elementIdClick(extractElementId(seleniumElement));
25
+ return res;
26
+ } catch (err) {
27
+ // If customer overrides the native Element prototype, this click will fail for this reason. in such a case, fallback to use js code.
28
+ if (!err.message.includes('Cannot check the displayedness of a non-Element argument')) {
29
+ throw err;
24
30
  }
31
+ }
32
+ }
33
+
34
+ const safariSelectOptionDispatchEventOnSelectElement = featureFlags.flags.safariSelectOptionDispatchEventOnSelectElement.isEnabled();
35
+ const selectOptionCode = `
36
+ var getLocatedElement = ${codeSnippets.getLocatedElementCode};
37
+ var isNativeFunction = ${utils.isNativeFunction.toString()};
38
+ var selectOption = ${selectOption.toString()};
39
+ return selectOption.apply(null, arguments);
40
+ `;
25
41
 
26
- const safariSelectOptionDispatchEventOnSelectElement = featureFlags.flags.safariSelectOptionDispatchEventOnSelectElement.isEnabled();
27
- const selectOptionCode = `
28
- var getLocatedElement = ${codeSnippets.getLocatedElementCode};
29
- var selectOption = ${selectOption.toString()};
30
- return selectOption.apply(null, arguments);
31
- `;
32
-
33
- return this.driver.executeJSWithArray(selectOptionCode, [locatedElement, safariSelectOptionDispatchEventOnSelectElement])
34
- .then(result => {
35
- if (result.value && result.value.success) {
36
- return { success: true };
37
- }
38
- return { success: false };
39
- });
40
- });
42
+ const result = await this.driver.executeJSWithArray(selectOptionCode, [locatedElement, safariSelectOptionDispatchEventOnSelectElement]);
43
+ if (result.value && result.value.success) {
44
+ return { success: true };
45
+ }
46
+ return { success: false };
41
47
  }
42
48
  }
43
49
 
@@ -0,0 +1,23 @@
1
+ const StepAction = require('./stepAction');
2
+ const { sfdc } = require('../../commons/getSessionPlayerRequire');
3
+
4
+ class SfdcRecordedStepAction extends StepAction {
5
+ async performAction() {
6
+ const page = sfdc.sfdcNewSePage(this.driver);
7
+ try {
8
+ await sfdc.sfdcExecuteRecordedStep(page, this.step.recordedData);
9
+ return { success: true };
10
+ } catch (err) {
11
+ return {
12
+ success: false,
13
+ reason: err.reason || err.message,
14
+ exception: err,
15
+ shouldRetry: false, // TODO - check this. Our (bFormat) steps are probably not retryable?
16
+ };
17
+ } finally {
18
+ page.releaseObjects();
19
+ }
20
+ }
21
+ }
22
+
23
+ module.exports = SfdcRecordedStepAction;
@@ -28,6 +28,7 @@ const CliConditionStepAction = require('./cliConditionStepAction');
28
28
  const NodePackageStepAction = require('./nodePackageStepAction');
29
29
  const ExtensionOnlyStepAction = require('./extensionOnlyStepAction');
30
30
  const SfdcStepAction = require('./sfdcStepAction');
31
+ const SfdcRecordedStepAction = require('./sfdcRecordedStepAction');
31
32
 
32
33
  function register(stepActionByType, stepActionFactory) {
33
34
  Object.keys(stepActionByType).forEach(type => {
@@ -84,16 +85,18 @@ module.exports = function (driver, stepActionFactory, runMode) {
84
85
  'cli-email-code-step': CliJsStepAction,
85
86
  'tdk-hybrid': TdkHybridStepAction,
86
87
 
88
+ 'sfdc-recorded-step': SfdcRecordedStepAction,
87
89
  'sfdc-step-login': SfdcStepAction,
88
90
  'sfdc-step-logout': SfdcStepAction,
89
91
  'sfdc-step-sobjectcreate': SfdcStepAction,
90
92
  'sfdc-step-sobjectdelete': SfdcStepAction,
91
93
  'sfdc-step-findrecord': SfdcStepAction,
92
94
  'sfdc-step-quickaction': SfdcStepAction,
93
- 'sfdc-step-edit': SfdcStepAction,
95
+ 'sfdc-step-sobjectedit': SfdcStepAction,
94
96
  'sfdc-step-sobjectvalidate': SfdcStepAction,
95
97
  'sfdc-step-launchapp': SfdcStepAction,
96
98
  'sfdc-step-closeconsoletabs': SfdcStepAction,
99
+ 'sfdc-step-relatedlistaction': SfdcStepAction,
97
100
  };
98
101
 
99
102
  register(STEP_ACTION_MAPPING, stepActionFactory);
@@ -129,7 +129,7 @@ class BaseWorker {
129
129
  await utils.delay(this.options.getBrowserTimeout - (Date.now() - startTime));
130
130
  throw error;
131
131
  }
132
- }, { retries: this.options.getBrowserRetries - 1, minTimeout: 0 });
132
+ }, { retries: this.options.getBrowserRetries - 1, minTimeout: 0, factor: 1 });
133
133
  perf.log('after getSlotOnce retries');
134
134
 
135
135
  perf.log('before getBrowserOnce retries');
@@ -168,7 +168,7 @@ class BaseWorker {
168
168
  }
169
169
  throw error;
170
170
  }
171
- }, { retries: getBrowserRetriesNumber - 1, minTimeout: 0 });
171
+ }, { retries: getBrowserRetriesNumber - 1, minTimeout: 0, factor: 1 });
172
172
  perf.log('after getBrowserOnce retries');
173
173
  } catch (err) {
174
174
  await releasePlayer(this.id, this.releaseSlotOnTestFinished, projectId, testPlayer);
@@ -66,7 +66,7 @@ class WorkerSelenium extends BaseWorker {
66
66
  await this.windowUtils.validatePageIsAvailable();
67
67
  perf.log('in WorkerSelenium after navigate');
68
68
  } catch (err) {
69
- const firefoxPageNotAvailable = (err.message.startsWith('Malformed URL') || err.message.includes('Reached error page: about:neterror')) &&
69
+ const firefoxPageNotAvailable = err.message && (err.message.startsWith('Malformed URL') || err.message.includes('Reached error page: about:neterror')) &&
70
70
  browserValue === 'firefox';
71
71
 
72
72
  const invalidURL = (err.message && err.message === 'invalid argument');