@testim/testim-cli 3.289.0 → 3.290.1-beta

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 (217) hide show
  1. package/cli.js +22390 -122
  2. package/cli.js.map +1 -0
  3. package/npm-shrinkwrap.json +1169 -12846
  4. package/package.json +16 -10
  5. package/OverrideTestDataBuilder.js +0 -117
  6. package/agent/routers/cliJsCode/index.js +0 -13
  7. package/agent/routers/cliJsCode/router.js +0 -63
  8. package/agent/routers/cliJsCode/service.js +0 -705
  9. package/agent/routers/codim/router.js +0 -69
  10. package/agent/routers/codim/router.test.js +0 -60
  11. package/agent/routers/codim/service.js +0 -193
  12. package/agent/routers/general/index.js +0 -36
  13. package/agent/routers/hybrid/registerRoutes.js +0 -81
  14. package/agent/routers/index.js +0 -56
  15. package/agent/routers/playground/router.js +0 -77
  16. package/agent/routers/playground/service.js +0 -96
  17. package/agent/routers/standalone-browser/registerRoutes.js +0 -47
  18. package/agent/server.js +0 -150
  19. package/cdpTestRunner.js +0 -86
  20. package/chromiumInstaller.js +0 -91
  21. package/cli/isCiRun.js +0 -10
  22. package/cli/onExit.js +0 -65
  23. package/cli/writeStackTrace.js +0 -27
  24. package/cliAgentMode.js +0 -384
  25. package/codim/codim-cli.js +0 -91
  26. package/codim/codim-npm-package/index.ts +0 -427
  27. package/codim/codim-npm-package/package-lock.json +0 -14
  28. package/codim/codim-npm-package/package.json +0 -14
  29. package/codim/hybrid-utils.js +0 -28
  30. package/codim/measure-perf.js +0 -41
  31. package/codim/template.js/.idea/workspace.xml +0 -57
  32. package/codim/template.js/.vscode/launch.json +0 -53
  33. package/codim/template.ts/.idea/workspace.xml +0 -57
  34. package/codim/template.ts/.vscode/launch.json +0 -55
  35. package/commons/AbortError.js +0 -12
  36. package/commons/SeleniumPerfStats.js +0 -58
  37. package/commons/chrome-launcher.js +0 -15
  38. package/commons/chromedriverWrapper.js +0 -70
  39. package/commons/config.js +0 -39
  40. package/commons/constants.js +0 -67
  41. package/commons/detectDebugger.js +0 -19
  42. package/commons/featureAvailabilityService.js +0 -26
  43. package/commons/featureFlags.js +0 -132
  44. package/commons/getSessionPlayerRequire.js +0 -28
  45. package/commons/httpRequest.js +0 -261
  46. package/commons/httpRequestCounters.js +0 -98
  47. package/commons/httpRequestCounters.test.js +0 -38
  48. package/commons/initializeUserWithAuth.js +0 -55
  49. package/commons/lazyRequire.js +0 -105
  50. package/commons/logUtils.js +0 -15
  51. package/commons/logUtils.test.js +0 -21
  52. package/commons/logger.js +0 -178
  53. package/commons/mockNetworkRuleFileSchema.json +0 -140
  54. package/commons/npmWrapper.js +0 -174
  55. package/commons/npmWrapper.test.js +0 -374
  56. package/commons/performance-logger.js +0 -71
  57. package/commons/preloadTests.js +0 -29
  58. package/commons/prepareRunner.js +0 -85
  59. package/commons/prepareRunner.test.js +0 -144
  60. package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
  61. package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
  62. package/commons/requireWithFallback.js +0 -25
  63. package/commons/runnerFileCache.js +0 -204
  64. package/commons/socket/baseSocketServiceSocketIO.js +0 -197
  65. package/commons/socket/realDataService.js +0 -59
  66. package/commons/socket/realDataServiceSocketIO.js +0 -33
  67. package/commons/socket/remoteStepService.js +0 -55
  68. package/commons/socket/remoteStepServiceSocketIO.js +0 -61
  69. package/commons/socket/socketService.js +0 -175
  70. package/commons/socket/testResultService.js +0 -62
  71. package/commons/socket/testResultServiceSocketIO.js +0 -64
  72. package/commons/testimAnalytics.js +0 -40
  73. package/commons/testimCloudflare.js +0 -83
  74. package/commons/testimCloudflare.test.js +0 -185
  75. package/commons/testimCustomToken.js +0 -124
  76. package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
  77. package/commons/testimNgrok.js +0 -90
  78. package/commons/testimNgrok.test.js +0 -140
  79. package/commons/testimServicesApi.js +0 -631
  80. package/commons/testimTunnel.js +0 -73
  81. package/commons/testimTunnel.test.js +0 -172
  82. package/commons/xhr2.js +0 -897
  83. package/coverage/SummaryToObjectReport.js +0 -19
  84. package/coverage/jsCoverage.js +0 -252
  85. package/credentialsManager.js +0 -142
  86. package/errors.js +0 -161
  87. package/executionQueue.js +0 -37
  88. package/fixLocalBuild.js +0 -24
  89. package/inputFileUtils.js +0 -103
  90. package/lib/coralogix-winston.transport.js +0 -99
  91. package/player/SeleniumProtocolError.js +0 -100
  92. package/player/WebDriverHttpRequest.js +0 -177
  93. package/player/WebdriverioWebDriverApi.js +0 -671
  94. package/player/appiumTestPlayer.js +0 -90
  95. package/player/chromeLauncherTestPlayer.js +0 -67
  96. package/player/constants.js +0 -332
  97. package/player/extensionTestPlayer.js +0 -32
  98. package/player/findElementStrategy.js +0 -154
  99. package/player/scripts/isElementDisplayed.js +0 -252
  100. package/player/seleniumTestPlayer.js +0 -140
  101. package/player/services/frameLocator.js +0 -170
  102. package/player/services/mobileFrameLocatorMock.js +0 -32
  103. package/player/services/playbackTimeoutCalculator.js +0 -175
  104. package/player/services/portSelector.js +0 -19
  105. package/player/services/tabService.js +0 -551
  106. package/player/services/tabServiceMock.js +0 -167
  107. package/player/services/windowCreationListener.js +0 -8
  108. package/player/stepActions/RefreshStepAction.js +0 -16
  109. package/player/stepActions/apiStepAction.js +0 -89
  110. package/player/stepActions/baseCliJsStepAction.js +0 -51
  111. package/player/stepActions/baseJsStepAction.js +0 -277
  112. package/player/stepActions/cliConditionStepAction.js +0 -11
  113. package/player/stepActions/cliJsStepAction.js +0 -11
  114. package/player/stepActions/dropFileStepAction.js +0 -34
  115. package/player/stepActions/evaluateExpressionStepAction.js +0 -52
  116. package/player/stepActions/extensionOnlyStepAction.js +0 -12
  117. package/player/stepActions/extractTextStepAction.js +0 -19
  118. package/player/stepActions/hoverStepAction.js +0 -55
  119. package/player/stepActions/inputFileStepAction.js +0 -199
  120. package/player/stepActions/jsCodeStepAction.js +0 -11
  121. package/player/stepActions/jsConditionStepAction.js +0 -11
  122. package/player/stepActions/locateStepAction.js +0 -159
  123. package/player/stepActions/mouseStepAction.js +0 -370
  124. package/player/stepActions/navigationStepAction.js +0 -29
  125. package/player/stepActions/nodePackageStepAction.js +0 -47
  126. package/player/stepActions/pixelValidationStepAction.js +0 -39
  127. package/player/stepActions/scripts/dispatchEvents.js +0 -282
  128. package/player/stepActions/scripts/doClick.js +0 -221
  129. package/player/stepActions/scripts/doDragPath.js +0 -225
  130. package/player/stepActions/scripts/doubleClick.js +0 -119
  131. package/player/stepActions/scripts/dropEvent.js +0 -63
  132. package/player/stepActions/scripts/focusElement.js +0 -46
  133. package/player/stepActions/scripts/html5dragAction.js +0 -56
  134. package/player/stepActions/scripts/html5dragActionV2.js +0 -312
  135. package/player/stepActions/scripts/runCode.js +0 -147
  136. package/player/stepActions/scripts/scroll.js +0 -90
  137. package/player/stepActions/scripts/selectOption.js +0 -51
  138. package/player/stepActions/scripts/setText.js +0 -415
  139. package/player/stepActions/scripts/wheel.js +0 -61
  140. package/player/stepActions/scrollStepAction.js +0 -96
  141. package/player/stepActions/selectOptionStepAction.js +0 -49
  142. package/player/stepActions/sfdcRecordedStepAction.js +0 -24
  143. package/player/stepActions/sfdcStepAction.js +0 -28
  144. package/player/stepActions/sleepStepAction.js +0 -12
  145. package/player/stepActions/specialKeyStepAction.js +0 -52
  146. package/player/stepActions/stepAction.js +0 -73
  147. package/player/stepActions/stepActionRegistrar.js +0 -111
  148. package/player/stepActions/submitStepAction.js +0 -12
  149. package/player/stepActions/tdkHybridStepAction.js +0 -18
  150. package/player/stepActions/textStepAction.js +0 -110
  151. package/player/stepActions/textValidationStepAction.js +0 -64
  152. package/player/stepActions/wheelStepAction.js +0 -41
  153. package/player/utils/cookieUtils.js +0 -39
  154. package/player/utils/eyeSdkService.js +0 -250
  155. package/player/utils/imageCaptureUtils.js +0 -267
  156. package/player/utils/screenshotUtils.js +0 -68
  157. package/player/utils/stepActionUtils.js +0 -90
  158. package/player/utils/windowUtils.js +0 -195
  159. package/player/webDriverUtils.js +0 -40
  160. package/player/webDriverUtils.test.js +0 -116
  161. package/player/webdriver.js +0 -976
  162. package/polyfills/Array.prototype.at.js +0 -13
  163. package/polyfills/index.js +0 -13
  164. package/processHandler.js +0 -79
  165. package/processHandler.test.js +0 -55
  166. package/reports/chromeReporter.js +0 -17
  167. package/reports/consoleReporter.js +0 -190
  168. package/reports/debugReporter.js +0 -82
  169. package/reports/jsonReporter.js +0 -55
  170. package/reports/junitReporter.js +0 -183
  171. package/reports/reporter.js +0 -166
  172. package/reports/reporterUtils.js +0 -54
  173. package/reports/teamCityReporter.js +0 -73
  174. package/runOptions.d.ts +0 -305
  175. package/runOptions.js +0 -1288
  176. package/runOptionsAgentFlow.js +0 -87
  177. package/runOptionsUtils.js +0 -60
  178. package/runner.js +0 -355
  179. package/runners/ParallelWorkerManager.js +0 -284
  180. package/runners/TestPlanRunner.js +0 -419
  181. package/runners/buildCodeTests.js +0 -159
  182. package/runners/runnerUtils.js +0 -81
  183. package/services/analyticsService.js +0 -96
  184. package/services/branchService.js +0 -29
  185. package/services/gridService.js +0 -357
  186. package/services/gridService.test.js +0 -357
  187. package/services/labFeaturesService.js +0 -64
  188. package/services/lambdatestService.js +0 -227
  189. package/services/lambdatestService.test.js +0 -353
  190. package/services/localRCASaver.js +0 -124
  191. package/stepPlayers/cliJsStepPlayback.js +0 -40
  192. package/stepPlayers/hybridStepPlayback.js +0 -140
  193. package/stepPlayers/nodePackageStepPlayback.js +0 -28
  194. package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
  195. package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
  196. package/stepPlayers/remoteStepPlayback.js +0 -80
  197. package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
  198. package/stepPlayers/tdkHybridStepPlayback.js +0 -112
  199. package/testRunHandler.js +0 -603
  200. package/testRunStatus.js +0 -567
  201. package/testimNpmDriver.js +0 -52
  202. package/utils/argsUtils.js +0 -91
  203. package/utils/argsUtils.test.js +0 -32
  204. package/utils/fsUtils.js +0 -174
  205. package/utils/index.js +0 -197
  206. package/utils/promiseUtils.js +0 -85
  207. package/utils/stringUtils.js +0 -98
  208. package/utils/stringUtils.test.js +0 -22
  209. package/utils/timeUtils.js +0 -25
  210. package/utils/utils.test.js +0 -27
  211. package/workers/BaseWorker.js +0 -498
  212. package/workers/BaseWorker.test.js +0 -186
  213. package/workers/WorkerAppium.js +0 -180
  214. package/workers/WorkerExtension.js +0 -192
  215. package/workers/WorkerExtensionSingleBrowser.js +0 -77
  216. package/workers/WorkerSelenium.js +0 -253
  217. package/workers/workerUtils.js +0 -20
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- const { extractElementId } = require('../../utils');
4
- const StepAction = require('./stepAction');
5
-
6
- const keyMap = {
7
- 8: '\uE008', // (Backspace)
8
- 9: '\uE004', // (tab)
9
- 13: '\uE007', // (enter)
10
- 27: '\uE00C', // (esc)
11
- 33: '\uE00E', // (page up)
12
- 34: '\uE00F', // (page down)
13
- 35: '\uE010', // (end)
14
- 36: '\uE011', // (home)
15
- 45: '\uE016', // (insert)
16
- 112: '\uE031', // (f1)
17
- 113: '\uE032', // (f2)
18
- 114: '\uE033', // (f3)
19
- 115: '\uE034', // (f4)
20
- 116: '\uE035', // (f5)
21
- 117: '\uE036', // (f6)
22
- 118: '\uE037', // (f7)
23
- 119: '\uE038', // (f8)
24
- 120: '\uE039', // (f9)
25
- 121: '\uE03A', // (f10)
26
- 122: '\uE03B', // (f11)
27
- 123: '\uE03C', // (f12)
28
- };
29
-
30
- class SpecialKeyStepAction extends StepAction {
31
- setWithValueApi(keys) {
32
- const target = this.getTarget();
33
- if (target?.seleniumElement) {
34
- return this.driver.elementIdValue(extractElementId(target.seleniumElement), keys);
35
- }
36
- return Promise.reject(new Error('missing selenium element'));
37
- }
38
-
39
- performAction() {
40
- const keys = [];
41
- const keyCode = this.step.events[0].eventData.keyCode;
42
-
43
- if (keyCode >= 32 && keyCode <= 127) {
44
- keys.push(String.fromCharCode(keyCode));
45
- } else {
46
- keys.push(keyMap[keyCode]);
47
- }
48
- return this.setWithValueApi(keys);
49
- }
50
- }
51
-
52
- module.exports = SpecialKeyStepAction;
@@ -1,73 +0,0 @@
1
- 'use strict';
2
-
3
- const { getSessionPlayer } = require('../../commons/getSessionPlayerRequire');
4
-
5
- /** @typedef {typeof import('clickim/src/background/stepActions/stepAction').StepAction} ClickimStepActionCtor */
6
- /** @typedef {ConstructorParameters<ClickimStepActionCtor>} ClickimStepActionCtorParams */
7
- /** @typedef {InstanceType<ClickimStepActionCtor>} ClickimStepAction */
8
-
9
- class StepAction {
10
- /** @type {(...args: ClickimStepActionCtorParams) => this} */
11
- constructor(
12
- step,
13
- context,
14
- frameHandler,
15
- exportsGlobal = {},
16
- stepActionUtils = undefined,
17
- locateElementPlayer = undefined,
18
- exportsTest = {},
19
- ) {
20
- this.step = step;
21
- this.context = context;
22
- this.frameHandler = frameHandler;
23
- this.frameId = 0;
24
- /** @type {import('../utils/stepActionUtils'))} */
25
- this.stepActionUtils = stepActionUtils;
26
- this.locateElementPlayer = locateElementPlayer;
27
- this.exportsGlobal = exportsGlobal;
28
- this.exportsTest = exportsTest;
29
- }
30
-
31
- get driver() {
32
- return this.stepActionUtils.driver;
33
- }
34
-
35
- /** @protected */
36
- get sessionPlayerInit() {
37
- return getSessionPlayer();
38
- }
39
-
40
- async performAction() {
41
- throw new Error('not implemented');
42
- }
43
-
44
- getTarget() {
45
- const targetId = this.step.targetId || 'targetId';
46
- return this.context.data[targetId];
47
- }
48
-
49
- /** @type {ClickimStepAction['execute']} */
50
- async execute(stepActionFactory, step) {
51
- try {
52
- const res = await this.performAction(stepActionFactory, step);
53
- return { success: true, ...res };
54
- } catch (err) {
55
- const errorMsg = err?.message || err?.seleniumStack?.message;
56
- const displayMsg = err?.displayMessage;
57
- return {
58
- success: false,
59
- reason: errorMsg,
60
- exception: err,
61
- errorType: this.sessionPlayerInit.commonConstants.stepResult.ACTION_EXCEPTION,
62
- resultInfo: {
63
- exception: `selenium exception: ${errorMsg}`,
64
- // clickim -> playbackStepResultHandler.js -> FAILURE_REASON_MAPPING -> ACTION_EXCEPTION
65
- // expects resultInfo.error or resultInfo.reason
66
- error: displayMsg || errorMsg,
67
- },
68
- };
69
- }
70
- }
71
- }
72
-
73
- module.exports = StepAction;
@@ -1,111 +0,0 @@
1
- // @ts-check
2
-
3
- 'use strict';
4
-
5
- const LocateStepAction = require('./locateStepAction');
6
- const ScrollStepAction = require('./scrollStepAction');
7
- const MouseStepAction = require('./mouseStepAction');
8
- const TextValidationStepAction = require('./textValidationStepAction');
9
- const EvaluateExpressionStepAction = require('./evaluateExpressionStepAction');
10
- const TextStepAction = require('./textStepAction');
11
- const JsCodeStepAction = require('./jsCodeStepAction');
12
- const JsConditionStepAction = require('./jsConditionStepAction');
13
- const SpecialKeyStepAction = require('./specialKeyStepAction');
14
- const SelectOptionStepAction = require('./selectOptionStepAction');
15
- const SubmitStepAction = require('./submitStepAction');
16
- const HoverStepAction = require('./hoverStepAction');
17
- const WheelStepAction = require('./wheelStepAction');
18
- const DropFileStepAction = require('./dropFileStepAction');
19
- const InputFileStepAction = require('./inputFileStepAction');
20
- const NavigationStepAction = require('./navigationStepAction');
21
- const SleepStepAction = require('./sleepStepAction');
22
- const RefreshStepAction = require('./RefreshStepAction');
23
- const ApiStepAction = require('./apiStepAction');
24
- const ExtractTextStepAction = require('./extractTextStepAction');
25
- const TdkHybridStepAction = require('./tdkHybridStepAction');
26
- const PixelValidationStepAction = require('./pixelValidationStepAction');
27
- const CliJsStepAction = require('./cliJsStepAction');
28
- const CliConditionStepAction = require('./cliConditionStepAction');
29
- const NodePackageStepAction = require('./nodePackageStepAction');
30
- const ExtensionOnlyStepAction = require('./extensionOnlyStepAction');
31
- const SfdcStepAction = require('./sfdcStepAction');
32
- const SfdcRecordedStepAction = require('./sfdcRecordedStepAction');
33
-
34
- function register(stepActionByType, stepActionFactory) {
35
- Object.keys(stepActionByType).forEach(type => {
36
- stepActionFactory.registerStepAction(type, stepActionByType[type]);
37
- });
38
- }
39
-
40
- const STEP_ACTION_MAPPING = {
41
- locate: LocateStepAction,
42
- scroll: ScrollStepAction,
43
- mouse: MouseStepAction,
44
- submit: SubmitStepAction,
45
- text: TextStepAction,
46
- 'special-key': SpecialKeyStepAction,
47
- 'user-code': JsCodeStepAction,
48
- 'validation-code-step': JsCodeStepAction,
49
- 'wait-for-code-step': JsCodeStepAction,
50
- 'action-code-step': JsCodeStepAction,
51
- 'condition-step': JsConditionStepAction,
52
- 'skip-code-step': JsConditionStepAction,
53
- 'element-code-step': JsConditionStepAction,
54
- 'evaluate-expression': EvaluateExpressionStepAction,
55
- 'text-validation': TextValidationStepAction,
56
- 'wait-for-text-validation': TextValidationStepAction,
57
- 'select-option': SelectOptionStepAction,
58
- 'drop-file': DropFileStepAction,
59
- 'input-file': InputFileStepAction,
60
- hover: HoverStepAction,
61
- navigation: NavigationStepAction,
62
- wheel: WheelStepAction,
63
- sleep: SleepStepAction,
64
- refresh: RefreshStepAction,
65
- 'api-validation': ApiStepAction,
66
- 'api-action': ApiStepAction,
67
- 'api-code-step': JsCodeStepAction,
68
- 'extract-text': ExtractTextStepAction,
69
- 'simple-ui-verification': PixelValidationStepAction,
70
- 'wait-for-simple-ui-verification': PixelValidationStepAction,
71
-
72
- 'cli-validation-download-file': ExtensionOnlyStepAction,
73
- 'cli-wait-for-download-file': ExtensionOnlyStepAction,
74
- 'network-validation-step': ExtensionOnlyStepAction,
75
-
76
- 'cli-validation-code-step': CliJsStepAction,
77
- 'cli-wait-for-code-step': CliJsStepAction,
78
- 'cli-action-code-step': CliJsStepAction,
79
- 'cli-api-code-step': CliJsStepAction,
80
-
81
- 'cli-condition-step': CliConditionStepAction,
82
- 'node-package': NodePackageStepAction,
83
-
84
- 'email-code-step': JsCodeStepAction,
85
- 'cli-email-code-step': CliJsStepAction,
86
- 'tdk-hybrid': TdkHybridStepAction,
87
-
88
- 'sfdc-recorded-step': SfdcRecordedStepAction,
89
- 'sfdc-step-login': SfdcStepAction,
90
- 'sfdc-step-logout': SfdcStepAction,
91
- 'sfdc-step-sobjectcreate': SfdcStepAction,
92
- 'sfdc-step-sobjectdelete': SfdcStepAction,
93
- 'sfdc-step-findrecord': SfdcStepAction,
94
- 'sfdc-step-quickaction': SfdcStepAction,
95
- 'sfdc-step-sobjectedit': SfdcStepAction,
96
- 'sfdc-step-sobjectvalidate': SfdcStepAction,
97
- 'sfdc-step-launchapp': SfdcStepAction,
98
- 'sfdc-step-closeconsoletabs': SfdcStepAction,
99
- 'sfdc-step-relatedlistaction': SfdcStepAction,
100
- };
101
-
102
- /**
103
- * @param {import('../webdriver')} driver
104
- * @param {import('clickim/src/background/stepActions/stepActionFactory').StepActionFactory} stepActionFactory
105
- */
106
- module.exports = function (driver, stepActionFactory, runMode) {
107
- register(STEP_ACTION_MAPPING, stepActionFactory);
108
- if (stepActionFactory.registerLocateStepActionUtils) {
109
- stepActionFactory.registerLocateStepActionUtils(LocateStepAction.getUtils(driver));
110
- }
111
- };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
-
5
- class SubmitStepAction extends StepAction {
6
- async performAction() {
7
- await this.driver.submitForm(this.getTarget().seleniumElement);
8
- }
9
- }
10
-
11
- module.exports = SubmitStepAction;
12
-
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
- const { execute } = require('../../stepPlayers/hybridStepPlayback');
5
-
6
- class TdkHybridStepAction extends StepAction {
7
- async performAction() {
8
- return await execute(
9
- this.step,
10
- this.context,
11
- this.driver,
12
- this.stepActionUtils.testimServicesApi.authenticationManager.getLoggedUserInfo(),
13
- this.frameHandler.frameManager
14
- );
15
- }
16
- }
17
-
18
- module.exports = TdkHybridStepAction;
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
- const setTextScript = require('./scripts/setText');
5
- const dispatchFocus = require('./scripts/focusElement');
6
- const { extractElementId, delay } = require('../../utils');
7
-
8
- class TextStepAction extends StepAction {
9
- async setValueNative() {
10
- const context = this.context;
11
- const target = this.getTarget();
12
- if (!this.step.delayBetweenChars) {
13
- return this.driver.setValue(target.seleniumElement, context.stepText);
14
- }
15
-
16
- await this.driver.elementIdClear(extractElementId(target.seleniumElement));
17
- return await this.setTextDelayed();
18
- }
19
-
20
- async setValueJS() {
21
- const step = this.step;
22
- const context = this.context;
23
- const target = context.data[step.targetId || 'targetId'];
24
- const timeout = context.data.timeToPlayStep + 3000;
25
- const events = step.events;
26
-
27
- const { setTextDraftJs } = this.sessionPlayerInit.codeSnippets;
28
- if (target.isDraftEditor && setTextDraftJs) {
29
- return this.driver.executeJS(setTextDraftJs(target.locatedElement, context.stepText));
30
- }
31
-
32
- if (!events?.length) {
33
- return undefined;
34
- }
35
-
36
- const eventMessage = {
37
- eventType: step.type,
38
- events,
39
- quirks: step.quirks,
40
- locatedElement: target.locatedElement,
41
- isRoot: target.isRoot,
42
- elementToFocusLocatedElement: target.elementToFocusLocatedElement,
43
- };
44
-
45
- const setTextCode = `
46
- var getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
47
- var dispatchFocus = ${dispatchFocus};
48
- var setText = ${setTextScript.toString()};
49
- var eventData = arguments[0];
50
- var done = arguments[1];
51
- return setText.call(null, eventData, done);
52
- `;
53
-
54
- const result = await this.driver.executeCodeAsync(setTextCode, timeout, eventMessage);
55
- return { success: Boolean(result.value?.success) };
56
- }
57
-
58
- async setTextDelayed() {
59
- const letters = this.context.stepText;
60
- const target = this.getTarget();
61
- for (let i = 0; i < letters.length; i++) {
62
- await this.driver.elementIdValue(extractElementId(target.seleniumElement), letters[i]);
63
- // don't delay on last step.
64
- if (i < letters.length - 1) {
65
- await delay(this.step.delayBetweenChars);
66
- }
67
- }
68
- }
69
-
70
- async setValueAppendNative() {
71
- const keys = [];
72
- const context = this.context;
73
- const target = this.getTarget();
74
-
75
- if (target?.seleniumElement) {
76
- if (!this.step.delayBetweenChars) {
77
- keys.push(Array.from(context.stepText));
78
- return this.driver.elementIdValue(extractElementId(target.seleniumElement), keys);
79
- }
80
-
81
- return this.setTextDelayed();
82
- }
83
- throw new Error('missing selenium element');
84
- }
85
-
86
- async performAction() {
87
- const target = this.getTarget();
88
- const forceJsEvent = this.driver.isSafari() &&
89
- target.locatedElement && target.locatedElement.shadowPath &&
90
- Array.isArray(target.locatedElement.shadowPath) && target.locatedElement.shadowPath.length > 1;
91
-
92
- if (this.step.appendText) {
93
- if (this.step.nativeEvents) {
94
- return this.setValueAppendNative();
95
- }
96
- const { stepResult } = this.sessionPlayerInit.commonConstants;
97
- return {
98
- success: false,
99
- errorType: stepResult.TEXT_ACTION_FAILURE,
100
- resultInfo: { error: "'Append Text' is only supported in Native Mode" },
101
- };
102
- }
103
- if (this.step.nativeEvents && !forceJsEvent) {
104
- return this.setValueNative();
105
- }
106
- return this.setValueJS();
107
- }
108
- }
109
-
110
- module.exports = TextStepAction;
@@ -1,64 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
-
5
- class TextValidationStepAction extends StepAction {
6
- async performAction(stepActionFactory) {
7
- const { step, context, frameHandler, sessionPlayerInit: { paramEvaluator, utils, commonConstants } } = this;
8
- const target = this.getTarget();
9
-
10
- try {
11
- const text = await this.stepActionUtils.extractTargetText(target);
12
- let actual;
13
- let expected;
14
- if (paramEvaluator) {
15
- const evaluation = paramEvaluator.computeExpression(
16
- step.expression2,
17
- context,
18
- this.exportsGlobal,
19
- this.exportsTest,
20
- );
21
- actual = text;
22
- expected = evaluation.evaluatedText;
23
- } else {
24
- const res = await stepActionFactory.executeStep(
25
- step.expression2,
26
- context,
27
- frameHandler,
28
- this.exportsGlobal,
29
- this.locateElementPlayer,
30
- this.exportsTest,
31
- );
32
- actual = text;
33
- expected = res.evaluatedText;
34
- }
35
- try {
36
- const compareResult = utils.compareOrMatch(expected, actual);
37
- if (compareResult) {
38
- return { success: true };
39
- }
40
- return {
41
- success: false,
42
- errorType: commonConstants.stepResult.TEXT_COMPARE_FAILURE,
43
- resultInfo: { expected: String(expected), actual },
44
- };
45
- } catch (err) {
46
- return {
47
- success: false,
48
- errorType: commonConstants.stepResult.TEXT_COMPARE_FAILURE,
49
- resultInfo: { expected: expected.toString(), actual },
50
- };
51
- }
52
- } catch (err) {
53
- return {
54
- success: false,
55
- reason: err.message,
56
- exception: err,
57
- shouldRetry: true,
58
- };
59
- }
60
- }
61
- }
62
-
63
- module.exports = TextValidationStepAction;
64
-
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
- const wheelScript = require('./scripts/wheel');
5
-
6
- class WheelStepAction extends StepAction {
7
- async performAction() {
8
- const step = this.step;
9
- const context = this.context;
10
- const events = step.events;
11
-
12
- if (!events?.length) {
13
- return undefined;
14
- }
15
-
16
- const eventMessage = {
17
- events,
18
- eventData: {
19
- modifiers: step.modifiers,
20
- button: step.button,
21
- },
22
- locatedElement: this.getTarget().locatedElement,
23
- };
24
-
25
- const timeout = context.data.timeToPlayStep + 3000;
26
-
27
- const wheelCode = `
28
- var getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
29
- var wheel = ${wheelScript.toString()};
30
- var eventData = arguments[0];
31
- var done = arguments[1];
32
- return wheel.call(null, eventData, done);
33
- `;
34
-
35
- const result = await this.driver.executeCodeAsync(wheelCode, timeout, eventMessage);
36
- return { success: result.value?.state === 'success' };
37
- }
38
- }
39
-
40
- module.exports = WheelStepAction;
41
-
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- const logger = require('../../commons/logger').getLogger('cookies-utils');
4
-
5
- module.exports = function (driver) {
6
- class CookieUtils {
7
- set(cookie) {
8
- let domain = cookie.domain;
9
- if(!cookie.hostOnly) {
10
- if (domain && !domain.startsWith('.')) {
11
- domain = `.${domain}`;
12
- }
13
- }
14
- return driver.setCookie(cookie.name, cookie.value, domain, cookie.httpOnly, cookie.secure, cookie.path, cookie.expirationDate)
15
- .catch(err => {
16
- logger.error("failed to set cookie", {err});
17
- throw err;
18
- });
19
- }
20
-
21
- get(cookie) {
22
- return driver.getCookie(cookie.name)
23
- .catch(err => {
24
- logger.error("failed to get cookie", {err});
25
- throw err;
26
- });
27
- }
28
-
29
- remove(cookie) {
30
- return driver.deleteCookie(cookie.name)
31
- .catch(err => {
32
- logger.error("failed to remove cookie", {err});
33
- throw err;
34
- });
35
- }
36
- }
37
-
38
- return new CookieUtils();
39
- };