@applitools/spec-driver-webdriver 1.0.56 → 1.1.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 +14 -0
- package/dist/spec-driver.js +83 -90
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-webdriver@1.0.57...js/spec-driver-webdriver@1.1.0) (2024-02-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* env var to skip deprected jwp commands ([#2200](https://github.com/applitools/eyes.sdk.javascript1/issues/2200)) ([d9123db](https://github.com/applitools/eyes.sdk.javascript1/commit/d9123dbba85679d1c6999718b90b89debb18ed18))
|
|
9
|
+
|
|
10
|
+
## [1.0.57](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-webdriver@1.0.56...js/spec-driver-webdriver@1.0.57) (2024-02-13)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* fixed issue with cdp commands on chromium browsers ([#2180](https://github.com/applitools/eyes.sdk.javascript1/issues/2180)) ([550fc77](https://github.com/applitools/eyes.sdk.javascript1/commit/550fc772d3988aae29e6f4a1a11d2a408072dc38))
|
|
16
|
+
|
|
3
17
|
## [1.0.56](https://github.com/applitools/eyes.sdk.javascript1/compare/js/spec-driver-webdriver@1.0.55...js/spec-driver-webdriver@1.0.56) (2024-02-06)
|
|
4
18
|
|
|
5
19
|
|
package/dist/spec-driver.js
CHANGED
|
@@ -74,16 +74,6 @@ function extractEnvironment(capabilities) {
|
|
|
74
74
|
isW3C,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function command(method, url, body) {
|
|
78
|
-
if (getFrameworkMajorVersion() < 8) {
|
|
79
|
-
const { default: command } = require('webdriver/build/command');
|
|
80
|
-
return command(method, url, body);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const { command } = require('webdriver');
|
|
84
|
-
return command(method, url, body);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
77
|
function getFrameworkMajorVersion() {
|
|
88
78
|
const version = require('webdriver/package.json').version;
|
|
89
79
|
return Number.parseInt(version);
|
|
@@ -144,89 +134,90 @@ function isStaleElementError(error) {
|
|
|
144
134
|
exports.isStaleElementError = isStaleElementError;
|
|
145
135
|
function toDriver(driver) {
|
|
146
136
|
var _a, _b, _c;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
137
|
+
let transformedDriver;
|
|
138
|
+
if (utils.types.has(driver, ['sessionId', 'serverUrl'])) {
|
|
139
|
+
const url = new URL(driver.serverUrl);
|
|
140
|
+
const environment = extractEnvironment(driver.capabilities);
|
|
141
|
+
const options = {
|
|
142
|
+
sessionId: driver.sessionId,
|
|
143
|
+
protocol: url.protocol ? url.protocol.replace(/:$/, '') : undefined,
|
|
144
|
+
hostname: url.hostname,
|
|
145
|
+
port: Number(url.port) || undefined,
|
|
146
|
+
path: url.pathname,
|
|
147
|
+
capabilities: driver.capabilities,
|
|
148
|
+
logLevel: 'silent',
|
|
149
|
+
...environment,
|
|
150
|
+
};
|
|
151
|
+
if (!options.port) {
|
|
152
|
+
if (options.protocol === 'http')
|
|
153
|
+
options.port = 80;
|
|
154
|
+
if (options.protocol === 'https')
|
|
155
|
+
options.port = 443;
|
|
156
|
+
}
|
|
157
|
+
if ((_a = driver.proxy) === null || _a === void 0 ? void 0 : _a.url) {
|
|
158
|
+
const proxyUrl = new URL(driver.proxy.url);
|
|
159
|
+
proxyUrl.username = (_b = driver.proxy.username) !== null && _b !== void 0 ? _b : proxyUrl.username;
|
|
160
|
+
proxyUrl.password = (_c = driver.proxy.password) !== null && _c !== void 0 ? _c : proxyUrl.password;
|
|
161
|
+
const proxyOptions = { ...(0, url_1.parse)(proxyUrl.href), rejectUnauthorized: false };
|
|
162
|
+
const httpAgent = (0, http_proxy_agent_1.default)(proxyOptions);
|
|
163
|
+
const httpsAgent = (0, https_proxy_agent_1.default)(proxyOptions);
|
|
164
|
+
httpsAgent.callback = utils.general.wrap(httpsAgent.callback.bind(httpsAgent), (fn, request, options, ...rest) => {
|
|
165
|
+
return fn(request, { ...options, rejectUnauthorized: false }, ...rest);
|
|
166
|
+
});
|
|
167
|
+
options.agent = { http: httpAgent, https: httpsAgent };
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const httpAgent = http_1.default.globalAgent;
|
|
171
|
+
const httpsAgent = new https_1.default.Agent({ rejectUnauthorized: false });
|
|
172
|
+
options.agent = { http: httpAgent, https: httpsAgent };
|
|
173
|
+
}
|
|
174
|
+
const WebDriver = getWebDriver();
|
|
175
|
+
transformedDriver = WebDriver.attachToSession(options);
|
|
176
|
+
transformedDriver.original = driver.original;
|
|
166
177
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const proxyOptions = { ...(0, url_1.parse)(proxyUrl.href), rejectUnauthorized: false };
|
|
172
|
-
const httpAgent = (0, http_proxy_agent_1.default)(proxyOptions);
|
|
173
|
-
const httpsAgent = (0, https_proxy_agent_1.default)(proxyOptions);
|
|
174
|
-
httpsAgent.callback = utils.general.wrap(httpsAgent.callback.bind(httpsAgent), (fn, request, options, ...rest) => {
|
|
175
|
-
return fn(request, { ...options, rejectUnauthorized: false }, ...rest);
|
|
178
|
+
else {
|
|
179
|
+
// NOTE: this is needed to a rare case when this function is used not on the SecondaryDriver but on a derivative of the Driver
|
|
180
|
+
transformedDriver = Object.create(driver, {
|
|
181
|
+
original: { enumerable: false, get: () => driver },
|
|
176
182
|
});
|
|
177
|
-
options.agent = { http: httpAgent, https: httpsAgent };
|
|
178
183
|
}
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
if (utils.types.isFunction(transformedDriver, 'addCommand')) {
|
|
185
|
+
const command = getFrameworkMajorVersion() < 8 ? require('webdriver/build/command').default : require('webdriver').command;
|
|
186
|
+
transformedDriver.addCommand('_getWindowSize', command('GET', '/session/:sessionId/window/current/size', {
|
|
187
|
+
command: '_getWindowSize',
|
|
188
|
+
description: '',
|
|
189
|
+
ref: '',
|
|
190
|
+
parameters: [],
|
|
191
|
+
}));
|
|
192
|
+
transformedDriver.addCommand('_setWindowSize', command('POST', '/session/:sessionId/window/current/size', {
|
|
193
|
+
command: '_setWindowSize',
|
|
194
|
+
parameters: [
|
|
195
|
+
{ name: 'width', type: 'number', required: true, description: '' },
|
|
196
|
+
{ name: 'height', type: 'number', required: true, description: '' },
|
|
197
|
+
],
|
|
198
|
+
description: '',
|
|
199
|
+
ref: '',
|
|
200
|
+
}));
|
|
201
|
+
transformedDriver.addCommand('setWindowPosition', command('POST', '/session/:sessionId/window/current/position', {
|
|
202
|
+
command: 'setWindowPosition',
|
|
203
|
+
parameters: [
|
|
204
|
+
{ name: 'x', type: 'number', required: true, description: '' },
|
|
205
|
+
{ name: 'y', type: 'number', required: true, description: '' },
|
|
206
|
+
],
|
|
207
|
+
description: '',
|
|
208
|
+
ref: '',
|
|
209
|
+
}));
|
|
210
|
+
transformedDriver.addCommand('sendCommandAndGetResult', command('POST', '/session/:sessionId/chromium/send_command_and_get_result', {
|
|
211
|
+
command: 'sendCommandAndGetResult',
|
|
212
|
+
parameters: [
|
|
213
|
+
{ name: 'cmd', type: 'string', required: true, description: '' },
|
|
214
|
+
{ name: 'params', type: 'object', required: true, description: '' },
|
|
215
|
+
],
|
|
216
|
+
description: 'Send a command to the DevTools debugger and wait for the result.',
|
|
217
|
+
ref: '',
|
|
218
|
+
}));
|
|
183
219
|
}
|
|
184
|
-
|
|
185
|
-
const attachedDriver = WebDriver.attachToSession(options, undefined, {
|
|
186
|
-
_getWindowSize: {
|
|
187
|
-
value: command('GET', '/session/:sessionId/window/current/size', {
|
|
188
|
-
command: '_getWindowSize',
|
|
189
|
-
description: '',
|
|
190
|
-
ref: '',
|
|
191
|
-
parameters: [],
|
|
192
|
-
}),
|
|
193
|
-
},
|
|
194
|
-
_setWindowSize: {
|
|
195
|
-
value: command('POST', '/session/:sessionId/window/current/size', {
|
|
196
|
-
command: '_setWindowSize',
|
|
197
|
-
parameters: [
|
|
198
|
-
{ name: 'width', type: 'number', required: true, description: '' },
|
|
199
|
-
{ name: 'height', type: 'number', required: true, description: '' },
|
|
200
|
-
],
|
|
201
|
-
description: '',
|
|
202
|
-
ref: '',
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
205
|
-
setWindowPosition: {
|
|
206
|
-
value: command('POST', '/session/:sessionId/window/current/position', {
|
|
207
|
-
command: 'setWindowPosition',
|
|
208
|
-
parameters: [
|
|
209
|
-
{ name: 'x', type: 'number', required: true, description: '' },
|
|
210
|
-
{ name: 'y', type: 'number', required: true, description: '' },
|
|
211
|
-
],
|
|
212
|
-
description: '',
|
|
213
|
-
ref: '',
|
|
214
|
-
}),
|
|
215
|
-
},
|
|
216
|
-
sendCommandAndGetResult: {
|
|
217
|
-
value: command('POST', '/session/:sessionId/chromium/send_command_and_get_result', {
|
|
218
|
-
command: 'sendCommandAndGetResult',
|
|
219
|
-
parameters: [
|
|
220
|
-
{ name: 'cmd', type: 'string', required: true, description: '' },
|
|
221
|
-
{ name: 'params', type: 'object', required: true, description: '' },
|
|
222
|
-
],
|
|
223
|
-
description: 'Send a command to the DevTools debugger and wait for the result.',
|
|
224
|
-
ref: '',
|
|
225
|
-
}),
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
attachedDriver.original = driver.original;
|
|
229
|
-
return attachedDriver;
|
|
220
|
+
return transformedDriver;
|
|
230
221
|
}
|
|
231
222
|
exports.toDriver = toDriver;
|
|
232
223
|
function toElement(element) {
|
|
@@ -346,7 +337,9 @@ async function getDriverInfo(driver) {
|
|
|
346
337
|
exports.getDriverInfo = getDriverInfo;
|
|
347
338
|
async function getCapabilities(driver) {
|
|
348
339
|
var _a;
|
|
349
|
-
const capabilities =
|
|
340
|
+
const capabilities = utils.general.getEnvValue('SKIP_DEPRECATED_JWP_COMMANDS', 'boolean')
|
|
341
|
+
? null
|
|
342
|
+
: await ((_a = driver.getSession) === null || _a === void 0 ? void 0 : _a.call(driver).catch(() => null));
|
|
350
343
|
return utils.types.isObject(capabilities) ? capabilities : driver.capabilities;
|
|
351
344
|
}
|
|
352
345
|
exports.getCapabilities = getCapabilities;
|