@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.
- package/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1169 -12846
- package/package.json +16 -10
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -13
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- package/workers/workerUtils.js +0 -20
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2017 Apple Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Redistribution and use in source and binary forms, with or without
|
|
5
|
-
* modification, are permitted provided that the following conditions
|
|
6
|
-
* are met:
|
|
7
|
-
* 1. Redistributions of source code must retain the above copyright
|
|
8
|
-
* notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
* documentation and/or other materials provided with the distribution.
|
|
12
|
-
*
|
|
13
|
-
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
14
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
15
|
-
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
16
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
17
|
-
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
18
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
19
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
20
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
21
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
22
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
23
|
-
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
// https://github.com/webdriverio/webdriverio/blob/master/packages/webdriverio/src/scripts/isElementDisplayed.js
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* check if element is visible
|
|
30
|
-
* @param {HTMLElement} element element to check
|
|
31
|
-
* @return {Boolean} true if element is within viewport
|
|
32
|
-
*/
|
|
33
|
-
module.exports = function isElementDisplayed(element) {
|
|
34
|
-
function nodeIsElement(node) {
|
|
35
|
-
if (!node) {
|
|
36
|
-
return false
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
switch (node.nodeType) {
|
|
40
|
-
case Node.ELEMENT_NODE:
|
|
41
|
-
case Node.DOCUMENT_NODE:
|
|
42
|
-
case Node.DOCUMENT_FRAGMENT_NODE:
|
|
43
|
-
return true
|
|
44
|
-
|
|
45
|
-
default:
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function parentElementForElement(element) {
|
|
51
|
-
if (!element) {
|
|
52
|
-
return null
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return enclosingNodeOrSelfMatchingPredicate(element.parentNode, nodeIsElement)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function enclosingNodeOrSelfMatchingPredicate(targetNode, predicate) {
|
|
59
|
-
for (let node = targetNode; node && node !== targetNode.ownerDocument; node = node.parentNode)
|
|
60
|
-
if (predicate(node)) {
|
|
61
|
-
return node
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return null
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function enclosingElementOrSelfMatchingPredicate(targetElement, predicate) {
|
|
68
|
-
for (let element = targetElement; element && element !== targetElement.ownerDocument; element = parentElementForElement(element))
|
|
69
|
-
if (predicate(element)) {
|
|
70
|
-
return element
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return null
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function cascadedStylePropertyForElement(element, property) {
|
|
77
|
-
if (!element || !property) {
|
|
78
|
-
return null
|
|
79
|
-
}
|
|
80
|
-
// if document-fragment, skip it and use element.host instead. This happens
|
|
81
|
-
// when the element is inside a shadow root.
|
|
82
|
-
// window.getComputedStyle errors on document-fragment.
|
|
83
|
-
if (element instanceof DocumentFragment) {
|
|
84
|
-
element = element.host
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let computedStyle = window.getComputedStyle(element)
|
|
88
|
-
let computedStyleProperty = computedStyle.getPropertyValue(property)
|
|
89
|
-
if (computedStyleProperty && computedStyleProperty !== 'inherit') {
|
|
90
|
-
return computedStyleProperty
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Ideally getPropertyValue would return the 'used' or 'actual' value, but
|
|
94
|
-
// it doesn't for legacy reasons. So we need to do our own poor man's cascade.
|
|
95
|
-
// Fall back to the first non-'inherit' value found in an ancestor.
|
|
96
|
-
// In any case, getPropertyValue will not return 'initial'.
|
|
97
|
-
|
|
98
|
-
// FIXME: will this incorrectly inherit non-inheritable CSS properties?
|
|
99
|
-
// I think all important non-inheritable properties (width, height, etc.)
|
|
100
|
-
// for our purposes here are specially resolved, so this may not be an issue.
|
|
101
|
-
// Specification is here: https://drafts.csswg.org/cssom/#resolved-values
|
|
102
|
-
let parentElement = parentElementForElement(element)
|
|
103
|
-
return cascadedStylePropertyForElement(parentElement, property)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function elementSubtreeHasNonZeroDimensions(element) {
|
|
107
|
-
let boundingBox = element.getBoundingClientRect()
|
|
108
|
-
if (boundingBox.width > 0 && boundingBox.height > 0) {
|
|
109
|
-
return true
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Paths can have a zero width or height. Treat them as shown if the stroke width is positive.
|
|
113
|
-
if (element.tagName.toUpperCase() === 'PATH' && boundingBox.width + boundingBox.height > 0) {
|
|
114
|
-
let strokeWidth = cascadedStylePropertyForElement(element, 'stroke-width')
|
|
115
|
-
return !!strokeWidth && (parseInt(strokeWidth, 10) > 0)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let cascadedOverflow = cascadedStylePropertyForElement(element, 'overflow')
|
|
119
|
-
if (cascadedOverflow === 'hidden') {
|
|
120
|
-
return false
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// If the container's overflow is not hidden and it has zero size, consider the
|
|
124
|
-
// container to have non-zero dimensions if a child node has non-zero dimensions.
|
|
125
|
-
return Array.from(element.childNodes).some((childNode) => {
|
|
126
|
-
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
127
|
-
return true
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (nodeIsElement(childNode)) {
|
|
131
|
-
return elementSubtreeHasNonZeroDimensions(childNode)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return false
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function elementOverflowsContainer(element) {
|
|
139
|
-
let cascadedOverflow = cascadedStylePropertyForElement(element, 'overflow')
|
|
140
|
-
if (cascadedOverflow !== 'hidden') {
|
|
141
|
-
return false
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// FIXME: this needs to take into account the scroll position of the element,
|
|
145
|
-
// the display modes of it and its ancestors, and the container it overflows.
|
|
146
|
-
// See Selenium's bot.dom.getOverflowState atom for an exhaustive list of edge cases.
|
|
147
|
-
return true
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function isElementSubtreeHiddenByOverflow(element) {
|
|
151
|
-
if (!element) {
|
|
152
|
-
return false
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (!elementOverflowsContainer(element)) {
|
|
156
|
-
return false
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!element.childNodes.length) {
|
|
160
|
-
return false
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// This element's subtree is hidden by overflow if all child subtrees are as well.
|
|
164
|
-
return Array.from(element.childNodes).every((childNode) => {
|
|
165
|
-
// Returns true if the child node is overflowed or otherwise hidden.
|
|
166
|
-
// Base case: not an element, has zero size, scrolled out, or doesn't overflow container.
|
|
167
|
-
// Visibility of text nodes is controlled by parent
|
|
168
|
-
if (childNode.nodeType === Node.TEXT_NODE) {
|
|
169
|
-
return false
|
|
170
|
-
}
|
|
171
|
-
if (!nodeIsElement(childNode)) {
|
|
172
|
-
return true
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (!elementSubtreeHasNonZeroDimensions(childNode)) {
|
|
176
|
-
return true
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Recurse.
|
|
180
|
-
return isElementSubtreeHiddenByOverflow(childNode)
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
// walk up the tree testing for a shadow root
|
|
184
|
-
function isElementInsideShadowRoot(element) {
|
|
185
|
-
if (!element) {
|
|
186
|
-
return false
|
|
187
|
-
}
|
|
188
|
-
if (element.parentNode && element.parentNode.host) {
|
|
189
|
-
return true
|
|
190
|
-
}
|
|
191
|
-
return isElementInsideShadowRoot(element.parentNode)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// This is a partial reimplementation of Selenium's "element is displayed" algorithm.
|
|
195
|
-
// When the W3C specification's algorithm stabilizes, we should implement that.
|
|
196
|
-
// If this command is misdirected to the wrong document (and is NOT inside a shadow root), treat it as not shown.
|
|
197
|
-
if (!isElementInsideShadowRoot(element) && !document.contains(element)) {
|
|
198
|
-
return false
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Special cases for specific tag names.
|
|
202
|
-
switch (element.tagName.toUpperCase()) {
|
|
203
|
-
case 'BODY':
|
|
204
|
-
return true
|
|
205
|
-
|
|
206
|
-
case 'SCRIPT':
|
|
207
|
-
case 'NOSCRIPT':
|
|
208
|
-
return false
|
|
209
|
-
|
|
210
|
-
case 'OPTGROUP':
|
|
211
|
-
case 'OPTION': {
|
|
212
|
-
// Option/optgroup are considered shown if the containing <select> is shown.
|
|
213
|
-
let enclosingSelectElement = enclosingNodeOrSelfMatchingPredicate(element, (e) => e.tagName.toUpperCase() === 'SELECT')
|
|
214
|
-
return isElementDisplayed(enclosingSelectElement)
|
|
215
|
-
}
|
|
216
|
-
case 'INPUT':
|
|
217
|
-
// <input type="hidden"> is considered not shown.
|
|
218
|
-
if (element.type === 'hidden') {
|
|
219
|
-
return false
|
|
220
|
-
}
|
|
221
|
-
break
|
|
222
|
-
// case 'MAP':
|
|
223
|
-
// FIXME: Selenium has special handling for <map> elements. We don't do anything now.
|
|
224
|
-
|
|
225
|
-
default:
|
|
226
|
-
break
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (cascadedStylePropertyForElement(element, 'visibility') !== 'visible') {
|
|
230
|
-
return false
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
let hasAncestorWithZeroOpacity = !!enclosingElementOrSelfMatchingPredicate(element, (e) => {
|
|
234
|
-
return Number(cascadedStylePropertyForElement(e, 'opacity')) === 0
|
|
235
|
-
})
|
|
236
|
-
let hasAncestorWithDisplayNone = !!enclosingElementOrSelfMatchingPredicate(element, (e) => {
|
|
237
|
-
return cascadedStylePropertyForElement(e, 'display') === 'none'
|
|
238
|
-
})
|
|
239
|
-
if (hasAncestorWithZeroOpacity || hasAncestorWithDisplayNone) {
|
|
240
|
-
return false
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (!elementSubtreeHasNonZeroDimensions(element)) {
|
|
244
|
-
return false
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (isElementSubtreeHiddenByOverflow(element)) {
|
|
248
|
-
return false
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return true
|
|
252
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const utils = require('../utils');
|
|
4
|
-
const WebDriver = require('./webdriver');
|
|
5
|
-
const CookieUtils = require('./utils/cookieUtils');
|
|
6
|
-
const TabService = require('./services/tabService');
|
|
7
|
-
const PortSelector = require('./services/portSelector');
|
|
8
|
-
const StepActionUtils = require('./utils/stepActionUtils');
|
|
9
|
-
const frameLocatorFactory = require('./services/frameLocator');
|
|
10
|
-
const testResultService = require('../commons/socket/testResultService');
|
|
11
|
-
const windowCreationListener = require('./services/windowCreationListener');
|
|
12
|
-
const PlaybackTimeoutCalculator = require('./services/playbackTimeoutCalculator');
|
|
13
|
-
const { isDebuggerConnected } = require('../commons/detectDebugger');
|
|
14
|
-
const { getSessionPlayer } = require('../commons/getSessionPlayerRequire');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class SeleniumTestPlayer {
|
|
18
|
-
//eslint-disable-next-line default-param-last
|
|
19
|
-
constructor(id, userParamsData, shouldMonitorPerformance, automationMode = 'code', driver = new WebDriver(), testRetryCount, previousTestResultId) {
|
|
20
|
-
const { sessionPlayer: Player, commonConstants, stepActionFactory: StepActionFactory } = getSessionPlayer();
|
|
21
|
-
this.driver = driver;
|
|
22
|
-
this.id = id;
|
|
23
|
-
|
|
24
|
-
const stepActionUtils = new StepActionUtils(this.driver);
|
|
25
|
-
this.stepActionFactory = new StepActionFactory(stepActionUtils);
|
|
26
|
-
require('./stepActions/stepActionRegistrar')(this.driver, this.stepActionFactory, 'selenium');
|
|
27
|
-
|
|
28
|
-
this.tabService = this.driver.tabService || new TabService(this.driver);
|
|
29
|
-
// expose the tabService on the driver so future sessions reusing the driver
|
|
30
|
-
// know the tabs (for example - a TDK Hybrid step)
|
|
31
|
-
this.driver.tabService = this.tabService;
|
|
32
|
-
this.windowCreationListener = windowCreationListener;
|
|
33
|
-
this.playbackTimeoutCalculator = new PlaybackTimeoutCalculator(isDebuggerConnected());
|
|
34
|
-
|
|
35
|
-
this.tabService.createSesion(id);
|
|
36
|
-
|
|
37
|
-
const FrameLocator = frameLocatorFactory(this.driver);
|
|
38
|
-
|
|
39
|
-
this.sessionPlayer = new Player(
|
|
40
|
-
id,
|
|
41
|
-
this.tabService,
|
|
42
|
-
CookieUtils(this.driver),
|
|
43
|
-
windowCreationListener,
|
|
44
|
-
FrameLocator,
|
|
45
|
-
PortSelector,
|
|
46
|
-
null,
|
|
47
|
-
null /* Not in use, placeholder for the order of arguments */,
|
|
48
|
-
stepActionUtils,
|
|
49
|
-
this.stepActionFactory,
|
|
50
|
-
this.playbackTimeoutCalculator,
|
|
51
|
-
testResultService.getSocket(),
|
|
52
|
-
automationMode,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
if (this.sessionPlayer.setShouldMonitorPerformance) {
|
|
56
|
-
this.sessionPlayer.setShouldMonitorPerformance(shouldMonitorPerformance);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.tabService.setAddFrameHandlerCallBack(this.sessionPlayer.addPlaybackFrameHandler.bind(this.sessionPlayer));
|
|
60
|
-
|
|
61
|
-
this.sessionPlayer.playbackManager.isRemoteSession = true;
|
|
62
|
-
this.sessionPlayer.playbackManager.isLocalRun = false;
|
|
63
|
-
this.sessionPlayer.playbackManager.testRetryCount = testRetryCount;
|
|
64
|
-
this.sessionPlayer.playbackManager.previousTestResultId = previousTestResultId;
|
|
65
|
-
|
|
66
|
-
this.sessionPlayer.playbackManager.userParamsData = userParamsData || {};
|
|
67
|
-
|
|
68
|
-
this.onStepCompleted = this.onStepCompleted.bind(this);
|
|
69
|
-
|
|
70
|
-
this.sessionPlayer.playbackManager.on(commonConstants.playback.RESULT, this.onStepCompleted);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
onStepCompleted(result, testId, resultId, step) {
|
|
74
|
-
if (step?.isTabOpener) {
|
|
75
|
-
this.tabService.addNewPopup(this.id, step.id)
|
|
76
|
-
.catch(() => { });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
onDone() {
|
|
81
|
-
const { commonConstants } = getSessionPlayer();
|
|
82
|
-
const END_DRIVER_TIMEOUT = 1000 * 60 * 2;
|
|
83
|
-
return utils.promiseTimeout(this.driver.end(), END_DRIVER_TIMEOUT)
|
|
84
|
-
.catch(error => {
|
|
85
|
-
if (error instanceof utils.TimeoutError) {
|
|
86
|
-
return this.driver.forceEnd().catch(() => null);
|
|
87
|
-
}
|
|
88
|
-
return undefined;
|
|
89
|
-
})
|
|
90
|
-
.then(() => {
|
|
91
|
-
this.sessionPlayer.playbackManager.off(commonConstants.playback.RESULT, this.onStepCompleted);
|
|
92
|
-
this.sessionPlayer = null;
|
|
93
|
-
this.tabService = null;
|
|
94
|
-
this.stepActionFactory = null;
|
|
95
|
-
this.driver = null;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
clearSessionTabs() {
|
|
100
|
-
this.tabService.clearAllTabs(this.id);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async addTab(openerStepId, options = { loadInfo: true }) {
|
|
104
|
-
const ids = await this.driver.getTabIds();
|
|
105
|
-
const lastId = ids.at(-1);
|
|
106
|
-
await this.tabService.addNewTab(this.id, lastId, openerStepId, options);
|
|
107
|
-
return this.sessionPlayer.addPlaybackFrameHandler(lastId, undefined, { emptyPage: true });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async addAllTabs(openerStepId, options = { loadInfo: true, checkForMainTab: true, takeScreenshots: true }, blackList = []) {
|
|
111
|
-
const ids = await this.driver.getTabIds();
|
|
112
|
-
// the ids are reversed so we search first in the last tab opened - otherwise it starts looking from the testim editor and not the AUT
|
|
113
|
-
|
|
114
|
-
const PROHIBITED_URLS = ['app.testim.io'].concat(blackList);
|
|
115
|
-
for (const id of ids.reverse()) {
|
|
116
|
-
await this.tabService.addNewTab(this.id, id, openerStepId, { ...options, forceSwitch: true });
|
|
117
|
-
const tabInfo = this.tabService.getTabInfo(this.id, id);
|
|
118
|
-
if (PROHIBITED_URLS.some(bad => tabInfo.url.includes(bad))) {
|
|
119
|
-
await this.tabService.removeTabInfo(this.id, id);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
await this.sessionPlayer.addPlaybackFrameHandler(id, undefined, { emptyPage: true });
|
|
123
|
-
}
|
|
124
|
-
if (this.tabService.tabCount(this.id) === 1) {
|
|
125
|
-
// if we only have one tab because we removed the editor tab - we have to switchTab to one of the other tabs, otherwise
|
|
126
|
-
// tabService will assume it's on a good context but it's not.
|
|
127
|
-
const tabInfo = this.tabService.getMainTabInfo(this.id);
|
|
128
|
-
const tabUtils = this.tabService.getTabUtils(this.id, tabInfo);
|
|
129
|
-
await this.tabService.switchTab(tabUtils.tabId, this.id, { forceSwitch: true });
|
|
130
|
-
}
|
|
131
|
-
// deal with checkForMainTab failing due to the page refreshing or JavaScript not responding or a similar issue
|
|
132
|
-
this.tabService.fixMissingMainTab(this.id);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
getSessionId() {
|
|
136
|
-
return this.driver.getSessionId();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
module.exports = SeleniumTestPlayer;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const featureFlags = require('../../commons/featureFlags');
|
|
6
|
-
const { getLogger } = require('../../commons/logger');
|
|
7
|
-
const { getSessionPlayer } = require('../../commons/getSessionPlayerRequire');
|
|
8
|
-
|
|
9
|
-
const logger = getLogger('frame-locator');
|
|
10
|
-
const SELENIUM_ELEMENT_KEY = 'ELEMENT';
|
|
11
|
-
const SELENIUM_GUID_KEY = 'element-6066-11e4-a52e-4f735466cecf';
|
|
12
|
-
|
|
13
|
-
const _getGuidFromSeleniumElement = (seleniumElement) => {
|
|
14
|
-
if (!seleniumElement) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return seleniumElement[SELENIUM_ELEMENT_KEY] || seleniumElement[SELENIUM_GUID_KEY];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/** @typedef {import('clickim/src/background/frameLocator').FrameLocator} FrameLocator */
|
|
22
|
-
/** @typedef {import("clickim/src/locators/dynamicParentUtils").FrameHandler} FrameHandler */
|
|
23
|
-
/** @typedef {import("clickim/src/background/playbackContext").PlaybackContext} PlaybackContext */
|
|
24
|
-
/** @typedef {import("clickim/src/background/frameTree").FrameTree} FrameTree */
|
|
25
|
-
/** @typedef {import("clickim/src/common/models/locateStep").LocateStep} LocateStep */
|
|
26
|
-
/** @typedef {import("clickim/src/common/models/step").Step} Step */
|
|
27
|
-
/** @typedef {FrameLocator['findFrame']} findFrameFn */
|
|
28
|
-
/** @typedef {ConstructorParameters<typeof import('clickim/src/background/frameLocator').FrameLocator>} ClickimFrameLocatorCtorArgs */
|
|
29
|
-
|
|
30
|
-
/** @param {import('../webdriver')} driver*/
|
|
31
|
-
module.exports = function frameLocatorFactory(driver) {
|
|
32
|
-
class FrameLocator {
|
|
33
|
-
/** @type {(...args: ClickimFrameLocatorCtorArgs) => this}} */
|
|
34
|
-
constructor(frameManager, locateElementPlayer) {
|
|
35
|
-
this.frameManager = frameManager;
|
|
36
|
-
this.locateElementPlayer = locateElementPlayer;
|
|
37
|
-
/** @type {Record<string, string>} */
|
|
38
|
-
this._cache = {};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
cacheResults(seleniumGuid, resultsUrl) {
|
|
42
|
-
this._cache[seleniumGuid] = resultsUrl;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getResultsFromCache(seleniumGuid) {
|
|
46
|
-
return this._cache[seleniumGuid];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
cacheFrameLocateResults(frameHandler) {
|
|
50
|
-
if (frameHandler?.seleniumFrameElement && frameHandler.frameLocateResultUrl) {
|
|
51
|
-
const guid = _getGuidFromSeleniumElement(frameHandler.seleniumFrameElement);
|
|
52
|
-
if (guid) {
|
|
53
|
-
this.cacheResults(guid, frameHandler.frameLocateResultUrl);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {FrameTree} frameTree
|
|
60
|
-
* @param {string | number} testimFrameId
|
|
61
|
-
* @returns {Promise<FrameHandler>}
|
|
62
|
-
*/
|
|
63
|
-
async foundFrameCallback(result, frameTree, testimFrameId) {
|
|
64
|
-
const { frameOffset, locatedElement } = result;
|
|
65
|
-
const { locatorBuilderUtils } = getSessionPlayer();
|
|
66
|
-
if (locatorBuilderUtils.isEmptyResult(locatedElement)) {
|
|
67
|
-
const errorMsg = 'got empty result in frame result, not rejected from locate element player';
|
|
68
|
-
logger.error(errorMsg);
|
|
69
|
-
throw new Error(errorMsg);
|
|
70
|
-
}
|
|
71
|
-
const el = await driver.switchToLocatedFrame(locatedElement);
|
|
72
|
-
const guid = _getGuidFromSeleniumElement(el.value);
|
|
73
|
-
const frameLocateResultUrl = this.getResultsFromCache(guid);
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
frameId: -1,
|
|
77
|
-
frameOffset,
|
|
78
|
-
tabInfo: frameTree.tabInfo,
|
|
79
|
-
tabId: frameTree.tabId,
|
|
80
|
-
testimFrameId,
|
|
81
|
-
testimFullFrameId: `${this.currentFrameHandler.testimFullFrameId}-${testimFrameId}`,
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
seleniumFrameElement: el.value,
|
|
84
|
-
frameLocateResultUrl,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @param {LocateStep & { targetId: NonNullable<LocateStep['targetId']>}} frameLocator
|
|
90
|
-
* @param {number} frameDepth
|
|
91
|
-
* @param {FrameHandler & { frameOffset: NonNullable<FrameHandler['frameOffset']> }} currentFrame
|
|
92
|
-
* @param {PlaybackContext} context
|
|
93
|
-
* @param {FrameTree} frameTree
|
|
94
|
-
* @param {Step} stepData
|
|
95
|
-
*/
|
|
96
|
-
locate(frameLocator, frameDepth, currentFrame, context, frameTree, stepData) {
|
|
97
|
-
// eslint-disable-next-line new-cap
|
|
98
|
-
const locateElementPlayer = new this.locateElementPlayer(context);
|
|
99
|
-
frameLocator.targetId = `frameLocator_${frameDepth}`;
|
|
100
|
-
return locateElementPlayer.locate(frameLocator, currentFrame, frameLocator.targetId)
|
|
101
|
-
.then(result => {
|
|
102
|
-
result.isVisible = true; // frame visibility check is done on the target element
|
|
103
|
-
return locateElementPlayer.handleLocateResult(result, stepData, frameLocator)
|
|
104
|
-
.catch(() => { throw new Error(); }); // silence [object object] errors;
|
|
105
|
-
})
|
|
106
|
-
.then(result => {
|
|
107
|
-
const { locatedElement } = context.data[frameLocator.targetId];
|
|
108
|
-
return driver.getElementLocationWithPadding(locatedElement)
|
|
109
|
-
.then(location => {
|
|
110
|
-
const value = location.value || { top: 0, left: 0 };
|
|
111
|
-
result.frameOffset = {
|
|
112
|
-
top: currentFrame.frameOffset.top + value.top,
|
|
113
|
-
left: currentFrame.frameOffset.left + value.left,
|
|
114
|
-
};
|
|
115
|
-
return result;
|
|
116
|
-
});
|
|
117
|
-
})
|
|
118
|
-
.then(result => {
|
|
119
|
-
if (locateElementPlayer.addFrameDataToContext) {
|
|
120
|
-
locateElementPlayer.addFrameDataToContext(result.targetId, result.locateResult);
|
|
121
|
-
}
|
|
122
|
-
return this.foundFrameCallback(result, frameTree, frameLocator.testimFrameId);
|
|
123
|
-
})
|
|
124
|
-
.then(frameHandler => {
|
|
125
|
-
this.currentFrameHandler = frameHandler;
|
|
126
|
-
return frameHandler;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** @type {findFrameFn} */
|
|
131
|
-
async findFrame(stepData, frameLocators, context, frameTree) {
|
|
132
|
-
const allowNoFrameSwitch = featureFlags.flags.enableFrameSwitchOptimization.isEnabled();
|
|
133
|
-
const chronologicalResults = context.playback.resultsHandler.resultsByChronologicOrder;
|
|
134
|
-
const lastResult = chronologicalResults[chronologicalResults.length - 1];
|
|
135
|
-
const allowedRetries = 1;
|
|
136
|
-
const moreThanAllowedRetries = Boolean(lastResult) && lastResult.stepId === stepData.id && lastResult.results.length > allowedRetries;
|
|
137
|
-
if (allowNoFrameSwitch && !moreThanAllowedRetries && this.currentFrameHandler) {
|
|
138
|
-
const currentFramePos = frameLocators.findIndex(x => x.testimFrameId === this.currentFrameHandler.testimFrameId);
|
|
139
|
-
if (currentFramePos > -1) {
|
|
140
|
-
const shorterPath = frameLocators.slice(currentFramePos + 1);
|
|
141
|
-
let frameIndex = 0;
|
|
142
|
-
// Changes to the deepest frame
|
|
143
|
-
for (const frameLocator of shorterPath) {
|
|
144
|
-
frameIndex++;
|
|
145
|
-
this.currentFrameHandler = await this.locate(frameLocator, frameIndex, this.currentFrameHandler, context, frameTree, stepData);
|
|
146
|
-
}
|
|
147
|
-
return this.currentFrameHandler;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const topFrameHandler = await frameTree.getTopFrameHandler();
|
|
152
|
-
topFrameHandler.frameOffset = { top: 0, left: 0 };
|
|
153
|
-
const switchToTop = (allowNoFrameSwitch && this.currentFrameHandler === topFrameHandler) ?
|
|
154
|
-
this.currentFrameHandler :
|
|
155
|
-
driver.switchToTopFrame();
|
|
156
|
-
await switchToTop;
|
|
157
|
-
this.cacheFrameLocateResults(this.currentFrameHandler);
|
|
158
|
-
this.currentFrameHandler = topFrameHandler;
|
|
159
|
-
let frameIndex = 0;
|
|
160
|
-
let currentFrame = topFrameHandler;
|
|
161
|
-
for (const frameLocator of frameLocators) {
|
|
162
|
-
frameIndex++;
|
|
163
|
-
currentFrame = await this.locate(frameLocator, frameIndex, currentFrame, context, frameTree, stepData);
|
|
164
|
-
}
|
|
165
|
-
return currentFrame;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return FrameLocator;
|
|
170
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const logger = require('../../commons/logger').getLogger('mobile-frame-locator-mock');
|
|
4
|
-
|
|
5
|
-
/** @param {import('../webdriver')} driver*/
|
|
6
|
-
module.exports = function frameLocatorFactory(driver) {
|
|
7
|
-
class FrameLocator {
|
|
8
|
-
/** @type {(...args: ConstructorParameters<typeof import('clickim/src/background/frameLocator').FrameLocator>) => this} */
|
|
9
|
-
constructor(frameManager, locateElementPlayer) {
|
|
10
|
-
this.frameManager = frameManager;
|
|
11
|
-
this.locateElementPlayer = locateElementPlayer;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
foundFrameCallback(result, frameTree, testimFrameId) {
|
|
15
|
-
logger.info('foundFrameCallback-mock invoked');
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
locate(frameLocator, frameDepth, currentFrame, context, frameTree, stepData) {
|
|
21
|
-
logger.info('locate-mock invoked');
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
findFrame(stepData, frameLocators, context, frameTree) {
|
|
26
|
-
logger.info('findFrame-mock invoked');
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return FrameLocator;
|
|
32
|
-
};
|