@testim/testim-cli 3.247.0 → 3.248.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testim/testim-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.248.0",
|
|
4
4
|
"description": "Command line interface for running Testing on your CI",
|
|
5
5
|
"author": "Oren Rubin",
|
|
6
6
|
"contributors": [{
|
|
@@ -17,15 +17,11 @@
|
|
|
17
17
|
"@types/node": "10.17.24",
|
|
18
18
|
"@types/selenium-webdriver": "4.0.9",
|
|
19
19
|
"bundle-deps": "1.0.0",
|
|
20
|
-
"chai": "4.3.6",
|
|
21
|
-
"chai-as-promised": "7.1.1",
|
|
22
20
|
"gulp": "4.0.2",
|
|
23
21
|
"gulp-cli": "2.3.0",
|
|
24
22
|
"gulp-json-editor": "2.5.6",
|
|
25
23
|
"gulp-preprocess": "3.0.3",
|
|
26
24
|
"merge-stream": "2.0.0",
|
|
27
|
-
"mocha": "9.2.0",
|
|
28
|
-
"nyc": "15.1.0",
|
|
29
25
|
"proxyquire": "2.1.3",
|
|
30
26
|
"request": "2.88.2",
|
|
31
27
|
"sinon": "9.0.2",
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */ // This code only runs in Safari, not in IE.
|
|
1
2
|
module.exports = function (locatedElement, dispatchEventOnSelectElement) {
|
|
2
3
|
function closest(el, selectors) {
|
|
4
|
+
var originalMatches = Element.prototype.matches;
|
|
5
|
+
/* eslint-disable-next-line no-proto, no-undef */ // Some customers override the native Element prototype, so we need to create a new one if they messed it up.
|
|
6
|
+
var matches = originalMatches && isNativeFunction(originalMatches) ? originalMatches : document.createElement(el.tagName).__proto__.matches;
|
|
3
7
|
do {
|
|
4
|
-
if (
|
|
8
|
+
if (matches.call(el, selectors)) return el;
|
|
5
9
|
el = el.parentElement || el.parentNode;
|
|
6
10
|
} while (el !== null && el.nodeType === 1);
|
|
7
11
|
return null;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
try {
|
|
15
|
+
/* eslint-disable-next-line no-undef */ // This code depends on pre-injecting this function as well.
|
|
11
16
|
var optionEl = getLocatedElement(locatedElement);
|
|
12
17
|
if (!optionEl) {
|
|
13
18
|
return { success: false, status: 'failed', result: 'option element not found' };
|
|
@@ -2,42 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
const StepAction = require('./stepAction');
|
|
4
4
|
const { extractElementId } = require('../../utils');
|
|
5
|
-
const { codeSnippets } = require('../../commons/getSessionPlayerRequire');
|
|
5
|
+
const { codeSnippets, utils } = require('../../commons/getSessionPlayerRequire');
|
|
6
6
|
const selectOption = require('./scripts/selectOption');
|
|
7
7
|
const featureFlags = require('../../commons/featureFlags');
|
|
8
8
|
|
|
9
9
|
class SelectOptionStepAction extends StepAction {
|
|
10
|
-
performAction() {
|
|
10
|
+
async performAction() {
|
|
11
11
|
const target = this.context.data[this.step.targetId || 'targetId'];
|
|
12
12
|
const { seleniumElement, locatedElement } = target;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
.then(browserAndOS => {
|
|
16
|
-
const browserMajor = browserAndOS.browserMajor;
|
|
17
|
-
const isSafari = this.driver.isSafari();
|
|
18
|
-
const isShadowed = Boolean(this.step.element && this.step.element.isShadowed);
|
|
14
|
+
const browserAndOS = await this.driver.getBrowserAndOS();
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const browserMajor = browserAndOS.browserMajor;
|
|
17
|
+
const isSafari = this.driver.isSafari();
|
|
18
|
+
const isShadowed = Boolean(this.step.element && this.step.element.isShadowed);
|
|
19
|
+
|
|
20
|
+
// TODO: Remove the special handling for safari < 12 after we upgrade our grid to safari 13.
|
|
21
|
+
// force use js code when element is shadow dom
|
|
22
|
+
if (!isSafari || (isSafari && browserMajor >= 13 && !isShadowed)) {
|
|
23
|
+
try {
|
|
24
|
+
const res = await this.driver.elementIdClick(extractElementId(seleniumElement));
|
|
25
|
+
return res;
|
|
26
|
+
} catch (err) {
|
|
27
|
+
// If customer overrides the native Element prototype, this click will fail for this reason. in such a case, fallback to use js code.
|
|
28
|
+
if (!err.message.includes('Cannot check the displayedness of a non-Element argument')) {
|
|
29
|
+
throw err;
|
|
24
30
|
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const safariSelectOptionDispatchEventOnSelectElement = featureFlags.flags.safariSelectOptionDispatchEventOnSelectElement.isEnabled();
|
|
35
|
+
const selectOptionCode = `
|
|
36
|
+
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
37
|
+
var isNativeFunction = ${utils.isNativeFunction.toString()};
|
|
38
|
+
var selectOption = ${selectOption.toString()};
|
|
39
|
+
return selectOption.apply(null, arguments);
|
|
40
|
+
`;
|
|
25
41
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
return this.driver.executeJSWithArray(selectOptionCode, [locatedElement, safariSelectOptionDispatchEventOnSelectElement])
|
|
34
|
-
.then(result => {
|
|
35
|
-
if (result.value && result.value.success) {
|
|
36
|
-
return { success: true };
|
|
37
|
-
}
|
|
38
|
-
return { success: false };
|
|
39
|
-
});
|
|
40
|
-
});
|
|
42
|
+
const result = await this.driver.executeJSWithArray(selectOptionCode, [locatedElement, safariSelectOptionDispatchEventOnSelectElement]);
|
|
43
|
+
if (result.value && result.value.success) {
|
|
44
|
+
return { success: true };
|
|
45
|
+
}
|
|
46
|
+
return { success: false };
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -66,7 +66,7 @@ class WorkerSelenium extends BaseWorker {
|
|
|
66
66
|
await this.windowUtils.validatePageIsAvailable();
|
|
67
67
|
perf.log('in WorkerSelenium after navigate');
|
|
68
68
|
} catch (err) {
|
|
69
|
-
const firefoxPageNotAvailable = (err.message.startsWith('Malformed URL') || err.message.includes('Reached error page: about:neterror')) &&
|
|
69
|
+
const firefoxPageNotAvailable = err.message && (err.message.startsWith('Malformed URL') || err.message.includes('Reached error page: about:neterror')) &&
|
|
70
70
|
browserValue === 'firefox';
|
|
71
71
|
|
|
72
72
|
const invalidURL = (err.message && err.message === 'invalid argument');
|