@applitools/core-universal 1.0.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/CHANGELOG.md +66 -0
- package/dist/cli/cli.js +160 -0
- package/dist/index.js +18 -0
- package/dist/universal/core-server-process.js +31 -0
- package/dist/universal/core-server.js +216 -0
- package/dist/universal/history.js +90 -0
- package/dist/universal/refer.js +67 -0
- package/dist/universal/spec-driver.js +189 -0
- package/dist/universal/types.js +2 -0
- package/dist/universal/ws-server.js +66 -0
- package/package.json +76 -0
- package/types/cli/cli.d.ts +2 -0
- package/types/index.d.ts +2 -0
- package/types/universal/core-server-process.d.ts +9 -0
- package/types/universal/core-server.d.ts +18 -0
- package/types/universal/history.d.ts +2 -0
- package/types/universal/refer.d.ts +8 -0
- package/types/universal/spec-driver.d.ts +15 -0
- package/types/universal/types.d.ts +205 -0
- package/types/universal/ws-server.d.ts +15 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.0](https://github.com/Applitools-Dev/sdk/compare/js/core-universal@0.0.0...js/core-universal@1.0.0) (2026-03-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* extract universal server from @applitools/core into new package
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* extract universal server from @applitools/core into new package ([2a7257e](https://github.com/Applitools-Dev/sdk/commit/2a7257e638647ebcd7d1040d2785bc9cac458295))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
* @applitools/dom-snapshot bumped to 4.15.9
|
|
18
|
+
#### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* expand CSS vars in CSSOM-injected style tags | FLD-4106 ([0821f9e](https://github.com/Applitools-Dev/sdk/commit/0821f9e7f6b20ec05387a8523dc0254bac22591b))
|
|
21
|
+
* @applitools/image bumped to 1.2.7
|
|
22
|
+
#### Performance Improvements
|
|
23
|
+
|
|
24
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
25
|
+
* @applitools/screenshoter bumped to 3.12.14
|
|
26
|
+
#### Performance Improvements
|
|
27
|
+
|
|
28
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
* @applitools/nml-client bumped to 1.11.17
|
|
33
|
+
#### Performance Improvements
|
|
34
|
+
|
|
35
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
* @applitools/ufg-client bumped to 1.19.2
|
|
40
|
+
#### Performance Improvements
|
|
41
|
+
|
|
42
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
* @applitools/core-base bumped to 1.31.3
|
|
47
|
+
#### Performance Improvements
|
|
48
|
+
|
|
49
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
* @applitools/ec-client bumped to 1.12.19
|
|
54
|
+
#### Performance Improvements
|
|
55
|
+
|
|
56
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
* @applitools/core bumped to 4.56.3
|
|
61
|
+
#### Performance Improvements
|
|
62
|
+
|
|
63
|
+
* use sharp to accelerate png performance in all js packages ([#3547](https://github.com/Applitools-Dev/sdk/issues/3547)) ([6e3c7b9](https://github.com/Applitools-Dev/sdk/commit/6e3c7b9e34815f470032ece52a161001592ad1b1))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
/* eslint no-console: off */
|
|
31
|
+
const core_server_1 = require("../universal/core-server");
|
|
32
|
+
const core_server_process_1 = require("../universal/core-server-process");
|
|
33
|
+
const core_1 = require("@applitools/core");
|
|
34
|
+
const { analyzeLogs, parseLogs, structureLogs } = core_1.logs;
|
|
35
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
36
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
37
|
+
const fs_1 = __importDefault(require("fs"));
|
|
38
|
+
void yargs_1.default
|
|
39
|
+
.example([
|
|
40
|
+
['eyes universal', 'Run Eyes Universal server on default port (21077)'],
|
|
41
|
+
['eyes universal --fork', 'Run Eyes Universal server in a forked process'],
|
|
42
|
+
['eyes universal --port 8080', 'Run Eyes Universal server on port 8080'],
|
|
43
|
+
['eyes universal --no-singleton', 'Run Eyes Universal server on a non-singleton mode'],
|
|
44
|
+
['eyes universal --shutdown-mode stdin', 'Run Eyes Universal server which will close once stdin stream will end'],
|
|
45
|
+
['eyes check-network', ''],
|
|
46
|
+
])
|
|
47
|
+
.version(JSON.parse(fs_1.default.readFileSync(require.resolve('../../package.json'), 'utf-8')).version)
|
|
48
|
+
.command({
|
|
49
|
+
command: 'universal',
|
|
50
|
+
builder: yargs => yargs.options({
|
|
51
|
+
port: {
|
|
52
|
+
description: 'run server on a specific port.',
|
|
53
|
+
type: 'number',
|
|
54
|
+
default: 21077,
|
|
55
|
+
},
|
|
56
|
+
singleton: {
|
|
57
|
+
description: 'runs server on a singleton mode. It will prevent the server to start in case the same server is already started.',
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
default: true,
|
|
60
|
+
},
|
|
61
|
+
fork: {
|
|
62
|
+
description: 'runs server in a forked process.',
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
default: false,
|
|
65
|
+
},
|
|
66
|
+
debug: {
|
|
67
|
+
description: 'runs server in a debug mode.',
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
default: false,
|
|
70
|
+
},
|
|
71
|
+
'port-resolution-mode': {
|
|
72
|
+
describe: 'preferred algorithm to solve port collisions.\n"lazy" mode will not try find free port.\n"random" mode will run on a random port.\n"next" mode will run on next free port after the given one.',
|
|
73
|
+
alias: 'port-resolution',
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: 'next',
|
|
76
|
+
},
|
|
77
|
+
'shutdown-mode': {
|
|
78
|
+
describe: 'preferred algorithm to automatically kill the process.\n"lazy" mode will end the process once the idle timeout ran out after the last client is disconnected from the server.\n"stdin" mode will end the process once its stdin stream got to its end.',
|
|
79
|
+
alias: 'shutdown',
|
|
80
|
+
type: 'string',
|
|
81
|
+
default: 'lazy',
|
|
82
|
+
},
|
|
83
|
+
'idle-timeout': {
|
|
84
|
+
description: 'time in minutes for server to stay responsible in case of idle.',
|
|
85
|
+
type: 'number',
|
|
86
|
+
default: 15,
|
|
87
|
+
coerce: value => value * 60 * 1000,
|
|
88
|
+
},
|
|
89
|
+
cert: {
|
|
90
|
+
description: 'path to the certificate file.',
|
|
91
|
+
alias: 'cert-path',
|
|
92
|
+
type: 'string',
|
|
93
|
+
implies: 'key',
|
|
94
|
+
},
|
|
95
|
+
key: {
|
|
96
|
+
description: 'path to the key file.',
|
|
97
|
+
alias: 'key-path',
|
|
98
|
+
type: 'string',
|
|
99
|
+
implies: 'cert',
|
|
100
|
+
},
|
|
101
|
+
config: {
|
|
102
|
+
description: 'json string to use instead of cli arguments',
|
|
103
|
+
type: 'string',
|
|
104
|
+
coerce: JSON.parse,
|
|
105
|
+
},
|
|
106
|
+
maskLog: {
|
|
107
|
+
description: 'mask sensitive information in the log',
|
|
108
|
+
type: 'boolean',
|
|
109
|
+
default: false,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
handler: async (args) => {
|
|
113
|
+
if (args.fork) {
|
|
114
|
+
const { port } = await (0, core_server_process_1.makeCoreServerProcess)({ ...args, fork: false, isProcess: true });
|
|
115
|
+
// eslint-disable-next-line no-console
|
|
116
|
+
console.log(port); // NOTE: this is a part of the generic protocol
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
void (0, core_server_1.makeCoreServer)({ ...args, ...args.config, isProcess: true });
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
.command({
|
|
124
|
+
command: 'logs [input]',
|
|
125
|
+
builder: yargs => yargs.options({
|
|
126
|
+
input: {
|
|
127
|
+
description: 'log input to process',
|
|
128
|
+
type: 'string',
|
|
129
|
+
},
|
|
130
|
+
structure: {
|
|
131
|
+
description: 'group logs by tag names',
|
|
132
|
+
type: 'boolean',
|
|
133
|
+
},
|
|
134
|
+
analyze: {
|
|
135
|
+
description: 'group logs by tag names',
|
|
136
|
+
type: 'boolean',
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
handler: async (args) => {
|
|
140
|
+
var _a;
|
|
141
|
+
const input = (_a = args.input) !== null && _a !== void 0 ? _a : (await utils.streams.toBuffer(process.stdin)).toString('utf8');
|
|
142
|
+
const logs = parseLogs(input);
|
|
143
|
+
if (args.analyze) {
|
|
144
|
+
console.log(JSON.stringify(analyzeLogs(structureLogs(logs)), null, 2));
|
|
145
|
+
}
|
|
146
|
+
else if (args.structure) {
|
|
147
|
+
console.log(JSON.stringify(structureLogs(logs), null, 2));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
console.log(JSON.stringify(logs, null, 2));
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
})
|
|
154
|
+
.command({
|
|
155
|
+
command: 'check-network',
|
|
156
|
+
handler: async () => {
|
|
157
|
+
await (0, core_1.checkNetwork)();
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
.wrap(yargs_1.default.terminalWidth()).argv;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./universal/core-server"), exports);
|
|
18
|
+
__exportStar(require("./universal/core-server-process"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeCoreServerProcess = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function makeCoreServerProcess(options) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const server = (0, child_process_1.fork)(path_1.default.resolve(__dirname, '../../dist/cli/cli.js'), ['universal', `--config=${JSON.stringify(options)}`], {
|
|
12
|
+
stdio: [options.shutdownMode === 'stdin' ? 'inherit' : 'ignore', 'ignore', 'ignore', 'ipc'],
|
|
13
|
+
...options.forkOptions,
|
|
14
|
+
});
|
|
15
|
+
const timeout = setTimeout(() => {
|
|
16
|
+
reject(new Error(`Server didn't respond for 10s after being started`));
|
|
17
|
+
server.kill();
|
|
18
|
+
}, 60000);
|
|
19
|
+
server.on('error', reject);
|
|
20
|
+
server.once('message', ({ name, payload }) => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (name === 'port') {
|
|
23
|
+
resolve({ port: payload.port, close: () => server.kill() });
|
|
24
|
+
clearTimeout(timeout);
|
|
25
|
+
(_a = server.channel) === null || _a === void 0 ? void 0 : _a.unref();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
server.unref();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.makeCoreServerProcess = makeCoreServerProcess;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makeCoreServer = void 0;
|
|
7
|
+
const socket_1 = require("@applitools/socket");
|
|
8
|
+
const spec_driver_webdriver_1 = __importDefault(require("@applitools/spec-driver-webdriver"));
|
|
9
|
+
const spec_driver_1 = require("./spec-driver");
|
|
10
|
+
const ws_server_1 = require("./ws-server");
|
|
11
|
+
const logger_1 = require("@applitools/logger");
|
|
12
|
+
const core_1 = require("@applitools/core");
|
|
13
|
+
const refer_1 = require("./refer");
|
|
14
|
+
const history_1 = require("./history");
|
|
15
|
+
const os_1 = __importDefault(require("os"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
async function makeCoreServer({ environment: defaultEnvironment, agentIdPrefix = `eyes-universal/${require('../../package.json').version}`, debug = false, shutdownMode = 'lazy', idleTimeout = 900000, // 15min
|
|
18
|
+
printStdout = false, isProcess = false, maskLog = false, logger = undefined, ...handlerOptions } = {}) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const logDirname = (_a = process.env.APPLITOOLS_LOG_DIR) !== null && _a !== void 0 ? _a : path_1.default.resolve(os_1.default.tmpdir(), `applitools-logs`);
|
|
21
|
+
const baseLogger = logger !== null && logger !== void 0 ? logger : (0, logger_1.makeLogger)({
|
|
22
|
+
handler: { type: 'rolling file', name: 'universal', dirname: logDirname },
|
|
23
|
+
level: 'info',
|
|
24
|
+
format: { label: 'core-universal', colors: false },
|
|
25
|
+
maskLog,
|
|
26
|
+
});
|
|
27
|
+
baseLogger.log('Core universal is going to be initialized with options', {
|
|
28
|
+
debug,
|
|
29
|
+
shutdownMode,
|
|
30
|
+
idleTimeout,
|
|
31
|
+
printStdout,
|
|
32
|
+
defaultEnvironment,
|
|
33
|
+
...handlerOptions,
|
|
34
|
+
});
|
|
35
|
+
const { server, port } = await (0, ws_server_1.makeServer)({ ...handlerOptions, debug }, baseLogger);
|
|
36
|
+
if (isProcess) {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.log(port.toString()); // NOTE: this is a part of the generic protocol
|
|
39
|
+
(_b = process.send) === null || _b === void 0 ? void 0 : _b.call(process, { name: 'port', payload: { port } }); // NOTE: this is a part of the js specific protocol
|
|
40
|
+
}
|
|
41
|
+
if (!server) {
|
|
42
|
+
baseLogger.console.log(`You are trying to spawn a duplicated server, use the server on port ${port} instead`);
|
|
43
|
+
return { port };
|
|
44
|
+
}
|
|
45
|
+
if (!printStdout)
|
|
46
|
+
process.stdout.write = () => true; // NOTE: prevent any write to stdout
|
|
47
|
+
baseLogger.log('Core universal is started on port', port);
|
|
48
|
+
let idle;
|
|
49
|
+
let serverClosed = false;
|
|
50
|
+
if (shutdownMode === 'stdin') {
|
|
51
|
+
process.stdin.resume();
|
|
52
|
+
process.stdin.on('end', () => {
|
|
53
|
+
server.close();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (shutdownMode === 'lazy') {
|
|
57
|
+
if (idleTimeout) {
|
|
58
|
+
idle = setTimeout(() => server.close(), idleTimeout);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
server.on('close', () => {
|
|
62
|
+
clearTimeout(idle);
|
|
63
|
+
serverClosed = true;
|
|
64
|
+
});
|
|
65
|
+
server.on('connection', async (client) => {
|
|
66
|
+
const refer = (0, refer_1.makeRefer)();
|
|
67
|
+
const socket = (0, socket_1.makeSocket)(client, {
|
|
68
|
+
transport: 'ws',
|
|
69
|
+
logger: baseLogger,
|
|
70
|
+
});
|
|
71
|
+
const getHistory = debug ? (0, history_1.withHistory)(socket) : () => null;
|
|
72
|
+
if (shutdownMode === 'lazy' && idleTimeout) {
|
|
73
|
+
clearTimeout(idle);
|
|
74
|
+
socket.on('close', () => {
|
|
75
|
+
if (server.clients.size > 0 || serverClosed)
|
|
76
|
+
return;
|
|
77
|
+
idle = setTimeout(() => server.close(), idleTimeout);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const logger = baseLogger.extend({
|
|
81
|
+
console: {
|
|
82
|
+
log: (message) => socket.emit('Logger.log', { level: 'info', message }),
|
|
83
|
+
warn: (message) => socket.emit('Logger.log', { level: 'warn', message }),
|
|
84
|
+
error: (message) => socket.emit('Logger.log', { level: 'error', message }),
|
|
85
|
+
fatal: (message) => socket.emit('Logger.log', { level: 'fatal', message }),
|
|
86
|
+
},
|
|
87
|
+
maskLog,
|
|
88
|
+
});
|
|
89
|
+
logger.console.log(`Logs saved in: ${logDirname}`);
|
|
90
|
+
const corePromise = socket.wait('Core.makeCore', ({ spec, agentId, environment, cwd }) => {
|
|
91
|
+
return (0, core_1.makeCore)({
|
|
92
|
+
spec: spec === 'webdriver' ? spec_driver_webdriver_1.default : (0, spec_driver_1.makeSpec)({ socket, spec }),
|
|
93
|
+
agentId: `${agentIdPrefix}/${agentId}`,
|
|
94
|
+
cwd,
|
|
95
|
+
environment: {
|
|
96
|
+
...defaultEnvironment,
|
|
97
|
+
...environment,
|
|
98
|
+
versions: { ...defaultEnvironment === null || defaultEnvironment === void 0 ? void 0 : defaultEnvironment.versions, ...environment === null || environment === void 0 ? void 0 : environment.versions },
|
|
99
|
+
universal: true,
|
|
100
|
+
},
|
|
101
|
+
logger,
|
|
102
|
+
maskLog,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
socket.command('Core.getAccountInfo', async (options) => {
|
|
106
|
+
const core = await corePromise;
|
|
107
|
+
return core.getAccountInfo(options);
|
|
108
|
+
});
|
|
109
|
+
socket.command('Core.getViewportSize', async (options) => {
|
|
110
|
+
var _a;
|
|
111
|
+
const core = await corePromise;
|
|
112
|
+
return (_a = core.getViewportSize) === null || _a === void 0 ? void 0 : _a.call(core, options);
|
|
113
|
+
});
|
|
114
|
+
socket.command('Core.setViewportSize', async (options) => {
|
|
115
|
+
var _a;
|
|
116
|
+
const core = await corePromise;
|
|
117
|
+
return (_a = core.setViewportSize) === null || _a === void 0 ? void 0 : _a.call(core, options);
|
|
118
|
+
});
|
|
119
|
+
socket.command('Core.closeBatch', async (options) => {
|
|
120
|
+
const core = await corePromise;
|
|
121
|
+
return core.closeBatch(options);
|
|
122
|
+
});
|
|
123
|
+
socket.command('Core.deleteTest', async (options) => {
|
|
124
|
+
const core = await corePromise;
|
|
125
|
+
return core.deleteTest(options);
|
|
126
|
+
});
|
|
127
|
+
socket.command('Core.logEvent', async ({ settings }) => {
|
|
128
|
+
const core = await corePromise;
|
|
129
|
+
return core.logEvent({ settings });
|
|
130
|
+
});
|
|
131
|
+
socket.command('Core.locate', async (options) => {
|
|
132
|
+
const core = await corePromise;
|
|
133
|
+
return core.locate(options);
|
|
134
|
+
});
|
|
135
|
+
socket.command('Core.locateText', async (options) => {
|
|
136
|
+
const core = await corePromise;
|
|
137
|
+
return core.locateText(options);
|
|
138
|
+
});
|
|
139
|
+
socket.command('Core.extractText', async (options) => {
|
|
140
|
+
const core = await corePromise;
|
|
141
|
+
return core.extractText(options);
|
|
142
|
+
});
|
|
143
|
+
socket.command('Core.getECClient', async (options) => {
|
|
144
|
+
const core = await corePromise;
|
|
145
|
+
const client = await core.getECClient(options);
|
|
146
|
+
return { url: client.url };
|
|
147
|
+
});
|
|
148
|
+
socket.command('Core.makeManager', async (options) => {
|
|
149
|
+
var _a;
|
|
150
|
+
const core = await corePromise;
|
|
151
|
+
if ((_a = options.settings) === null || _a === void 0 ? void 0 : _a.agentId) {
|
|
152
|
+
options.settings.agentId = `${agentIdPrefix}/${options.settings.agentId}`;
|
|
153
|
+
}
|
|
154
|
+
return refer.ref(await core.makeManager(options));
|
|
155
|
+
});
|
|
156
|
+
socket.command('EyesManager.openEyes', async ({ manager, ...options }) => {
|
|
157
|
+
var _a;
|
|
158
|
+
const eyes = await ((_a = refer.deref(manager)) === null || _a === void 0 ? void 0 : _a.openEyes(options));
|
|
159
|
+
const eyesRef = refer.ref(eyes, manager);
|
|
160
|
+
return eyesRef;
|
|
161
|
+
});
|
|
162
|
+
socket.command('EyesManager.getResults', async ({ manager, ...options }) => {
|
|
163
|
+
var _a;
|
|
164
|
+
return (_a = refer.deref(manager)) === null || _a === void 0 ? void 0 : _a.getResults(options);
|
|
165
|
+
});
|
|
166
|
+
socket.command('Eyes.check', async ({ eyes, ...options }) => {
|
|
167
|
+
var _a;
|
|
168
|
+
return (_a = refer.deref(eyes)) === null || _a === void 0 ? void 0 : _a.check(options);
|
|
169
|
+
});
|
|
170
|
+
socket.command('Eyes.checkAndClose', async ({ eyes, ...options }) => {
|
|
171
|
+
var _a;
|
|
172
|
+
return (_a = refer.deref(eyes)) === null || _a === void 0 ? void 0 : _a.checkAndClose(options);
|
|
173
|
+
});
|
|
174
|
+
socket.command('Eyes.close', async ({ eyes, ...options }) => {
|
|
175
|
+
var _a;
|
|
176
|
+
return (_a = refer.deref(eyes)) === null || _a === void 0 ? void 0 : _a.close(options);
|
|
177
|
+
});
|
|
178
|
+
socket.command('Eyes.abort', async ({ eyes, ...options }) => {
|
|
179
|
+
var _a;
|
|
180
|
+
return (_a = refer.deref(eyes)) === null || _a === void 0 ? void 0 : _a.abort(options);
|
|
181
|
+
});
|
|
182
|
+
socket.command('Eyes.getResults', async ({ eyes, ...options }) => {
|
|
183
|
+
var _a;
|
|
184
|
+
return (_a = refer.deref(eyes)) === null || _a === void 0 ? void 0 : _a.getResults(options);
|
|
185
|
+
});
|
|
186
|
+
socket.command('Debug.getHistory', async () => {
|
|
187
|
+
return {
|
|
188
|
+
...getHistory(),
|
|
189
|
+
initialArgs: {
|
|
190
|
+
environment: defaultEnvironment,
|
|
191
|
+
agentIdPrefix,
|
|
192
|
+
debug,
|
|
193
|
+
shutdownMode,
|
|
194
|
+
idleTimeout,
|
|
195
|
+
printStdout,
|
|
196
|
+
isProcess,
|
|
197
|
+
maskLog,
|
|
198
|
+
...handlerOptions,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
process.on('unhandledRejection', error => {
|
|
204
|
+
baseLogger.error('Unhandled promise rejection', error);
|
|
205
|
+
/* eslint-disable-next-line no-console */
|
|
206
|
+
console.error('Unhandled promise rejection', error);
|
|
207
|
+
});
|
|
208
|
+
process.on('uncaughtException', error => {
|
|
209
|
+
baseLogger.error('Uncaught error terminating the process', error);
|
|
210
|
+
/* eslint-disable-next-line no-console */
|
|
211
|
+
console.error('Uncaught error terminating the process', error);
|
|
212
|
+
process.exit(1);
|
|
213
|
+
});
|
|
214
|
+
return { port, close: () => server.close() };
|
|
215
|
+
}
|
|
216
|
+
exports.makeCoreServer = makeCoreServer;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withHistory = void 0;
|
|
4
|
+
//TODO Design a better history tracker
|
|
5
|
+
function withHistory(socket) {
|
|
6
|
+
const history = {
|
|
7
|
+
managers: new Map(),
|
|
8
|
+
eyes: new Map(),
|
|
9
|
+
startedAt: new Date().toISOString(),
|
|
10
|
+
unknownEvents: [],
|
|
11
|
+
};
|
|
12
|
+
const originalCommand = socket.command;
|
|
13
|
+
socket.command = function command(name, fn) {
|
|
14
|
+
return originalCommand(name, async (payload) => {
|
|
15
|
+
let result, error;
|
|
16
|
+
try {
|
|
17
|
+
result = await fn(payload);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
error = err;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
if (name === 'Core.makeManager') {
|
|
26
|
+
const managerRef = result;
|
|
27
|
+
history.managers.set(extractRefId(managerRef), { ...payload, manager: result, eyes: [] });
|
|
28
|
+
}
|
|
29
|
+
else if (name.startsWith('EyesManager.')) {
|
|
30
|
+
const managerRef = payload.manager;
|
|
31
|
+
const managerHistory = history.managers.get(extractRefId(managerRef));
|
|
32
|
+
if (managerHistory) {
|
|
33
|
+
if (name === 'EyesManager.openEyes') {
|
|
34
|
+
if (error) {
|
|
35
|
+
managerHistory.eyes.push({ ...payload, error });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const eyesRef = result;
|
|
39
|
+
managerHistory.eyes.push(eyesRef);
|
|
40
|
+
history.eyes.set(extractRefId(eyesRef), { ...payload, eyes: eyesRef, commands: [] });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (name.startsWith('Eyes.')) {
|
|
46
|
+
const eyesRef = payload.eyes;
|
|
47
|
+
const eyesHistory = history.eyes.get(extractRefId(eyesRef));
|
|
48
|
+
if (eyesHistory) {
|
|
49
|
+
if (name === 'Eyes.check') {
|
|
50
|
+
const command = { name, ...payload };
|
|
51
|
+
if (error)
|
|
52
|
+
command.error = error;
|
|
53
|
+
else
|
|
54
|
+
command.result = result;
|
|
55
|
+
eyesHistory.commands.push(command);
|
|
56
|
+
}
|
|
57
|
+
else if (name === 'Eyes.close') {
|
|
58
|
+
eyesHistory.closed = true;
|
|
59
|
+
}
|
|
60
|
+
else if (name === 'Eyes.abort') {
|
|
61
|
+
eyesHistory.aborted = true;
|
|
62
|
+
}
|
|
63
|
+
else if (name === 'Eyes.getResults') {
|
|
64
|
+
eyesHistory.result = error !== null && error !== void 0 ? error : result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
history.unknownEvents.push({ name, payload });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return function getHistory() {
|
|
75
|
+
return {
|
|
76
|
+
managers: Array.from(history.managers.values(), managerMeta => ({
|
|
77
|
+
...managerMeta,
|
|
78
|
+
eyes: managerMeta.eyes.map(eyesRefOrError => {
|
|
79
|
+
return eyesRefOrError instanceof Error ? eyesRefOrError : history.eyes.get(extractRefId(eyesRefOrError));
|
|
80
|
+
}),
|
|
81
|
+
})),
|
|
82
|
+
startedAt: history.startedAt,
|
|
83
|
+
requestedAt: new Date().toISOString(),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
function extractRefId(ref) {
|
|
87
|
+
return ref['applitools-ref-id'];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.withHistory = withHistory;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.makeRefer = void 0;
|
|
27
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
const REF_ID = 'applitools-ref-id';
|
|
29
|
+
function makeRefer() {
|
|
30
|
+
const store = new Map();
|
|
31
|
+
const relation = new Map();
|
|
32
|
+
return { isRef, ref, deref, destroy };
|
|
33
|
+
function isRef(ref) {
|
|
34
|
+
return Boolean(ref[REF_ID]);
|
|
35
|
+
}
|
|
36
|
+
function ref(value, parentRef) {
|
|
37
|
+
const ref = utils.general.guid();
|
|
38
|
+
store.set(ref, value);
|
|
39
|
+
if (parentRef) {
|
|
40
|
+
let childRefs = relation.get(parentRef[REF_ID]);
|
|
41
|
+
if (!childRefs) {
|
|
42
|
+
childRefs = new Set();
|
|
43
|
+
relation.set(parentRef[REF_ID], childRefs);
|
|
44
|
+
}
|
|
45
|
+
childRefs.add({ [REF_ID]: ref });
|
|
46
|
+
}
|
|
47
|
+
return { [REF_ID]: ref };
|
|
48
|
+
}
|
|
49
|
+
function deref(ref) {
|
|
50
|
+
if (isRef(ref)) {
|
|
51
|
+
return store.get(ref[REF_ID]);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return ref;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function destroy(ref) {
|
|
58
|
+
if (!isRef(ref))
|
|
59
|
+
return;
|
|
60
|
+
const childRefs = relation.get(ref[REF_ID]);
|
|
61
|
+
if (childRefs) {
|
|
62
|
+
childRefs.forEach(childRef => destroy(childRef));
|
|
63
|
+
}
|
|
64
|
+
store.delete(ref[REF_ID]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.makeRefer = makeRefer;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.makeSpec = void 0;
|
|
27
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
function makeSpec({ socket, spec, }) {
|
|
29
|
+
const commands = {
|
|
30
|
+
isDriver(driver) {
|
|
31
|
+
return utils.types.has(driver, 'applitools-ref-id');
|
|
32
|
+
},
|
|
33
|
+
isContext(context) {
|
|
34
|
+
return utils.types.has(context, 'applitools-ref-id');
|
|
35
|
+
},
|
|
36
|
+
isElement(element) {
|
|
37
|
+
return utils.types.has(element, ['applitools-ref-id', 'type']) && element.type === 'element';
|
|
38
|
+
},
|
|
39
|
+
isSelector(selector) {
|
|
40
|
+
return ((utils.types.has(selector, ['applitools-ref-id', 'type']) && selector.type === 'selector') ||
|
|
41
|
+
utils.types.isString(selector) ||
|
|
42
|
+
(utils.types.isPlainObject(selector) &&
|
|
43
|
+
utils.types.has(selector, 'selector') &&
|
|
44
|
+
(utils.types.isString(selector.selector) || utils.types.has(selector, 'applitools-ref-id'))));
|
|
45
|
+
},
|
|
46
|
+
async isEqualElements(context, element1, element2) {
|
|
47
|
+
return socket.request('Driver.isEqualElements', { context, element1, element2 });
|
|
48
|
+
},
|
|
49
|
+
isStaleElementError(error) {
|
|
50
|
+
return error === null || error === void 0 ? void 0 : error.isStaleElementError;
|
|
51
|
+
},
|
|
52
|
+
extractContext(driver) {
|
|
53
|
+
return driver.context;
|
|
54
|
+
},
|
|
55
|
+
extractSelector(element) {
|
|
56
|
+
return element.selector;
|
|
57
|
+
},
|
|
58
|
+
async executeScript(context, script, arg) {
|
|
59
|
+
return socket.request('Driver.executeScript', { context, script: script.toString(), arg });
|
|
60
|
+
},
|
|
61
|
+
async findElement(context, selector, parent) {
|
|
62
|
+
return socket.request('Driver.findElement', { context, selector, parent });
|
|
63
|
+
},
|
|
64
|
+
async findElements(context, selector, parent) {
|
|
65
|
+
return socket.request('Driver.findElements', { context, selector, parent });
|
|
66
|
+
},
|
|
67
|
+
async waitForSelector(context, selector, parent, options) {
|
|
68
|
+
return socket.request('Driver.waitForSelector', { context, selector, parent, options });
|
|
69
|
+
},
|
|
70
|
+
async getElementText(context, element) {
|
|
71
|
+
return socket.request('Driver.getElementText', { context, element });
|
|
72
|
+
},
|
|
73
|
+
async setElementText(context, element, text) {
|
|
74
|
+
return socket.request('Driver.setElementText', { context, element, text });
|
|
75
|
+
},
|
|
76
|
+
async getElementRegion(context, element) {
|
|
77
|
+
return socket.request('Driver.getElementRegion', { context, element });
|
|
78
|
+
},
|
|
79
|
+
async getElementAttribute(context, element, attr) {
|
|
80
|
+
return socket.request('Driver.getElementAttribute', { context, element, attr });
|
|
81
|
+
},
|
|
82
|
+
async hover(context, element) {
|
|
83
|
+
return socket.request('Driver.hover', { context, element });
|
|
84
|
+
},
|
|
85
|
+
async click(context, element) {
|
|
86
|
+
return socket.request('Driver.click', { context, element });
|
|
87
|
+
},
|
|
88
|
+
async mainContext(context) {
|
|
89
|
+
return socket.request('Driver.mainContext', { context });
|
|
90
|
+
},
|
|
91
|
+
async parentContext(context) {
|
|
92
|
+
return socket.request('Driver.parentContext', { context });
|
|
93
|
+
},
|
|
94
|
+
async childContext(context, element) {
|
|
95
|
+
return socket.request('Driver.childContext', { context, element });
|
|
96
|
+
},
|
|
97
|
+
async getCapabilities(driver) {
|
|
98
|
+
return socket.request('Driver.getCapabilities', { driver });
|
|
99
|
+
},
|
|
100
|
+
async getDriverInfo(driver) {
|
|
101
|
+
return socket.request('Driver.getDriverInfo', { driver });
|
|
102
|
+
},
|
|
103
|
+
async getWindowSize(driver) {
|
|
104
|
+
return socket.request('Driver.getWindowSize', { driver });
|
|
105
|
+
},
|
|
106
|
+
async setWindowSize(driver, size) {
|
|
107
|
+
return socket.request('Driver.setWindowSize', { driver, size });
|
|
108
|
+
},
|
|
109
|
+
async getViewportSize(driver) {
|
|
110
|
+
return socket.request('Driver.getViewportSize', { driver });
|
|
111
|
+
},
|
|
112
|
+
async setViewportSize(driver, size) {
|
|
113
|
+
return socket.request('Driver.setViewportSize', { driver, size });
|
|
114
|
+
},
|
|
115
|
+
async getSystemBars(driver) {
|
|
116
|
+
return socket.request('Driver.getSystemBars', { driver });
|
|
117
|
+
},
|
|
118
|
+
async getOrientation(driver) {
|
|
119
|
+
return socket.request('Driver.getOrientation', { driver });
|
|
120
|
+
},
|
|
121
|
+
async setOrientation(driver, orientation) {
|
|
122
|
+
return socket.request('Driver.setOrientation', { driver, orientation });
|
|
123
|
+
},
|
|
124
|
+
async getCookies(driver, context) {
|
|
125
|
+
return socket.request('Driver.getCookies', { driver, context });
|
|
126
|
+
},
|
|
127
|
+
async getTitle(driver) {
|
|
128
|
+
return socket.request('Driver.getTitle', { driver });
|
|
129
|
+
},
|
|
130
|
+
async getUrl(driver) {
|
|
131
|
+
return socket.request('Driver.getUrl', { driver });
|
|
132
|
+
},
|
|
133
|
+
async takeScreenshot(driver) {
|
|
134
|
+
return socket.request('Driver.takeScreenshot', { driver });
|
|
135
|
+
},
|
|
136
|
+
async performAction(driver, steps) {
|
|
137
|
+
return socket.request('Driver.performAction', { driver, steps });
|
|
138
|
+
},
|
|
139
|
+
async visit(driver, url) {
|
|
140
|
+
return socket.request('Driver.visit', { driver, url });
|
|
141
|
+
},
|
|
142
|
+
async getCurrentWorld(driver) {
|
|
143
|
+
return socket.request('Driver.getCurrentWorld', { driver });
|
|
144
|
+
},
|
|
145
|
+
async getWorlds(driver) {
|
|
146
|
+
return socket.request('Driver.getWorlds', { driver });
|
|
147
|
+
},
|
|
148
|
+
async switchWorld(driver, name) {
|
|
149
|
+
return socket.request('Driver.switchWorld', { driver, name });
|
|
150
|
+
},
|
|
151
|
+
async reload(driver) {
|
|
152
|
+
return socket.request('Driver.reload', { driver });
|
|
153
|
+
},
|
|
154
|
+
async isUserFunction(ref) {
|
|
155
|
+
return utils.types.has(ref, 'applitools-ref-id');
|
|
156
|
+
},
|
|
157
|
+
async executeUserFunction(userFunction) {
|
|
158
|
+
return socket.request('Driver.executeUserFunction', userFunction);
|
|
159
|
+
},
|
|
160
|
+
async executeBrowserCommands(driver, commands) {
|
|
161
|
+
return socket.request('Driver.executeBrowserCommands', { driver, commands });
|
|
162
|
+
},
|
|
163
|
+
async bringToFront(driver) {
|
|
164
|
+
return socket.request('Driver.bringToFront', { driver });
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
// add default commands to spec (if not already there) such as `isUserFunction`
|
|
168
|
+
spec = addDefaultCommands(spec);
|
|
169
|
+
return spec.reduce((spec, name) => {
|
|
170
|
+
return Object.assign(spec, { [name]: commands[name] });
|
|
171
|
+
}, {});
|
|
172
|
+
}
|
|
173
|
+
exports.makeSpec = makeSpec;
|
|
174
|
+
// returns a new clone of the spec commands array with additional commands universal can support even if the spec doesn't
|
|
175
|
+
function addDefaultCommands(spec) {
|
|
176
|
+
const defaultCommands = [
|
|
177
|
+
{
|
|
178
|
+
command: 'isUserFunction',
|
|
179
|
+
dependsOn: ['executeUserFunction'],
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
const commands = spec.slice();
|
|
183
|
+
defaultCommands.forEach(({ command, dependsOn }) => {
|
|
184
|
+
if (!commands.includes(command) && dependsOn.every(dep => commands.includes(dep))) {
|
|
185
|
+
commands.push(command);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return commands;
|
|
189
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeServer = void 0;
|
|
4
|
+
const http_1 = require("http");
|
|
5
|
+
const https_1 = require("https");
|
|
6
|
+
const ws_1 = require("ws");
|
|
7
|
+
const { name, version } = require('../../package.json');
|
|
8
|
+
const TOKEN_HEADER = 'x-eyes-universal-token';
|
|
9
|
+
const TOKEN = `${name}@${version}`;
|
|
10
|
+
async function makeServer(options = {}, logger) {
|
|
11
|
+
const { port = 21077, singleton = true, debug = false, portResolutionMode = 'next', cert, key } = options;
|
|
12
|
+
const secure = Boolean(cert && key);
|
|
13
|
+
const http = secure ? new https_1.Server({ cert, key }) : new http_1.Server();
|
|
14
|
+
http.on('request', (request, response) => {
|
|
15
|
+
if (request.url === '/handshake') {
|
|
16
|
+
const token = debug ? request.headers[TOKEN_HEADER] : TOKEN;
|
|
17
|
+
if (request.headers[TOKEN_HEADER] === token) {
|
|
18
|
+
response.writeHead(200, { [TOKEN_HEADER]: token });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
response.writeHead(400);
|
|
22
|
+
}
|
|
23
|
+
response.end();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const hostName = process.env.APPLITOOLS_UNIVERSAL_HOST_NAME || 'localhost';
|
|
27
|
+
http.listen(port, hostName);
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
http.on('listening', () => {
|
|
30
|
+
const ws = new ws_1.Server({ server: http, path: '/eyes', maxPayload: 256 * 1024 * 1024 });
|
|
31
|
+
ws.on('close', () => {
|
|
32
|
+
logger.log('Core universal server is closed');
|
|
33
|
+
http.close();
|
|
34
|
+
});
|
|
35
|
+
ws.on('error', err => {
|
|
36
|
+
logger.log('Core universal server error', err);
|
|
37
|
+
});
|
|
38
|
+
resolve({ server: ws, port: http.address().port });
|
|
39
|
+
});
|
|
40
|
+
http.on('error', async (err) => {
|
|
41
|
+
if (portResolutionMode !== 'lazy' && err.code === 'EADDRINUSE') {
|
|
42
|
+
if (singleton && (await isHandshakable({ port, secure }))) {
|
|
43
|
+
return resolve({ port });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return resolve(await makeServer({ ...options, port: portResolutionMode === 'next' ? port + 1 : 0 }, logger));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
reject(err);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.makeServer = makeServer;
|
|
54
|
+
async function isHandshakable({ port, secure }) {
|
|
55
|
+
const request = secure ? https_1.request : http_1.request;
|
|
56
|
+
return new Promise(resolve => {
|
|
57
|
+
const handshake = request(`${secure ? 'https' : 'http'}://localhost:${port}/handshake`, {
|
|
58
|
+
headers: { [TOKEN_HEADER]: TOKEN },
|
|
59
|
+
});
|
|
60
|
+
handshake.on('response', ({ statusCode, headers }) => {
|
|
61
|
+
resolve(statusCode === 200 && headers[TOKEN_HEADER] === TOKEN);
|
|
62
|
+
});
|
|
63
|
+
handshake.on('error', () => resolve(false));
|
|
64
|
+
handshake.end();
|
|
65
|
+
});
|
|
66
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@applitools/core-universal",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"homepage": "https://applitools.com",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
11
|
+
"directory": "js/packages/core-universal"
|
|
12
|
+
},
|
|
13
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Applitools Team",
|
|
16
|
+
"email": "team@applitools.com"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./dist/*": "./dist/*.js",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./types/index.d.ts",
|
|
28
|
+
"bin": "./dist/cli/cli.js",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"types"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"lint": "run --top-level eslint '**/*.ts'",
|
|
35
|
+
"build": "yarn build:dist",
|
|
36
|
+
"build:dist": "run --top-level tsc --project ./tsconfig.build.json",
|
|
37
|
+
"build:bin": "bash ../../../scripts/build-binary-local.sh core-universal",
|
|
38
|
+
"setup": "run --top-level browsers:setup && run --top-level xvfb:setup",
|
|
39
|
+
"test:e2e": "run --top-level mocha './test/e2e/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --exit --require ./test/mocha-global-setup.js",
|
|
40
|
+
"test:bin": "MOCHA_GROUP=bin run --top-level mocha './test/bin/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --require ./test/mocha-global-setup.js"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@applitools/core": "4.56.3",
|
|
44
|
+
"@applitools/driver": "1.25.1",
|
|
45
|
+
"@applitools/logger": "2.2.8",
|
|
46
|
+
"@applitools/socket": "1.3.9",
|
|
47
|
+
"@applitools/spec-driver-webdriver": "1.5.6",
|
|
48
|
+
"@applitools/utils": "1.14.1",
|
|
49
|
+
"@types/ws": "8.5.5",
|
|
50
|
+
"chalk": "4.1.2",
|
|
51
|
+
"webdriver": "7.31.1",
|
|
52
|
+
"ws": "8.17.1",
|
|
53
|
+
"yargs": "17.7.2"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@applitools/bongo": "^5.10.0",
|
|
57
|
+
"@applitools/test-server": "^1.4.0",
|
|
58
|
+
"@applitools/test-utils": "^1.5.17",
|
|
59
|
+
"@types/mocha": "^10.0.7",
|
|
60
|
+
"@types/node": "^12.20.55",
|
|
61
|
+
"@types/yargs": "^17.0.22"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=12.13.0"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"lavamoat": {
|
|
70
|
+
"allowScripts": {
|
|
71
|
+
"ws>bufferutil": false,
|
|
72
|
+
"ws>utf-8-validate": false,
|
|
73
|
+
"@applitools/core>@applitools/core-base>@applitools/image>sharp": false
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { type Options } from './core-server';
|
|
3
|
+
import { type ForkOptions } from 'child_process';
|
|
4
|
+
export declare function makeCoreServerProcess(options: Options & {
|
|
5
|
+
forkOptions?: ForkOptions;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
port: number;
|
|
8
|
+
close: () => void;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ServerOptions } from './ws-server';
|
|
2
|
+
import { type Logger } from '@applitools/logger';
|
|
3
|
+
export type Options = ServerOptions & {
|
|
4
|
+
environment?: Record<string, any>;
|
|
5
|
+
agentIdPrefix?: string;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
shutdownMode?: 'lazy' | 'stdin';
|
|
8
|
+
idleTimeout?: number;
|
|
9
|
+
printStdout?: boolean;
|
|
10
|
+
isProcess?: boolean;
|
|
11
|
+
maskLog?: boolean;
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
};
|
|
14
|
+
export declare function makeCoreServer({ environment: defaultEnvironment, agentIdPrefix, debug, shutdownMode, idleTimeout, // 15min
|
|
15
|
+
printStdout, isProcess, maskLog, logger, ...handlerOptions }?: Options): Promise<{
|
|
16
|
+
port: number;
|
|
17
|
+
close?: () => void;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref } from './types';
|
|
2
|
+
export interface Refer {
|
|
3
|
+
isRef<TValue = any>(ref: any): ref is Ref<TValue>;
|
|
4
|
+
ref<TValue>(value: TValue, parentRef?: Ref<unknown>): Ref<TValue>;
|
|
5
|
+
deref<TValue>(ref: Ref<TValue>): TValue;
|
|
6
|
+
destroy(ref: Ref<any>): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function makeRefer(): Refer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ref, ServerSocket, UniversalSpecDriver } from './types';
|
|
2
|
+
import type { SpecType, SpecDriver as BaseSpecDriver, CommonSelector } from '@applitools/driver';
|
|
3
|
+
export type Driver = Ref;
|
|
4
|
+
export type Context = Ref;
|
|
5
|
+
export type Element = Ref;
|
|
6
|
+
export type Selector = string | CommonSelector | Ref;
|
|
7
|
+
export type UserFunction = Ref;
|
|
8
|
+
export type PrimarySpecType = SpecType<Driver, Context, Element, Selector, never, UserFunction>;
|
|
9
|
+
export type SpecDriver = BaseSpecDriver<PrimarySpecType>;
|
|
10
|
+
type CommandName = keyof UniversalSpecDriver<PrimarySpecType>;
|
|
11
|
+
export declare function makeSpec({ socket, spec, }: {
|
|
12
|
+
socket: ServerSocket<PrimarySpecType, any>;
|
|
13
|
+
spec: CommandName[];
|
|
14
|
+
}): SpecDriver;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Size, Region } from '@applitools/utils';
|
|
2
|
+
import type { Emitter, Listener, Client, Server } from '@applitools/socket';
|
|
3
|
+
import type { SpecType, DriverInfo, Cookie, WaitOptions } from '@applitools/driver';
|
|
4
|
+
import type * as MainCore from '@applitools/core';
|
|
5
|
+
/**
|
|
6
|
+
* Wraps the type with a ref if it vas to be refed
|
|
7
|
+
*/
|
|
8
|
+
type Refify<TValue> = TValue extends string | number | boolean | null | undefined ? TValue : TValue extends Array<infer TItem> ? Refify<TItem>[] : Extract<TValue[keyof TValue], (...args: any) => any> extends never ? TValue : Ref<TValue>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates universalized object out of an ordinary interface:
|
|
11
|
+
* - Filters out properties that are not of async function type
|
|
12
|
+
* - Adds domain to the method names (`Domain.methodName`)
|
|
13
|
+
* - Keep only first (`options`) argument of the methods
|
|
14
|
+
* - Introduces additional option to the methods with a ref of the current instance
|
|
15
|
+
* - Refifies return values of the methods
|
|
16
|
+
*/
|
|
17
|
+
type Universalize<TTarget extends Record<string, any>, TDomain extends string, TRefKey extends string = never> = {
|
|
18
|
+
[TKey in keyof TTarget as NonNullable<TTarget[TKey]> extends (...args: any[]) => Promise<any> ? `${TDomain}.${TKey & string}` : never]: NonNullable<TTarget[TKey]> extends (options: infer TOptions) => Promise<infer TResult> ? (options: TOptions & {
|
|
19
|
+
[TKey in TRefKey]: Ref<TTarget>;
|
|
20
|
+
}) => Promise<Refify<TResult>> : never;
|
|
21
|
+
};
|
|
22
|
+
export type Ref<TValue = never> = {
|
|
23
|
+
'applitools-ref-id': string;
|
|
24
|
+
type?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ClientSocket<TSpec extends SpecType, TType extends 'classic' | 'ufg'> = unknown & Emitter<Universalize<UniversalCore<TSpec, TType>, 'Core'>> & Client<Universalize<MainCore.Core<TSpec, TType>, 'Core'>> & Client<Universalize<MainCore.EyesManager<TSpec, TType>, 'EyesManager', 'manager'>> & Client<Universalize<MainCore.Eyes<TSpec, TType>, 'Eyes', 'eyes'>> & Client<Universalize<UniversalDebug<TSpec>, 'Debug'>> & Server<Universalize<UniversalSpecDriver<TSpec>, 'Driver'>>;
|
|
27
|
+
export type ServerSocket<TSpec extends SpecType, TType extends 'classic' | 'ufg'> = unknown & Listener<Universalize<UniversalCore<TSpec, TType>, 'Core'>> & Emitter<Universalize<UniversalLogger, 'Logger'>> & Server<Universalize<MainCore.Core<TSpec, TType>, 'Core'>> & Server<Universalize<MainCore.EyesManager<TSpec, TType>, 'EyesManager', 'manager'>> & Server<Universalize<MainCore.Eyes<TSpec, TType>, 'Eyes', 'eyes'>> & Server<Universalize<UniversalDebug<TSpec>, 'Debug'>> & Client<Universalize<UniversalSpecDriver<TSpec>, 'Driver'>>;
|
|
28
|
+
export interface UniversalCore<TSpec extends SpecType, TType extends 'classic' | 'ufg'> {
|
|
29
|
+
makeCore(options: {
|
|
30
|
+
spec: 'webdriver' | (keyof UniversalSpecDriver<TSpec>)[];
|
|
31
|
+
agentId: string;
|
|
32
|
+
environment?: Record<string, any>;
|
|
33
|
+
cwd: string;
|
|
34
|
+
}): Promise<MainCore.Core<TSpec, TType>>;
|
|
35
|
+
}
|
|
36
|
+
export interface UniversalLogger {
|
|
37
|
+
log(options: {
|
|
38
|
+
level: string;
|
|
39
|
+
message: string;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface UniversalDebug<TSpec extends SpecType> {
|
|
43
|
+
getHistory(): Promise<any>;
|
|
44
|
+
checkSpecDriver(options: {
|
|
45
|
+
driver: TSpec['driver'];
|
|
46
|
+
commands: (keyof UniversalSpecDriver<TSpec>)[];
|
|
47
|
+
}): Promise<any>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ideally would be transform SpecDriver type to the type with single object argument
|
|
51
|
+
* but typescript doesn't have a possibility to convert named tuples to object types at the moment
|
|
52
|
+
*/
|
|
53
|
+
export interface UniversalSpecDriver<T extends SpecType> {
|
|
54
|
+
isEqualElements(options: {
|
|
55
|
+
context: T['context'];
|
|
56
|
+
element1: T['element'];
|
|
57
|
+
element2: T['element'];
|
|
58
|
+
}): Promise<boolean>;
|
|
59
|
+
executeScript(options: {
|
|
60
|
+
context: T['context'];
|
|
61
|
+
script: string;
|
|
62
|
+
arg?: any;
|
|
63
|
+
}): Promise<any>;
|
|
64
|
+
findElement(options: {
|
|
65
|
+
context: T['context'];
|
|
66
|
+
selector: T['selector'];
|
|
67
|
+
parent?: T['element'];
|
|
68
|
+
}): Promise<T['element'] | null>;
|
|
69
|
+
findElements(options: {
|
|
70
|
+
context: T['context'];
|
|
71
|
+
selector: T['selector'];
|
|
72
|
+
parent?: T['element'];
|
|
73
|
+
}): Promise<T['element'][]>;
|
|
74
|
+
waitForSelector(options: {
|
|
75
|
+
context: T['context'];
|
|
76
|
+
selector: T['selector'];
|
|
77
|
+
parent?: T['element'];
|
|
78
|
+
options?: WaitOptions;
|
|
79
|
+
}): Promise<T['element'] | null>;
|
|
80
|
+
getElementRegion(options: {
|
|
81
|
+
context: T['context'];
|
|
82
|
+
element: T['element'];
|
|
83
|
+
}): Promise<Region>;
|
|
84
|
+
getElementAttribute(options: {
|
|
85
|
+
context: T['context'];
|
|
86
|
+
element: T['element'];
|
|
87
|
+
attr: string;
|
|
88
|
+
}): Promise<string>;
|
|
89
|
+
setElementText(options: {
|
|
90
|
+
context: T['context'];
|
|
91
|
+
element: T['element'];
|
|
92
|
+
text: string;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
getElementText(options: {
|
|
95
|
+
context: T['context'];
|
|
96
|
+
element: T['element'];
|
|
97
|
+
}): Promise<string>;
|
|
98
|
+
hover(options: {
|
|
99
|
+
context: T['context'];
|
|
100
|
+
element: T['element'];
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
click(options: {
|
|
103
|
+
context: T['context'];
|
|
104
|
+
element: T['element'];
|
|
105
|
+
}): Promise<void>;
|
|
106
|
+
mainContext(options: {
|
|
107
|
+
context: T['context'];
|
|
108
|
+
}): Promise<T['context']>;
|
|
109
|
+
parentContext(options: {
|
|
110
|
+
context: T['context'];
|
|
111
|
+
}): Promise<T['context']>;
|
|
112
|
+
childContext(options: {
|
|
113
|
+
context: T['context'];
|
|
114
|
+
element: T['element'];
|
|
115
|
+
}): Promise<T['context']>;
|
|
116
|
+
getDriverInfo(options: {
|
|
117
|
+
driver: T['driver'];
|
|
118
|
+
}): Promise<DriverInfo>;
|
|
119
|
+
getCapabilities(options: {
|
|
120
|
+
driver: T['driver'];
|
|
121
|
+
}): Promise<Record<string, any>>;
|
|
122
|
+
setWindowSize(options: {
|
|
123
|
+
driver: T['driver'];
|
|
124
|
+
size: Size;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
getWindowSize(options: {
|
|
127
|
+
driver: T['driver'];
|
|
128
|
+
}): Promise<Size>;
|
|
129
|
+
setViewportSize(options: {
|
|
130
|
+
driver: T['driver'];
|
|
131
|
+
size: Size;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
getViewportSize(options: {
|
|
134
|
+
driver: T['driver'];
|
|
135
|
+
}): Promise<Size>;
|
|
136
|
+
getSystemBars(options: {
|
|
137
|
+
driver: T['driver'];
|
|
138
|
+
}): Promise<{
|
|
139
|
+
statusBar: {
|
|
140
|
+
visible: boolean;
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
height: number;
|
|
144
|
+
width: number;
|
|
145
|
+
};
|
|
146
|
+
navigationBar: {
|
|
147
|
+
visible: boolean;
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
height: number;
|
|
151
|
+
width: number;
|
|
152
|
+
};
|
|
153
|
+
}>;
|
|
154
|
+
getOrientation(options: {
|
|
155
|
+
driver: T['driver'];
|
|
156
|
+
}): Promise<'portrait' | 'landscape' | 'portrait-secondary' | 'landscape-secondary'>;
|
|
157
|
+
setOrientation(options: {
|
|
158
|
+
driver: T['driver'];
|
|
159
|
+
orientation: 'portrait' | 'landscape' | 'portrait-secondary' | 'landscape-secondary';
|
|
160
|
+
}): Promise<void>;
|
|
161
|
+
getCookies(options: {
|
|
162
|
+
driver: T['driver'] | T['context'];
|
|
163
|
+
context?: boolean;
|
|
164
|
+
}): Promise<Cookie[]>;
|
|
165
|
+
getTitle(options: {
|
|
166
|
+
driver: T['driver'];
|
|
167
|
+
}): Promise<string>;
|
|
168
|
+
getUrl(options: {
|
|
169
|
+
driver: T['driver'];
|
|
170
|
+
}): Promise<string>;
|
|
171
|
+
takeScreenshot(options: {
|
|
172
|
+
driver: T['driver'];
|
|
173
|
+
}): Promise<string>;
|
|
174
|
+
performAction(options: {
|
|
175
|
+
driver: T['driver'];
|
|
176
|
+
steps: any[];
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
visit(options: {
|
|
179
|
+
driver: T['driver'];
|
|
180
|
+
url: string;
|
|
181
|
+
}): Promise<void>;
|
|
182
|
+
getCurrentWorld(options: {
|
|
183
|
+
driver: T['driver'];
|
|
184
|
+
}): Promise<string>;
|
|
185
|
+
getWorlds(options: {
|
|
186
|
+
driver: T['driver'];
|
|
187
|
+
}): Promise<string[]>;
|
|
188
|
+
switchWorld(options: {
|
|
189
|
+
driver: T['driver'];
|
|
190
|
+
name: string;
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
reload(options: {
|
|
193
|
+
driver: T['driver'];
|
|
194
|
+
}): Promise<void>;
|
|
195
|
+
isUserFunction(ref: any): Promise<boolean>;
|
|
196
|
+
executeUserFunction(userFunction: Ref): Promise<any>;
|
|
197
|
+
executeBrowserCommands(options: {
|
|
198
|
+
driver?: T['driver'];
|
|
199
|
+
commands: any[];
|
|
200
|
+
}): Promise<any>;
|
|
201
|
+
bringToFront(options: {
|
|
202
|
+
driver: T['driver'];
|
|
203
|
+
}): Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Server as WsServer } from 'ws';
|
|
3
|
+
import { Logger } from '@applitools/logger';
|
|
4
|
+
export type ServerOptions = {
|
|
5
|
+
port?: number;
|
|
6
|
+
singleton?: boolean;
|
|
7
|
+
portResolutionMode?: 'next' | 'random' | 'lazy';
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
key?: string | Buffer;
|
|
10
|
+
cert?: string | Buffer;
|
|
11
|
+
};
|
|
12
|
+
export declare function makeServer(options: ServerOptions | undefined, logger: Logger): Promise<{
|
|
13
|
+
server?: WsServer;
|
|
14
|
+
port: number;
|
|
15
|
+
}>;
|