@appium/base-driver 8.1.2 → 8.2.3
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/build/lib/basedriver/capabilities.js +3 -1
- package/build/lib/basedriver/commands/index.js +2 -4
- package/build/lib/basedriver/driver.js +8 -10
- package/build/lib/basedriver/helpers.js +140 -82
- package/build/lib/express/express-logging.js +2 -2
- package/build/lib/index.js +126 -0
- package/build/lib/jsonwp-proxy/protocol-converter.js +2 -5
- package/build/lib/jsonwp-proxy/proxy.js +2 -5
- package/build/lib/protocol/errors.js +4 -2
- package/build/lib/protocol/helpers.js +3 -20
- package/build/lib/protocol/index.js +13 -1
- package/build/lib/protocol/protocol.js +26 -25
- package/build/lib/protocol/routes.js +1 -10
- package/build/test/basedriver/capability-specs.js +10 -10
- package/build/test/basedriver/commands/event-specs.js +10 -10
- package/build/test/basedriver/driver-e2e-specs.js +3 -3
- package/build/test/basedriver/driver-e2e-tests.js +6 -223
- package/build/test/basedriver/driver-specs.js +3 -3
- package/build/test/basedriver/driver-tests.js +6 -6
- package/build/test/basedriver/helpers-specs.js +5 -1
- package/build/test/basedriver/timeout-specs.js +7 -7
- package/build/test/basedriver/websockets-e2e-specs.js +5 -5
- package/build/test/express/server-e2e-specs.js +156 -0
- package/build/test/express/server-specs.js +151 -0
- package/build/test/express/static-specs.js +23 -0
- package/build/test/helpers.js +57 -0
- package/build/test/jsonwp-proxy/mock-request.js +93 -0
- package/build/test/jsonwp-proxy/protocol-converter-specs.js +173 -0
- package/build/test/jsonwp-proxy/proxy-e2e-specs.js +61 -0
- package/build/test/jsonwp-proxy/proxy-specs.js +294 -0
- package/build/test/jsonwp-proxy/url-specs.js +167 -0
- package/build/test/jsonwp-status/status-specs.js +36 -0
- package/build/test/protocol/errors-specs.js +388 -0
- package/build/test/protocol/fake-driver.js +168 -0
- package/build/test/protocol/helpers.js +27 -0
- package/build/test/protocol/protocol-e2e-specs.js +1182 -0
- package/build/test/protocol/routes-specs.js +82 -0
- package/build/test/protocol/validator-specs.js +151 -0
- package/index.d.ts +5 -3
- package/index.js +1 -62
- package/lib/basedriver/capabilities.js +3 -0
- package/lib/basedriver/commands/index.js +0 -2
- package/lib/basedriver/driver.js +6 -26
- package/lib/basedriver/helpers.js +202 -85
- package/lib/express/express-logging.js +1 -1
- package/lib/index.js +64 -0
- package/lib/jsonwp-proxy/protocol-converter.js +1 -5
- package/lib/jsonwp-proxy/proxy.js +1 -3
- package/lib/protocol/errors.js +1 -1
- package/lib/protocol/helpers.js +5 -25
- package/lib/protocol/index.js +3 -1
- package/lib/protocol/protocol.js +26 -31
- package/lib/protocol/routes.js +0 -3
- package/package.json +8 -16
- package/test/basedriver/capability-specs.js +1 -1
- package/test/basedriver/commands/event-specs.js +1 -1
- package/test/basedriver/driver-e2e-specs.js +1 -1
- package/test/basedriver/driver-e2e-tests.js +1 -179
- package/test/basedriver/driver-specs.js +1 -1
- package/test/basedriver/driver-tests.js +3 -3
- package/test/basedriver/helpers-specs.js +4 -0
- package/test/basedriver/timeout-specs.js +1 -1
- package/test/basedriver/websockets-e2e-specs.js +1 -1
- package/build/index.js +0 -120
- package/build/lib/basedriver/commands/execute-child.js +0 -137
- package/build/lib/basedriver/commands/execute.js +0 -119
- package/build/test/basedriver/fixtures/custom-element-finder-bad.js +0 -12
- package/build/test/basedriver/fixtures/custom-element-finder.js +0 -36
- package/lib/basedriver/commands/execute-child.js +0 -132
- package/lib/basedriver/commands/execute.js +0 -126
package/lib/protocol/protocol.js
CHANGED
|
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
|
|
2
2
|
import { util } from '@appium/support';
|
|
3
3
|
import { validators } from './validators';
|
|
4
4
|
import {
|
|
5
|
-
errors, isErrorType, getResponseForW3CError,
|
|
5
|
+
errors, isErrorType, getResponseForW3CError,
|
|
6
6
|
errorFromMJSONWPStatusCode, errorFromW3CJsonCode,
|
|
7
7
|
} from './errors';
|
|
8
8
|
import { METHOD_MAP, NO_SESSION_ID_COMMANDS } from './routes';
|
|
@@ -16,6 +16,7 @@ import SESSIONS_CACHE from './sessions-cache';
|
|
|
16
16
|
|
|
17
17
|
const CREATE_SESSION_COMMAND = 'createSession';
|
|
18
18
|
const DELETE_SESSION_COMMAND = 'deleteSession';
|
|
19
|
+
const GET_STATUS_COMMAND = 'getStatus';
|
|
19
20
|
|
|
20
21
|
class Protocol {}
|
|
21
22
|
|
|
@@ -239,9 +240,17 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
|
|
|
239
240
|
// this command should never be proxied (which is useful for plugin developers who add
|
|
240
241
|
// commands and generally would not want that command to be proxied instead of handled by the
|
|
241
242
|
// plugin)
|
|
243
|
+
let didPluginOverrideProxy = false;
|
|
242
244
|
if (isSessCmd && !spec.neverProxy && driverShouldDoJwpProxy(driver, req, spec.command)) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
if (!driver.pluginsToHandleCmd ||
|
|
246
|
+
driver.pluginsToHandleCmd(spec.command, req.params.sessionId).length === 0) {
|
|
247
|
+
await doJwpProxy(driver, req, res);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
SESSIONS_CACHE.getLogger(req.params.sessionId, currentProtocol).debug(`Would have proxied ` +
|
|
251
|
+
`command directly, but a plugin exists which might require its value, so will let ` +
|
|
252
|
+
`its value be collected internally and made part of plugin chain`);
|
|
253
|
+
didPluginOverrideProxy = true;
|
|
245
254
|
}
|
|
246
255
|
|
|
247
256
|
// if a command is not in our method map, it's because we
|
|
@@ -283,12 +292,15 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
|
|
|
283
292
|
`${driver.constructor.name}.${spec.command}() with args: ` +
|
|
284
293
|
_.truncate(JSON.stringify(args), {length: MAX_LOG_BODY_LENGTH}));
|
|
285
294
|
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
if (didPluginOverrideProxy) {
|
|
296
|
+
// TODO for now we add this information on the args list, but that's mixing purposes here.
|
|
297
|
+
// We really should add another 'options' parameter to 'executeCommand', but this would be
|
|
298
|
+
// a breaking change for all drivers so would need to be handled carefully.
|
|
299
|
+
args.push({reqForProxy: req});
|
|
290
300
|
}
|
|
291
301
|
|
|
302
|
+
driverRes = await driver.executeCommand(spec.command, ...args);
|
|
303
|
+
|
|
292
304
|
// Get the protocol after executeCommand
|
|
293
305
|
currentProtocol = extractProtocol(driver, req.params.sessionId) || currentProtocol;
|
|
294
306
|
|
|
@@ -366,24 +378,7 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
|
|
|
366
378
|
.debug(`Encountered internal error running command: ${errMsg}`);
|
|
367
379
|
}
|
|
368
380
|
|
|
369
|
-
|
|
370
|
-
[httpStatus, httpResBody] = getResponseForW3CError(actualErr);
|
|
371
|
-
} else if (currentProtocol === PROTOCOLS.MJSONWP) {
|
|
372
|
-
[httpStatus, httpResBody] = getResponseForJsonwpError(actualErr);
|
|
373
|
-
} else {
|
|
374
|
-
// If it's unknown what the protocol is (like if it's `getStatus` prior to `createSession`), merge the responses
|
|
375
|
-
// together to be protocol-agnostic
|
|
376
|
-
let jsonwpRes = getResponseForJsonwpError(actualErr);
|
|
377
|
-
let w3cRes = getResponseForW3CError(actualErr);
|
|
378
|
-
|
|
379
|
-
httpResBody = {
|
|
380
|
-
...jsonwpRes[1],
|
|
381
|
-
...w3cRes[1],
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// Use the JSONWP status code (which is usually 500)
|
|
385
|
-
httpStatus = jsonwpRes[0];
|
|
386
|
-
}
|
|
381
|
+
[httpStatus, httpResBody] = getResponseForW3CError(actualErr);
|
|
387
382
|
}
|
|
388
383
|
|
|
389
384
|
// decode the response, which is either a string or json
|
|
@@ -404,7 +399,7 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
|
|
|
404
399
|
delete httpResBody.sessionId;
|
|
405
400
|
}
|
|
406
401
|
|
|
407
|
-
httpResBody = formatStatus(httpResBody
|
|
402
|
+
httpResBody = formatStatus(httpResBody);
|
|
408
403
|
res.status(httpStatus).json(httpResBody);
|
|
409
404
|
}
|
|
410
405
|
};
|
|
@@ -422,7 +417,7 @@ function driverShouldDoJwpProxy (driver, req, command) {
|
|
|
422
417
|
|
|
423
418
|
// we should never proxy deleteSession because we need to give the containing
|
|
424
419
|
// driver an opportunity to clean itself up
|
|
425
|
-
if (command ===
|
|
420
|
+
if (command === DELETE_SESSION_COMMAND) {
|
|
426
421
|
return false;
|
|
427
422
|
}
|
|
428
423
|
|
|
@@ -441,11 +436,10 @@ async function doJwpProxy (driver, req, res) {
|
|
|
441
436
|
|
|
442
437
|
// check that the inner driver has a proxy function
|
|
443
438
|
if (!driver.canProxy(req.params.sessionId)) {
|
|
444
|
-
throw new Error('Trying to proxy to a
|
|
439
|
+
throw new Error('Trying to proxy to a server but the driver is unable to proxy');
|
|
445
440
|
}
|
|
446
441
|
try {
|
|
447
|
-
|
|
448
|
-
if (proxiedRes && proxiedRes.error) throw proxiedRes.error; // eslint-disable-line curly
|
|
442
|
+
await driver.executeCommand('proxyReqRes', req, res, req.params.sessionId);
|
|
449
443
|
} catch (err) {
|
|
450
444
|
if (isErrorType(err, errors.ProxyRequestError)) {
|
|
451
445
|
throw err;
|
|
@@ -458,5 +452,6 @@ async function doJwpProxy (driver, req, res) {
|
|
|
458
452
|
|
|
459
453
|
export {
|
|
460
454
|
Protocol, routeConfiguringFunction, isSessionCommand,
|
|
461
|
-
driverShouldDoJwpProxy, determineProtocol
|
|
455
|
+
driverShouldDoJwpProxy, determineProtocol, CREATE_SESSION_COMMAND,
|
|
456
|
+
DELETE_SESSION_COMMAND, GET_STATUS_COMMAND,
|
|
462
457
|
};
|
package/lib/protocol/routes.js
CHANGED
|
@@ -575,9 +575,6 @@ const METHOD_MAP = {
|
|
|
575
575
|
'/session/:sessionId/appium/receive_async_response': {
|
|
576
576
|
POST: {command: 'receiveAsyncResponse', payloadParams: {required: ['response']}}
|
|
577
577
|
},
|
|
578
|
-
'/session/:sessionId/appium/execute_driver': {
|
|
579
|
-
POST: {command: 'executeDriverScript', payloadParams: {required: ['script'], optional: ['type', 'timeout']}}
|
|
580
|
-
},
|
|
581
578
|
'/session/:sessionId/appium/events': {
|
|
582
579
|
POST: {command: 'getLogEvents', payloadParams: {optional: ['type']}}
|
|
583
580
|
},
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"firefoxos",
|
|
12
12
|
"testing"
|
|
13
13
|
],
|
|
14
|
-
"version": "8.
|
|
14
|
+
"version": "8.2.3",
|
|
15
15
|
"author": "https://github.com/appium",
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"repository": {
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"node": ">=12",
|
|
26
26
|
"npm": ">=6"
|
|
27
27
|
},
|
|
28
|
-
"main": "./build/index.js",
|
|
29
28
|
"directories": {
|
|
30
29
|
"lib": "lib"
|
|
31
30
|
},
|
|
@@ -36,20 +35,18 @@
|
|
|
36
35
|
"static",
|
|
37
36
|
"test/basedriver",
|
|
38
37
|
"!test/basedriver/fixtures",
|
|
39
|
-
"build
|
|
40
|
-
"build/lib",
|
|
41
|
-
"build/test/basedriver",
|
|
38
|
+
"build",
|
|
42
39
|
"!build/test/basedriver/fixtures"
|
|
43
40
|
],
|
|
44
41
|
"dependencies": {
|
|
45
|
-
"@appium/support": "^2.55.
|
|
46
|
-
"@babel/runtime": "7.16.
|
|
42
|
+
"@appium/support": "^2.55.3",
|
|
43
|
+
"@babel/runtime": "7.16.3",
|
|
44
|
+
"@dabh/colors": "1.4.0",
|
|
47
45
|
"async-lock": "1.3.0",
|
|
48
46
|
"asyncbox": "2.9.2",
|
|
49
47
|
"axios": "0.24.0",
|
|
50
48
|
"bluebird": "3.7.2",
|
|
51
49
|
"body-parser": "1.19.0",
|
|
52
|
-
"colors": "1.4.0",
|
|
53
50
|
"es6-error": "4.1.1",
|
|
54
51
|
"express": "4.17.1",
|
|
55
52
|
"http-status-codes": "2.1.4",
|
|
@@ -58,18 +55,13 @@
|
|
|
58
55
|
"method-override": "3.0.0",
|
|
59
56
|
"morgan": "1.10.0",
|
|
60
57
|
"serve-favicon": "2.5.0",
|
|
61
|
-
"source-map-support": "0.5.
|
|
58
|
+
"source-map-support": "0.5.21",
|
|
62
59
|
"validate.js": "0.13.1",
|
|
63
|
-
"
|
|
64
|
-
"ws": "7.5.5"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@appium/eslint-config-appium": "^4.7.3",
|
|
68
|
-
"@appium/gulp-plugins": "^5.5.4"
|
|
60
|
+
"ws": "7.5.6"
|
|
69
61
|
},
|
|
70
62
|
"publishConfig": {
|
|
71
63
|
"access": "public"
|
|
72
64
|
},
|
|
73
65
|
"homepage": "https://appium.io",
|
|
74
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ca90a11813546ab4851e5b1f0406f420a53227e6"
|
|
75
67
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { BaseDriver, server, routeConfiguringFunction, DeviceSettings
|
|
3
|
-
import {
|
|
4
|
-
MJSONWP_ELEMENT_KEY, W3C_ELEMENT_KEY
|
|
5
|
-
} from '../../lib/constants';
|
|
2
|
+
import { BaseDriver, server, routeConfiguringFunction, DeviceSettings } from '../../lib';
|
|
6
3
|
import axios from 'axios';
|
|
7
4
|
import B from 'bluebird';
|
|
8
5
|
import {TEST_HOST, getTestPort, createAppiumURL, METHODS} from '../helpers';
|
|
@@ -339,181 +336,6 @@ function baseDriverE2ETests (DriverClass, defaultCaps = {}) {
|
|
|
339
336
|
});
|
|
340
337
|
});
|
|
341
338
|
|
|
342
|
-
describe('execute driver script', function () {
|
|
343
|
-
// mock some methods on BaseDriver that aren't normally there except in
|
|
344
|
-
// a fully blown driver
|
|
345
|
-
let originalFindElement, sessionId;
|
|
346
|
-
before(function () {
|
|
347
|
-
d.allowInsecure = ['execute_driver_script'];
|
|
348
|
-
originalFindElement = d.findElement;
|
|
349
|
-
d.findElement = (function (strategy, selector) {
|
|
350
|
-
if (strategy === 'accessibility id' && selector === 'amazing') {
|
|
351
|
-
return {[W3C_ELEMENT_KEY]: 'element-id-1'};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
throw new errors.NoSuchElementError('not found');
|
|
355
|
-
}).bind(d);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
beforeEach(async function () {
|
|
359
|
-
({sessionId} = await startSession(defaultCaps));
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
after(function () {
|
|
363
|
-
d.findElement = originalFindElement;
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
afterEach(async function () {
|
|
367
|
-
await endSession(sessionId);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it('should not work unless the allowInsecure feature flag is set', async function () {
|
|
371
|
-
d._allowInsecure = d.allowInsecure;
|
|
372
|
-
try {
|
|
373
|
-
d.allowInsecure = [];
|
|
374
|
-
const script = `return 'foo'`;
|
|
375
|
-
await axios({
|
|
376
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
377
|
-
method: POST,
|
|
378
|
-
data: {script, type: 'wd'},
|
|
379
|
-
}).should.eventually.be.rejected;
|
|
380
|
-
await endSession(sessionId);
|
|
381
|
-
} finally {
|
|
382
|
-
d.allowInsecure = d._allowInsecure;
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it('should execute a webdriverio script in the context of session', async function () {
|
|
387
|
-
const script = `
|
|
388
|
-
const timeouts = await driver.getTimeouts();
|
|
389
|
-
const status = await driver.status();
|
|
390
|
-
return [timeouts, status];
|
|
391
|
-
`;
|
|
392
|
-
const {value} = (await axios({
|
|
393
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
394
|
-
method: POST,
|
|
395
|
-
data: {script, type: 'webdriverio'},
|
|
396
|
-
})).data;
|
|
397
|
-
const expectedTimeouts = {command: 250, implicit: 0};
|
|
398
|
-
const expectedStatus = {};
|
|
399
|
-
value.result.should.eql([expectedTimeouts, expectedStatus]);
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it('should fail with any script type other than webdriverio currently', async function () {
|
|
403
|
-
const script = `return 'foo'`;
|
|
404
|
-
await axios({
|
|
405
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
406
|
-
method: POST,
|
|
407
|
-
data: {script, type: 'wd'},
|
|
408
|
-
}).should.eventually.be.rejected;
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it('should execute a webdriverio script that returns elements correctly', async function () {
|
|
412
|
-
const script = `
|
|
413
|
-
return await driver.$("~amazing");
|
|
414
|
-
`;
|
|
415
|
-
const {value} = (await axios({
|
|
416
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
417
|
-
method: POST,
|
|
418
|
-
data: {script},
|
|
419
|
-
})).data;
|
|
420
|
-
value.result.should.eql({
|
|
421
|
-
[W3C_ELEMENT_KEY]: 'element-id-1',
|
|
422
|
-
[MJSONWP_ELEMENT_KEY]: 'element-id-1'
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it('should execute a webdriverio script that returns elements in deep structure', async function () {
|
|
427
|
-
const script = `
|
|
428
|
-
const el = await driver.$("~amazing");
|
|
429
|
-
return {element: el, elements: [el, el]};
|
|
430
|
-
`;
|
|
431
|
-
const {value} = (await axios({
|
|
432
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
433
|
-
method: POST,
|
|
434
|
-
data: {script},
|
|
435
|
-
})).data;
|
|
436
|
-
const elObj = {
|
|
437
|
-
[W3C_ELEMENT_KEY]: 'element-id-1',
|
|
438
|
-
[MJSONWP_ELEMENT_KEY]: 'element-id-1'
|
|
439
|
-
};
|
|
440
|
-
value.result.should.eql({element: elObj, elements: [elObj, elObj]});
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
it('should store and return logs to the user', async function () {
|
|
444
|
-
const script = `
|
|
445
|
-
console.log("foo");
|
|
446
|
-
console.log("foo2");
|
|
447
|
-
console.warn("bar");
|
|
448
|
-
console.error("baz");
|
|
449
|
-
return null;
|
|
450
|
-
`;
|
|
451
|
-
const {value} = (await axios({
|
|
452
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
453
|
-
method: POST,
|
|
454
|
-
data: {script},
|
|
455
|
-
})).data;
|
|
456
|
-
value.logs.should.eql({log: ['foo', 'foo2'], warn: ['bar'], error: ['baz']});
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('should have appium specific commands available', async function () {
|
|
460
|
-
const script = `
|
|
461
|
-
return typeof driver.lock;
|
|
462
|
-
`;
|
|
463
|
-
const {value} = (await axios({
|
|
464
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
465
|
-
method: POST,
|
|
466
|
-
data: {script},
|
|
467
|
-
})).data;
|
|
468
|
-
value.result.should.eql('function');
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
it('should correctly handle errors that happen in a webdriverio script', async function () {
|
|
472
|
-
const script = `
|
|
473
|
-
return await driver.$("~notfound");
|
|
474
|
-
`;
|
|
475
|
-
const {data} = await axios({
|
|
476
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
477
|
-
method: POST,
|
|
478
|
-
validateStatus: null,
|
|
479
|
-
data: {script},
|
|
480
|
-
});
|
|
481
|
-
data.value.result.error.error.should.equal('no such element');
|
|
482
|
-
data.value.result.error.message.should.equal('not found');
|
|
483
|
-
data.value.result.error.stacktrace.should.includes('NoSuchElementError:');
|
|
484
|
-
data.value.result.selector.should.equal('~notfound');
|
|
485
|
-
data.value.result.sessionId.should.equal(sessionId);
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
it('should correctly handle errors that happen when a script cannot be compiled', async function () {
|
|
489
|
-
const script = `
|
|
490
|
-
return {;
|
|
491
|
-
`;
|
|
492
|
-
const {data} = await axios({
|
|
493
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
494
|
-
method: POST,
|
|
495
|
-
validateStatus: null,
|
|
496
|
-
data: {script},
|
|
497
|
-
});
|
|
498
|
-
data.value.should.have.property('message');
|
|
499
|
-
data.value.message.should.match(/An unknown server-side error occurred while processing the command. Original error: Could not execute driver script. Original error was: Error: Unexpected token '?;'?/);
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
it('should be able to set a timeout on a driver script', async function () {
|
|
503
|
-
const script = `
|
|
504
|
-
await Promise.delay(1000);
|
|
505
|
-
return true;
|
|
506
|
-
`;
|
|
507
|
-
const {value} = (await axios({
|
|
508
|
-
url: createAppiumTestURL(sessionId, 'appium/execute_driver'),
|
|
509
|
-
method: POST,
|
|
510
|
-
validateStatus: null,
|
|
511
|
-
data: {script, timeout: 50},
|
|
512
|
-
})).data;
|
|
513
|
-
value.message.should.match(/.+50.+timeout.+/);
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
|
|
517
339
|
if (DriverClass === BaseDriver) {
|
|
518
340
|
// only run this test on basedriver, not other drivers which also use these tests, since we
|
|
519
341
|
// don't want them to try and start sessions with these random capabilities that are
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import B from 'bluebird';
|
|
3
|
-
import { DeviceSettings } from '
|
|
3
|
+
import { DeviceSettings } from '../../lib';
|
|
4
4
|
import sinon from 'sinon';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -335,8 +335,8 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
|
|
|
335
335
|
it('should have a #canProxy method', function () {
|
|
336
336
|
d.canProxy.should.be.an.instanceof(Function);
|
|
337
337
|
});
|
|
338
|
-
it('should return
|
|
339
|
-
d.canProxy(sessId).should.be.
|
|
338
|
+
it('should return a boolean from #canProxy', function () {
|
|
339
|
+
d.canProxy(sessId).should.be.a('boolean');
|
|
340
340
|
});
|
|
341
341
|
it('should throw an error when sessionId is wrong', function () {
|
|
342
342
|
(() => { d.canProxy(); }).should.throw;
|
|
@@ -98,6 +98,10 @@ describe('helpers', function () {
|
|
|
98
98
|
sandbox.stub(zip, 'extractAllTo').resolves();
|
|
99
99
|
sandbox.stub(zip, 'assertValidZip').resolves();
|
|
100
100
|
sandbox.stub(fs, 'mv').resolves();
|
|
101
|
+
sandbox.stub(fs, 'stat').resolves({
|
|
102
|
+
isFile: () => true,
|
|
103
|
+
isDirectory: () => false,
|
|
104
|
+
});
|
|
101
105
|
sandbox.stub(fs, 'exists').resolves(true);
|
|
102
106
|
sandbox.stub(fs, 'hash').resolves('0xDEADBEEF');
|
|
103
107
|
sandbox.stub(fs, 'glob').resolves(['/path/to/an.apk']);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { server, routeConfiguringFunction,
|
|
3
|
-
DEFAULT_WS_PATHNAME_PREFIX } from '
|
|
3
|
+
DEFAULT_WS_PATHNAME_PREFIX } from '../../lib';
|
|
4
4
|
import { FakeDriver } from '../protocol/fake-driver';
|
|
5
5
|
import WebSocket from 'ws';
|
|
6
6
|
import B from 'bluebird';
|
package/build/index.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BaseDriver = exports.BASEDRIVER_HANDLED_SETTINGS = exports.ALL_COMMANDS = void 0;
|
|
7
|
-
Object.defineProperty(exports, "DEFAULT_BASE_PATH", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _constants.DEFAULT_BASE_PATH;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.NO_SESSION_ID_COMMANDS = exports.METHOD_MAP = exports.JWProxy = exports.DeviceSettings = exports.DEFAULT_WS_PATHNAME_PREFIX = void 0;
|
|
14
|
-
Object.defineProperty(exports, "PROTOCOLS", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return _constants.PROTOCOLS;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
exports.validateCaps = exports.statusCodes = exports.server = exports.routeToCommandName = exports.routeConfiguringFunction = exports.processCapabilities = exports.normalizeBasePath = exports.isStandardCap = exports.isSessionCommand = exports.isErrorType = exports.getSummaryByCode = exports.errors = exports.errorFromW3CJsonCode = exports.errorFromMJSONWPStatusCode = exports.errorFromCode = exports.determineProtocol = exports.default = exports.STATIC_DIR = exports.Protocol = void 0;
|
|
21
|
-
|
|
22
|
-
require("source-map-support/register");
|
|
23
|
-
|
|
24
|
-
var driver = _interopRequireWildcard(require("./lib/basedriver/driver"));
|
|
25
|
-
|
|
26
|
-
var deviceSettings = _interopRequireWildcard(require("./lib/basedriver/device-settings"));
|
|
27
|
-
|
|
28
|
-
var protocol = _interopRequireWildcard(require("./lib/protocol"));
|
|
29
|
-
|
|
30
|
-
var _constants = require("./lib/constants");
|
|
31
|
-
|
|
32
|
-
var staticIndex = _interopRequireWildcard(require("./lib/express/static"));
|
|
33
|
-
|
|
34
|
-
var serverIndex = _interopRequireWildcard(require("./lib/express/server"));
|
|
35
|
-
|
|
36
|
-
var proxyIndex = _interopRequireWildcard(require("./lib/jsonwp-proxy/proxy"));
|
|
37
|
-
|
|
38
|
-
var statusIndex = _interopRequireWildcard(require("./lib/jsonwp-status/status"));
|
|
39
|
-
|
|
40
|
-
var caps = _interopRequireWildcard(require("./lib/basedriver/capabilities"));
|
|
41
|
-
|
|
42
|
-
var ws = _interopRequireWildcard(require("./lib/express/websocket"));
|
|
43
|
-
|
|
44
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
|
-
|
|
46
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
BaseDriver
|
|
50
|
-
} = driver;
|
|
51
|
-
exports.BaseDriver = BaseDriver;
|
|
52
|
-
const {
|
|
53
|
-
DeviceSettings,
|
|
54
|
-
BASEDRIVER_HANDLED_SETTINGS
|
|
55
|
-
} = deviceSettings;
|
|
56
|
-
exports.BASEDRIVER_HANDLED_SETTINGS = BASEDRIVER_HANDLED_SETTINGS;
|
|
57
|
-
exports.DeviceSettings = DeviceSettings;
|
|
58
|
-
var _default = BaseDriver;
|
|
59
|
-
exports.default = _default;
|
|
60
|
-
const {
|
|
61
|
-
Protocol,
|
|
62
|
-
routeConfiguringFunction,
|
|
63
|
-
errors,
|
|
64
|
-
isErrorType,
|
|
65
|
-
errorFromMJSONWPStatusCode,
|
|
66
|
-
errorFromW3CJsonCode,
|
|
67
|
-
ALL_COMMANDS,
|
|
68
|
-
METHOD_MAP,
|
|
69
|
-
routeToCommandName,
|
|
70
|
-
NO_SESSION_ID_COMMANDS,
|
|
71
|
-
isSessionCommand,
|
|
72
|
-
normalizeBasePath,
|
|
73
|
-
determineProtocol
|
|
74
|
-
} = protocol;
|
|
75
|
-
exports.determineProtocol = determineProtocol;
|
|
76
|
-
exports.normalizeBasePath = normalizeBasePath;
|
|
77
|
-
exports.isSessionCommand = isSessionCommand;
|
|
78
|
-
exports.NO_SESSION_ID_COMMANDS = NO_SESSION_ID_COMMANDS;
|
|
79
|
-
exports.routeToCommandName = routeToCommandName;
|
|
80
|
-
exports.METHOD_MAP = METHOD_MAP;
|
|
81
|
-
exports.ALL_COMMANDS = ALL_COMMANDS;
|
|
82
|
-
exports.errorFromW3CJsonCode = errorFromW3CJsonCode;
|
|
83
|
-
exports.errorFromCode = exports.errorFromMJSONWPStatusCode = errorFromMJSONWPStatusCode;
|
|
84
|
-
exports.isErrorType = isErrorType;
|
|
85
|
-
exports.errors = errors;
|
|
86
|
-
exports.routeConfiguringFunction = routeConfiguringFunction;
|
|
87
|
-
exports.Protocol = Protocol;
|
|
88
|
-
const {
|
|
89
|
-
STATIC_DIR
|
|
90
|
-
} = staticIndex;
|
|
91
|
-
exports.STATIC_DIR = STATIC_DIR;
|
|
92
|
-
const {
|
|
93
|
-
server
|
|
94
|
-
} = serverIndex;
|
|
95
|
-
exports.server = server;
|
|
96
|
-
const {
|
|
97
|
-
JWProxy
|
|
98
|
-
} = proxyIndex;
|
|
99
|
-
exports.JWProxy = JWProxy;
|
|
100
|
-
const {
|
|
101
|
-
codes: statusCodes,
|
|
102
|
-
getSummaryByCode
|
|
103
|
-
} = statusIndex;
|
|
104
|
-
exports.getSummaryByCode = getSummaryByCode;
|
|
105
|
-
exports.statusCodes = statusCodes;
|
|
106
|
-
const {
|
|
107
|
-
processCapabilities,
|
|
108
|
-
isStandardCap,
|
|
109
|
-
validateCaps
|
|
110
|
-
} = caps;
|
|
111
|
-
exports.validateCaps = validateCaps;
|
|
112
|
-
exports.isStandardCap = isStandardCap;
|
|
113
|
-
exports.processCapabilities = processCapabilities;
|
|
114
|
-
const {
|
|
115
|
-
DEFAULT_WS_PATHNAME_PREFIX
|
|
116
|
-
} = ws;
|
|
117
|
-
exports.DEFAULT_WS_PATHNAME_PREFIX = DEFAULT_WS_PATHNAME_PREFIX;require('source-map-support').install();
|
|
118
|
-
|
|
119
|
-
|
|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