codeceptjs 4.0.0-beta.5 → 4.0.0-beta.6.esm-aria
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/README.md +0 -45
- package/bin/codecept.js +46 -57
- package/lib/actor.js +15 -11
- package/lib/ai.js +6 -5
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +66 -107
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +29 -26
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +34 -31
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +10 -24
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +117 -269
- package/lib/config.js +111 -49
- package/lib/container.js +299 -102
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +1 -1
- package/lib/helper/ApiDataFactory.js +16 -13
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +1 -1
- package/lib/helper/JSONResponse.js +19 -30
- package/lib/helper/Mochawesome.js +9 -28
- package/lib/helper/Playwright.js +668 -265
- package/lib/helper/Puppeteer.js +284 -169
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +191 -71
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +11 -10
- package/lib/listener/helpers.js +33 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/steps.js +7 -18
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +108 -75
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +60 -27
- package/lib/mocha/factory.js +75 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +57 -25
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -13
- package/lib/mocha/ui.js +28 -31
- package/lib/output.js +11 -9
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +12 -8
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +47 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -23
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +6 -6
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +4 -4
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +68 -97
- package/lib/workerStorage.js +16 -17
- package/lib/workers.js +145 -171
- package/package.json +63 -57
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +11 -2
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +7 -18
- package/typings/promiseBasedTypes.d.ts +3769 -5450
- package/typings/types.d.ts +3953 -5778
- package/bin/test-server.js +0 -53
- package/lib/element/WebElement.js +0 -327
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- package/lib/listener/retryEnhancer.js +0 -85
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/htmlReporter.js +0 -1947
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/test-server.js +0 -323
- package/lib/within.js +0 -90
|
@@ -1,133 +1,133 @@
|
|
|
1
1
|
const createAdvancedTestResults = (url, dataToCheck, requests) => {
|
|
2
2
|
// Creates advanced test results for a network traffic check.
|
|
3
3
|
// Advanced test results only applies when expected parameters are set
|
|
4
|
-
if (!dataToCheck) return ''
|
|
4
|
+
if (!dataToCheck) return ''
|
|
5
5
|
|
|
6
|
-
let urlFound = false
|
|
7
|
-
let advancedResults
|
|
8
|
-
requests.forEach(
|
|
6
|
+
let urlFound = false
|
|
7
|
+
let advancedResults
|
|
8
|
+
requests.forEach(request => {
|
|
9
9
|
// url not found in this request. continue with next request
|
|
10
|
-
if (urlFound || !request.url.match(new RegExp(url))) return
|
|
11
|
-
urlFound = true
|
|
10
|
+
if (urlFound || !request.url.match(new RegExp(url))) return
|
|
11
|
+
urlFound = true
|
|
12
12
|
|
|
13
13
|
// Url found. Now we create advanced test report for that URL and show which parameters failed
|
|
14
14
|
if (!request.requestPostData) {
|
|
15
|
-
advancedResults = allParameterValuePairsMatchExtreme(extractQueryObjects(request.url), dataToCheck)
|
|
15
|
+
advancedResults = allParameterValuePairsMatchExtreme(extractQueryObjects(request.url), dataToCheck)
|
|
16
16
|
} else if (request.requestPostData) {
|
|
17
|
-
advancedResults = allRequestPostDataValuePairsMatchExtreme(request.requestPostData, dataToCheck)
|
|
17
|
+
advancedResults = allRequestPostDataValuePairsMatchExtreme(request.requestPostData, dataToCheck)
|
|
18
18
|
}
|
|
19
|
-
})
|
|
20
|
-
return advancedResults
|
|
21
|
-
}
|
|
19
|
+
})
|
|
20
|
+
return advancedResults
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
const extractQueryObjects =
|
|
23
|
+
const extractQueryObjects = queryString => {
|
|
24
24
|
// Converts a string of GET parameters into an array of parameter objects. Each parameter object contains the properties "name" and "value".
|
|
25
25
|
if (queryString.indexOf('?') === -1) {
|
|
26
|
-
return []
|
|
26
|
+
return []
|
|
27
27
|
}
|
|
28
|
-
const queryObjects = []
|
|
28
|
+
const queryObjects = []
|
|
29
29
|
|
|
30
|
-
const queryPart = queryString.split('?')[1]
|
|
30
|
+
const queryPart = queryString.split('?')[1]
|
|
31
31
|
|
|
32
|
-
const queryParameters = queryPart.split('&')
|
|
32
|
+
const queryParameters = queryPart.split('&')
|
|
33
33
|
|
|
34
|
-
queryParameters.forEach(
|
|
35
|
-
const keyValue = queryParameter.split('=')
|
|
36
|
-
const queryObject = {}
|
|
34
|
+
queryParameters.forEach(queryParameter => {
|
|
35
|
+
const keyValue = queryParameter.split('=')
|
|
36
|
+
const queryObject = {}
|
|
37
37
|
|
|
38
|
-
queryObject.name = keyValue[0]
|
|
39
|
-
queryObject.value = decodeURIComponent(keyValue[1])
|
|
40
|
-
queryObjects.push(queryObject)
|
|
41
|
-
})
|
|
38
|
+
queryObject.name = keyValue[0]
|
|
39
|
+
queryObject.value = decodeURIComponent(keyValue[1])
|
|
40
|
+
queryObjects.push(queryObject)
|
|
41
|
+
})
|
|
42
42
|
|
|
43
|
-
return queryObjects
|
|
44
|
-
}
|
|
43
|
+
return queryObjects
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
const allParameterValuePairsMatchExtreme = (queryStringObject, advancedExpectedParameterValuePairs) => {
|
|
47
47
|
// More advanced check if all request parameters match with the expectations
|
|
48
|
-
let littleReport = '\nQuery parameters:\n'
|
|
49
|
-
let success = true
|
|
48
|
+
let littleReport = '\nQuery parameters:\n'
|
|
49
|
+
let success = true
|
|
50
50
|
|
|
51
51
|
for (const expectedKey in advancedExpectedParameterValuePairs) {
|
|
52
52
|
if (!Object.prototype.hasOwnProperty.call(advancedExpectedParameterValuePairs, expectedKey)) {
|
|
53
|
-
continue
|
|
53
|
+
continue
|
|
54
54
|
}
|
|
55
|
-
let parameterFound = false
|
|
56
|
-
const expectedValue = advancedExpectedParameterValuePairs[expectedKey]
|
|
55
|
+
let parameterFound = false
|
|
56
|
+
const expectedValue = advancedExpectedParameterValuePairs[expectedKey]
|
|
57
57
|
|
|
58
58
|
for (const queryParameter of queryStringObject) {
|
|
59
59
|
if (queryParameter.name === expectedKey) {
|
|
60
|
-
parameterFound = true
|
|
60
|
+
parameterFound = true
|
|
61
61
|
if (expectedValue === undefined) {
|
|
62
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')}\n
|
|
62
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')}\n`
|
|
63
63
|
} else if (typeof expectedValue === 'object' && expectedValue.base64) {
|
|
64
|
-
const decodedActualValue = Buffer.from(queryParameter.value, 'base64').toString('utf8')
|
|
64
|
+
const decodedActualValue = Buffer.from(queryParameter.value, 'base64').toString('utf8')
|
|
65
65
|
if (decodedActualValue === expectedValue.base64) {
|
|
66
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64})\n
|
|
66
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64})\n`
|
|
67
67
|
} else {
|
|
68
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64}) -> actual value: "base64(${decodedActualValue})"\n
|
|
69
|
-
success = false
|
|
68
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64}) -> actual value: "base64(${decodedActualValue})"\n`
|
|
69
|
+
success = false
|
|
70
70
|
}
|
|
71
71
|
} else if (queryParameter.value === expectedValue) {
|
|
72
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')} = ${expectedValue}\n
|
|
72
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')} = ${expectedValue}\n`
|
|
73
73
|
} else {
|
|
74
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = ${expectedValue} -> actual value: "${queryParameter.value}"\n
|
|
75
|
-
success = false
|
|
74
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = ${expectedValue} -> actual value: "${queryParameter.value}"\n`
|
|
75
|
+
success = false
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (parameterFound === false) {
|
|
81
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')}${expectedValue ? ` = ${JSON.stringify(expectedValue)}` : ''} -> parameter not found in request\n
|
|
82
|
-
success = false
|
|
81
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')}${expectedValue ? ` = ${JSON.stringify(expectedValue)}` : ''} -> parameter not found in request\n`
|
|
82
|
+
success = false
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
return success ? true : littleReport
|
|
87
|
-
}
|
|
86
|
+
return success ? true : littleReport
|
|
87
|
+
}
|
|
88
88
|
|
|
89
89
|
const allRequestPostDataValuePairsMatchExtreme = (RequestPostDataObject, advancedExpectedRequestPostValuePairs) => {
|
|
90
90
|
// More advanced check if all request post data match with the expectations
|
|
91
|
-
let littleReport = '\nRequest Post Data:\n'
|
|
92
|
-
let success = true
|
|
91
|
+
let littleReport = '\nRequest Post Data:\n'
|
|
92
|
+
let success = true
|
|
93
93
|
|
|
94
94
|
for (const expectedKey in advancedExpectedRequestPostValuePairs) {
|
|
95
95
|
if (!Object.prototype.hasOwnProperty.call(advancedExpectedRequestPostValuePairs, expectedKey)) {
|
|
96
|
-
continue
|
|
96
|
+
continue
|
|
97
97
|
}
|
|
98
|
-
let keyFound = false
|
|
99
|
-
const expectedValue = advancedExpectedRequestPostValuePairs[expectedKey]
|
|
98
|
+
let keyFound = false
|
|
99
|
+
const expectedValue = advancedExpectedRequestPostValuePairs[expectedKey]
|
|
100
100
|
|
|
101
101
|
for (const [key, value] of Object.entries(RequestPostDataObject)) {
|
|
102
102
|
if (key === expectedKey) {
|
|
103
|
-
keyFound = true
|
|
103
|
+
keyFound = true
|
|
104
104
|
if (expectedValue === undefined) {
|
|
105
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')}\n
|
|
105
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')}\n`
|
|
106
106
|
} else if (typeof expectedValue === 'object' && expectedValue.base64) {
|
|
107
|
-
const decodedActualValue = Buffer.from(value, 'base64').toString('utf8')
|
|
107
|
+
const decodedActualValue = Buffer.from(value, 'base64').toString('utf8')
|
|
108
108
|
if (decodedActualValue === expectedValue.base64) {
|
|
109
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64})\n
|
|
109
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64})\n`
|
|
110
110
|
} else {
|
|
111
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64}) -> actual value: "base64(${decodedActualValue})"\n
|
|
112
|
-
success = false
|
|
111
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = base64(${expectedValue.base64}) -> actual value: "base64(${decodedActualValue})"\n`
|
|
112
|
+
success = false
|
|
113
113
|
}
|
|
114
114
|
} else if (value === expectedValue) {
|
|
115
|
-
littleReport += ` ${expectedKey.padStart(10, ' ')} = ${expectedValue}\n
|
|
115
|
+
littleReport += ` ${expectedKey.padStart(10, ' ')} = ${expectedValue}\n`
|
|
116
116
|
} else {
|
|
117
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = ${expectedValue} -> actual value: "${value}"\n
|
|
118
|
-
success = false
|
|
117
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')} = ${expectedValue} -> actual value: "${value}"\n`
|
|
118
|
+
success = false
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
if (keyFound === false) {
|
|
124
|
-
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')}${expectedValue ? ` = ${JSON.stringify(expectedValue)}` : ''} -> key not found in request\n
|
|
125
|
-
success = false
|
|
124
|
+
littleReport += ` ✖ ${expectedKey.padStart(10, ' ')}${expectedValue ? ` = ${JSON.stringify(expectedValue)}` : ''} -> key not found in request\n`
|
|
125
|
+
success = false
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
return success ? true : littleReport
|
|
130
|
-
}
|
|
129
|
+
return success ? true : littleReport
|
|
130
|
+
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Returns all URLs of all network requests recorded so far during execution of test scenario.
|
|
@@ -136,11 +136,11 @@ const allRequestPostDataValuePairsMatchExtreme = (RequestPostDataObject, advance
|
|
|
136
136
|
* @private
|
|
137
137
|
*/
|
|
138
138
|
function getTrafficDump() {
|
|
139
|
-
let dumpedTraffic = ''
|
|
140
|
-
this.requests.forEach(
|
|
141
|
-
dumpedTraffic += `${request.method} - ${request.url}\n
|
|
142
|
-
})
|
|
143
|
-
return dumpedTraffic
|
|
139
|
+
let dumpedTraffic = ''
|
|
140
|
+
this.requests.forEach(request => {
|
|
141
|
+
dumpedTraffic += `${request.method} - ${request.url}\n`
|
|
142
|
+
})
|
|
143
|
+
return dumpedTraffic
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
|
@@ -152,36 +152,29 @@ function getTrafficDump() {
|
|
|
152
152
|
* @private
|
|
153
153
|
*/
|
|
154
154
|
function isInTraffic(url, parameters) {
|
|
155
|
-
let isInTraffic = false
|
|
156
|
-
this.requests.forEach(
|
|
155
|
+
let isInTraffic = false
|
|
156
|
+
this.requests.forEach(request => {
|
|
157
157
|
if (isInTraffic) {
|
|
158
|
-
return
|
|
158
|
+
return // We already found traffic. Continue with next request
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
if (!request.url.match(new RegExp(url))) {
|
|
162
|
-
return
|
|
162
|
+
return // url not found in this request. continue with next request
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// URL has matched. Now we check the parameters
|
|
166
166
|
|
|
167
167
|
if (parameters) {
|
|
168
|
-
const advancedReport = allParameterValuePairsMatchExtreme(extractQueryObjects(request.url), parameters)
|
|
168
|
+
const advancedReport = allParameterValuePairsMatchExtreme(extractQueryObjects(request.url), parameters)
|
|
169
169
|
if (advancedReport === true) {
|
|
170
|
-
isInTraffic = true
|
|
170
|
+
isInTraffic = true
|
|
171
171
|
}
|
|
172
172
|
} else {
|
|
173
|
-
isInTraffic = true
|
|
173
|
+
isInTraffic = true
|
|
174
174
|
}
|
|
175
|
-
})
|
|
175
|
+
})
|
|
176
176
|
|
|
177
|
-
return isInTraffic
|
|
177
|
+
return isInTraffic
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
createAdvancedTestResults,
|
|
182
|
-
extractQueryObjects,
|
|
183
|
-
allParameterValuePairsMatchExtreme,
|
|
184
|
-
allRequestPostDataValuePairsMatchExtreme,
|
|
185
|
-
getTrafficDump,
|
|
186
|
-
isInTraffic,
|
|
187
|
-
};
|
|
180
|
+
export { createAdvancedTestResults, extractQueryObjects, allParameterValuePairsMatchExtreme, allRequestPostDataValuePairsMatchExtreme, getTrafficDump, isInTraffic }
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
export const blurElement = (element, context) => {
|
|
2
2
|
const clientSideBlurFn = el => {
|
|
3
|
-
el.blur()
|
|
4
|
-
}
|
|
3
|
+
el.blur()
|
|
4
|
+
}
|
|
5
5
|
|
|
6
6
|
try {
|
|
7
7
|
// Puppeteer
|
|
8
|
-
context.evaluate(clientSideBlurFn, element)
|
|
8
|
+
context.evaluate(clientSideBlurFn, element)
|
|
9
9
|
} catch (e) {
|
|
10
10
|
// WebDriver
|
|
11
11
|
try {
|
|
12
|
-
context.execute(clientSideBlurFn, element)
|
|
12
|
+
context.execute(clientSideBlurFn, element)
|
|
13
13
|
} catch (err) {
|
|
14
14
|
// ignore
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
export const focusElement = (element, context) => {
|
|
2
2
|
const clientSideFn = el => {
|
|
3
|
-
el.focus()
|
|
4
|
-
}
|
|
3
|
+
el.focus()
|
|
4
|
+
}
|
|
5
5
|
|
|
6
6
|
try {
|
|
7
7
|
// Puppeteer
|
|
8
|
-
context.evaluate(clientSideFn, element)
|
|
8
|
+
context.evaluate(clientSideFn, element)
|
|
9
9
|
} catch (e) {
|
|
10
10
|
// WebDriver
|
|
11
11
|
try {
|
|
12
|
-
context.execute(clientSideFn, element)
|
|
12
|
+
context.execute(clientSideFn, element)
|
|
13
13
|
} catch (err) {
|
|
14
14
|
// ignore
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
export const highlightElement = (element, context) => {
|
|
2
2
|
const clientSideHighlightFn = el => {
|
|
3
|
-
const style = '0px 0px 4px 3px rgba(255, 0, 0, 0.7)'
|
|
4
|
-
const prevStyle = el.style.boxShadow
|
|
5
|
-
el.style.boxShadow = style
|
|
6
|
-
setTimeout(() => el.style.boxShadow = prevStyle, 2000)
|
|
7
|
-
}
|
|
3
|
+
const style = '0px 0px 4px 3px rgba(255, 0, 0, 0.7)'
|
|
4
|
+
const prevStyle = el.style.boxShadow
|
|
5
|
+
el.style.boxShadow = style
|
|
6
|
+
setTimeout(() => (el.style.boxShadow = prevStyle), 2000)
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
try {
|
|
10
10
|
// Puppeteer
|
|
11
|
-
context.evaluate(clientSideHighlightFn, element).catch(err => console.error(err))
|
|
11
|
+
context.evaluate(clientSideHighlightFn, element).catch(err => console.error(err))
|
|
12
12
|
} catch (e) {
|
|
13
13
|
// WebDriver
|
|
14
14
|
try {
|
|
15
|
-
context.execute(clientSideHighlightFn, element)
|
|
15
|
+
context.execute(clientSideHighlightFn, element)
|
|
16
16
|
} catch (err) {
|
|
17
17
|
// ignore
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
function isElementClickable(element) {
|
|
2
2
|
if (!element.getBoundingClientRect || !element.scrollIntoView || !element.contains || !element.getClientRects || !document.elementFromPoint) {
|
|
3
|
-
return false
|
|
3
|
+
return false
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
const getOverlappingElement = (element, context = document) => {
|
|
7
|
-
const elemDimension = element.getBoundingClientRect()
|
|
8
|
-
const x = elemDimension.left +
|
|
9
|
-
const y = elemDimension.top +
|
|
7
|
+
const elemDimension = element.getBoundingClientRect()
|
|
8
|
+
const x = elemDimension.left + element.clientWidth / 2
|
|
9
|
+
const y = elemDimension.top + element.clientHeight / 2
|
|
10
10
|
|
|
11
|
-
return context.elementFromPoint(x, y)
|
|
12
|
-
}
|
|
11
|
+
return context.elementFromPoint(x, y)
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
const getOverlappingRects = (element, context = document) => {
|
|
15
|
-
const rects = element.getClientRects()
|
|
16
|
-
const rect = rects[0]
|
|
17
|
-
const x = rect.left +
|
|
18
|
-
const y = rect.top +
|
|
15
|
+
const rects = element.getClientRects()
|
|
16
|
+
const rect = rects[0]
|
|
17
|
+
const x = rect.left + rect.width / 2
|
|
18
|
+
const y = rect.top + rect.height / 2
|
|
19
19
|
|
|
20
|
-
return context.elementFromPoint(x, y)
|
|
21
|
-
}
|
|
20
|
+
return context.elementFromPoint(x, y)
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
const getOverlappingElements = (element, context) => {
|
|
24
|
-
return [getOverlappingElement(element, context), getOverlappingRects(element, context)]
|
|
25
|
-
}
|
|
24
|
+
return [getOverlappingElement(element, context), getOverlappingRects(element, context)]
|
|
25
|
+
}
|
|
26
26
|
|
|
27
27
|
const isOverlappingElementMatch = (elementsFromPoint, element) => {
|
|
28
28
|
if (elementsFromPoint.some(elementFromPoint => elementFromPoint === element || element.contains(elementFromPoint))) {
|
|
29
|
-
return true
|
|
29
|
+
return true
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
let elementsWithShadowRoot = [...new Set(elementsFromPoint)]
|
|
33
|
-
elementsWithShadowRoot = elementsWithShadowRoot.filter(elem => elem && elem.shadowRoot && elem.shadowRoot.elementFromPoint)
|
|
32
|
+
let elementsWithShadowRoot = [...new Set(elementsFromPoint)]
|
|
33
|
+
elementsWithShadowRoot = elementsWithShadowRoot.filter(elem => elem && elem.shadowRoot && elem.shadowRoot.elementFromPoint)
|
|
34
34
|
|
|
35
|
-
let shadowElementsFromPoint = []
|
|
35
|
+
let shadowElementsFromPoint = []
|
|
36
36
|
for (const shadowElement of elementsWithShadowRoot) {
|
|
37
|
-
shadowElementsFromPoint.push(...getOverlappingElements(element, shadowElement.shadowRoot))
|
|
37
|
+
shadowElementsFromPoint.push(...getOverlappingElements(element, shadowElement.shadowRoot))
|
|
38
38
|
}
|
|
39
|
-
shadowElementsFromPoint = [...new Set(shadowElementsFromPoint)]
|
|
40
|
-
shadowElementsFromPoint = shadowElementsFromPoint.filter(element => !elementsFromPoint.includes(element))
|
|
39
|
+
shadowElementsFromPoint = [...new Set(shadowElementsFromPoint)]
|
|
40
|
+
shadowElementsFromPoint = shadowElementsFromPoint.filter(element => !elementsFromPoint.includes(element))
|
|
41
41
|
|
|
42
42
|
if (shadowElementsFromPoint.length === 0) {
|
|
43
|
-
return false
|
|
43
|
+
return false
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
return isOverlappingElementMatch(shadowElementsFromPoint, element)
|
|
47
|
-
}
|
|
46
|
+
return isOverlappingElementMatch(shadowElementsFromPoint, element)
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
const isElementInViewport =
|
|
50
|
-
const rect = element.getBoundingClientRect()
|
|
49
|
+
const isElementInViewport = element => {
|
|
50
|
+
const rect = element.getBoundingClientRect()
|
|
51
51
|
|
|
52
|
-
const windowHeight =
|
|
53
|
-
const windowWidth =
|
|
52
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight
|
|
53
|
+
const windowWidth = window.innerWidth || document.documentElement.clientWidth
|
|
54
54
|
|
|
55
|
-
const vertInView =
|
|
56
|
-
const horInView =
|
|
55
|
+
const vertInView = rect.top <= windowHeight && rect.top + rect.height > 0
|
|
56
|
+
const horInView = rect.left <= windowWidth && rect.left + rect.width > 0
|
|
57
57
|
|
|
58
|
-
return
|
|
59
|
-
}
|
|
58
|
+
return vertInView && horInView
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
return element.disabled !== true && isElementInViewport(element) && isOverlappingElementMatch(getOverlappingElements(element), element)
|
|
61
|
+
return element.disabled !== true && isElementInViewport(element) && isOverlappingElementMatch(getOverlappingElements(element), element)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
export default isElementClickable
|
package/lib/helper.js
CHANGED
package/lib/history.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const output = require('./output');
|
|
1
|
+
import colors from 'chalk'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import output from './output.js'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* REPL history records REPL commands and stores them in
|
|
@@ -11,42 +10,46 @@ const output = require('./output');
|
|
|
11
10
|
class ReplHistory {
|
|
12
11
|
constructor() {
|
|
13
12
|
if (global.output_dir) {
|
|
14
|
-
this.historyFile = path.join(global.output_dir, 'cli-history')
|
|
13
|
+
this.historyFile = path.join(global.output_dir, 'cli-history')
|
|
15
14
|
}
|
|
16
|
-
this.commands = []
|
|
15
|
+
this.commands = []
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
push(cmd) {
|
|
20
|
-
this.commands.push(cmd)
|
|
19
|
+
this.commands.push(cmd)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
pop() {
|
|
24
|
-
this.commands.pop()
|
|
23
|
+
this.commands.pop()
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
load() {
|
|
28
|
-
if (!this.historyFile) return
|
|
27
|
+
if (!this.historyFile) return
|
|
29
28
|
if (!fs.existsSync(this.historyFile)) {
|
|
30
|
-
return
|
|
29
|
+
return
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
const history = fs.readFileSync(this.historyFile, 'utf-8')
|
|
34
|
-
return history
|
|
32
|
+
const history = fs.readFileSync(this.historyFile, 'utf-8')
|
|
33
|
+
return history
|
|
34
|
+
.split('\n')
|
|
35
|
+
.reverse()
|
|
36
|
+
.filter(line => line.startsWith('I.'))
|
|
37
|
+
.map(line => line.slice(2))
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
save() {
|
|
38
|
-
if (!this.historyFile) return
|
|
41
|
+
if (!this.historyFile) return
|
|
39
42
|
if (this.commands.length === 0) {
|
|
40
|
-
return
|
|
43
|
+
return
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
const commandSnippet = `\n\n<<< Recorded commands on ${new Date()}\n${this.commands.join('\n')}
|
|
44
|
-
fs.appendFileSync(this.historyFile, commandSnippet)
|
|
46
|
+
const commandSnippet = `\n\n<<< Recorded commands on ${new Date()}\n${this.commands.join('\n')}`
|
|
47
|
+
fs.appendFileSync(this.historyFile, commandSnippet)
|
|
45
48
|
|
|
46
|
-
output.print(colors.yellow(` Commands have been saved to ${this.historyFile}`))
|
|
49
|
+
output.print(colors.yellow(` Commands have been saved to ${this.historyFile}`))
|
|
47
50
|
|
|
48
|
-
this.commands = []
|
|
51
|
+
this.commands = []
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
export default new ReplHistory()
|
package/lib/hooks.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { isFunction, isAsyncFunction } from './utils.js'
|
|
2
|
+
import output from './output.js'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
if (!hook) return
|
|
4
|
+
export default async function (hook, stage) {
|
|
5
|
+
if (!hook) return
|
|
6
6
|
if (!isFunction(hook)) {
|
|
7
|
-
throw new Error('CodeceptJS 3 allows bootstrap/teardown hooks only as async functions. More info: https://bit.ly/codecept3Up')
|
|
7
|
+
throw new Error('CodeceptJS 3 allows bootstrap/teardown hooks only as async functions. More info: https://bit.ly/codecept3Up')
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
if (stage) output.log(`started ${stage} hook`)
|
|
10
|
+
if (stage) output.log(`started ${stage} hook`)
|
|
11
11
|
if (isAsyncFunction(hook)) {
|
|
12
|
-
await hook()
|
|
12
|
+
await hook()
|
|
13
13
|
} else {
|
|
14
|
-
hook()
|
|
14
|
+
hook()
|
|
15
15
|
}
|
|
16
|
-
if (stage) output.log(`finished ${stage} hook`)
|
|
17
|
-
}
|
|
16
|
+
if (stage) output.log(`finished ${stage} hook`)
|
|
17
|
+
}
|