@appium/base-driver 10.0.0-beta.0 → 10.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +2 -4
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +12 -31
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +0 -8
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +8 -18
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/driver.js +2 -2
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.d.ts +9 -1
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +56 -142
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/basedriver/validation.d.ts +7 -0
- package/build/lib/basedriver/validation.d.ts.map +1 -0
- package/build/lib/basedriver/validation.js +130 -0
- package/build/lib/basedriver/validation.js.map +1 -0
- package/build/lib/express/middleware.d.ts +0 -6
- package/build/lib/express/middleware.d.ts.map +1 -1
- package/build/lib/express/middleware.js +28 -60
- package/build/lib/express/middleware.js.map +1 -1
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +0 -1
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts +13 -6
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +7 -0
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +3 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.d.ts +0 -8
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +7 -38
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/build/lib/protocol/errors.d.ts +171 -277
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +201 -421
- package/build/lib/protocol/errors.js.map +1 -1
- package/build/lib/protocol/helpers.d.ts +6 -6
- package/build/lib/protocol/helpers.d.ts.map +1 -1
- package/build/lib/protocol/helpers.js +11 -7
- package/build/lib/protocol/helpers.js.map +1 -1
- package/build/lib/protocol/index.d.ts +2 -1
- package/build/lib/protocol/index.d.ts.map +1 -1
- package/build/lib/protocol/index.js +2 -1
- package/build/lib/protocol/index.js.map +1 -1
- package/build/lib/protocol/protocol.d.ts +16 -19
- package/build/lib/protocol/protocol.d.ts.map +1 -1
- package/build/lib/protocol/protocol.js +98 -119
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts +12 -714
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +24 -488
- package/build/lib/protocol/routes.js.map +1 -1
- package/build/lib/protocol/validators.d.ts +4 -7
- package/build/lib/protocol/validators.d.ts.map +1 -1
- package/build/lib/protocol/validators.js +4 -21
- package/build/lib/protocol/validators.js.map +1 -1
- package/lib/basedriver/capabilities.ts +2 -4
- package/lib/basedriver/commands/execute.ts +1 -1
- package/lib/basedriver/commands/timeout.ts +16 -43
- package/lib/basedriver/core.ts +10 -19
- package/lib/basedriver/driver.ts +3 -3
- package/lib/basedriver/helpers.js +61 -167
- package/lib/basedriver/validation.ts +145 -0
- package/lib/express/middleware.js +32 -70
- package/lib/express/server.js +0 -2
- package/lib/helpers/capabilities.js +9 -4
- package/lib/index.js +2 -0
- package/lib/jsonwp-proxy/proxy.js +8 -45
- package/lib/protocol/{errors.js → errors.ts} +322 -436
- package/lib/protocol/helpers.js +12 -8
- package/lib/protocol/index.js +8 -1
- package/lib/protocol/{protocol.js → protocol.ts} +147 -146
- package/lib/protocol/routes.js +26 -498
- package/lib/protocol/validators.ts +19 -0
- package/package.json +10 -11
- package/build/lib/basedriver/desired-caps.d.ts +0 -5
- package/build/lib/basedriver/desired-caps.d.ts.map +0 -1
- package/build/lib/basedriver/desired-caps.js +0 -92
- package/build/lib/basedriver/desired-caps.js.map +0 -1
- package/lib/basedriver/README.md +0 -36
- package/lib/basedriver/desired-caps.js +0 -103
- package/lib/express/README.md +0 -59
- package/lib/jsonwp-proxy/README.md +0 -52
- package/lib/jsonwp-status/README.md +0 -20
- package/lib/protocol/README.md +0 -100
- package/lib/protocol/validators.js +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/base-driver",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.2",
|
|
4
4
|
"description": "Base driver class for Appium drivers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
40
|
"test": "run-p test:unit test:types",
|
|
41
|
-
"test:e2e": "mocha --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
41
|
+
"test:e2e": "mocha --exit --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
42
42
|
"test:smoke": "node ./index.js",
|
|
43
43
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\"",
|
|
44
44
|
"test:types": "tsd"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@appium/support": "^6.0
|
|
48
|
-
"@appium/types": "^0.25.
|
|
47
|
+
"@appium/support": "^6.1.0",
|
|
48
|
+
"@appium/types": "^0.25.3",
|
|
49
49
|
"@colors/colors": "1.6.0",
|
|
50
50
|
"async-lock": "1.4.1",
|
|
51
51
|
"asyncbox": "3.0.0",
|
|
52
|
-
"axios": "1.
|
|
52
|
+
"axios": "1.9.0",
|
|
53
53
|
"bluebird": "3.7.2",
|
|
54
54
|
"body-parser": "1.20.3",
|
|
55
|
-
"express": "
|
|
55
|
+
"express": "5.0.1",
|
|
56
56
|
"fastest-levenshtein": "1.0.16",
|
|
57
57
|
"http-status-codes": "2.3.0",
|
|
58
58
|
"lodash": "4.17.21",
|
|
@@ -62,21 +62,20 @@
|
|
|
62
62
|
"path-to-regexp": "8.2.0",
|
|
63
63
|
"serve-favicon": "2.5.0",
|
|
64
64
|
"source-map-support": "0.5.21",
|
|
65
|
-
"type-fest": "4.
|
|
66
|
-
"validate.js": "0.13.1"
|
|
65
|
+
"type-fest": "4.40.0"
|
|
67
66
|
},
|
|
68
67
|
"optionalDependencies": {
|
|
69
68
|
"spdy": "4.0.2"
|
|
70
69
|
},
|
|
71
70
|
"engines": {
|
|
72
|
-
"node": "^
|
|
73
|
-
"npm": ">=
|
|
71
|
+
"node": "^20.9.0 || >=22.11.0",
|
|
72
|
+
"npm": ">=10"
|
|
74
73
|
},
|
|
75
74
|
"publishConfig": {
|
|
76
75
|
"access": "public",
|
|
77
76
|
"tag": "beta"
|
|
78
77
|
},
|
|
79
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "dc5ef8d5f62c8a0775131305107a4037cd9ec9c9",
|
|
80
79
|
"tsd": {
|
|
81
80
|
"directory": "test/types"
|
|
82
81
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"desired-caps.d.ts","sourceRoot":"","sources":["../../../lib/basedriver/desired-caps.js"],"names":[],"mappings":"AAIA,wBACa,OAAO,aAAa,EAAE,UAAU,GAAG;IAAC,OAAO,EAAE,QAAyB,CAAA;CAAC,CAEhF;cALU,UAAU"}
|
|
@@ -1,92 +0,0 @@
|
|
|
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.validator = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
-
const validate_js_1 = __importDefault(require("validate.js"));
|
|
9
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
10
|
-
exports.validator =
|
|
11
|
-
/** @type {import('validate.js').ValidateJS & {promise: typeof import('bluebird')}} */ (validate_js_1.default);
|
|
12
|
-
exports.validator.validators.isString = function isString(value) {
|
|
13
|
-
if (typeof value === 'string') {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (typeof value === 'undefined') {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return 'must be of type string';
|
|
20
|
-
};
|
|
21
|
-
exports.validator.validators.isNumber = function isNumber(value) {
|
|
22
|
-
if (typeof value === 'number') {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
if (typeof value === 'undefined') {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
// allow a string value
|
|
29
|
-
if (typeof value === 'string' && !isNaN(Number(value))) {
|
|
30
|
-
logger_1.default.warn('Number capability passed in as string. Functionality may be compromised.');
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return 'must be of type number';
|
|
34
|
-
};
|
|
35
|
-
exports.validator.validators.isBoolean = function isBoolean(value) {
|
|
36
|
-
if (typeof value === 'boolean') {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
// allow a string value
|
|
40
|
-
if (typeof value === 'string' && ['true', 'false', ''].includes(value)) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
if (typeof value === 'undefined') {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return 'must be of type boolean';
|
|
47
|
-
};
|
|
48
|
-
exports.validator.validators.isObject = function isObject(value) {
|
|
49
|
-
if (typeof value === 'object') {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
if (typeof value === 'undefined') {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return 'must be of type object';
|
|
56
|
-
};
|
|
57
|
-
exports.validator.validators.isArray = function isArray(value) {
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
if (typeof value === 'undefined') {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return 'must be of type array';
|
|
65
|
-
};
|
|
66
|
-
exports.validator.validators.deprecated = function deprecated(value, options, key) {
|
|
67
|
-
// do not print caps that hasn't been provided.
|
|
68
|
-
if (typeof value !== 'undefined' && options) {
|
|
69
|
-
logger_1.default.warn(`The '${key}' capability has been deprecated and must not be used anymore. ` +
|
|
70
|
-
`Please check the driver documentation for possible alternatives.`);
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
};
|
|
74
|
-
exports.validator.validators.inclusionCaseInsensitive = function inclusionCaseInsensitive(value, options) {
|
|
75
|
-
if (typeof value === 'undefined') {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
else if (typeof value !== 'string') {
|
|
79
|
-
return 'unrecognised';
|
|
80
|
-
}
|
|
81
|
-
for (let option of options) {
|
|
82
|
-
if (option.toLowerCase() === value.toLowerCase()) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return `${value} not part of ${options.toString()}`;
|
|
87
|
-
};
|
|
88
|
-
exports.validator.promise = bluebird_1.default;
|
|
89
|
-
exports.validator.prettify = function prettify(val) {
|
|
90
|
-
return val;
|
|
91
|
-
};
|
|
92
|
-
//# sourceMappingURL=desired-caps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"desired-caps.js","sourceRoot":"","sources":["../../../lib/basedriver/desired-caps.js"],"names":[],"mappings":";;;;;;AAAA,sDAA2B;AAC3B,8DAAqC;AACrC,wDAAyB;AAEZ,QAAA,SAAS;AACpB,sFAAsF,CAAC,CACrF,qBAAU,CACX,CAAC;AAEJ,iBAAS,CAAC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QACd,CAAC;IACH,CAAC;IACD,OAAO,GAAG,KAAK,gBAAgB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;AACtD,CAAC,CAAC;AAEF,iBAAS,CAAC,OAAO,GAAG,kBAAC,CAAC;AACtB,iBAAS,CAAC,QAAQ,GAAG,SAAS,QAAQ,CAAC,GAAG;IACxC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/lib/basedriver/README.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
appium-base-driver
|
|
2
|
-
===================
|
|
3
|
-
This is the parent class that all [appium](appium.io) drivers inherit from. Appium drivers themselves can either be started from the command line as standalone appium servers, or can be included by another module (appium) which then proxies commands to the appropriate driver based on [Desired Capabilities](https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md).
|
|
4
|
-
|
|
5
|
-
An appium driver is a module which processes [Mobile Json Wire Protocol](https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile) commands and controls a device accordingly. The commands can either come in over HTTP as json api requests, or they can be passed to the driver object programmatically as already-parsed json object (without the HTTP headers and junk).
|
|
6
|
-
|
|
7
|
-
The appium Base driver already includes the [mjsonwp](https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/README.md) module, which is the HTTP server that converts incoming requests into json objects that get sent to the driver programmatically.
|
|
8
|
-
|
|
9
|
-
The appium Base driver already has all the REST api routes, validation, and error codes supplied by [mjsonwp](https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/README.md).
|
|
10
|
-
|
|
11
|
-
Appium drivers are designed to have a *single testing session* per instantiation. This means that one Driver object should be attached to a single device and handle commands from a single client. The main appium driver handles multiple sessions and instantiates a new instance of the desired driver for each new session.
|
|
12
|
-
|
|
13
|
-
## Writing your own appium driver
|
|
14
|
-
|
|
15
|
-
Writing your own appium driver starts with inheriting and extending this Base driver module.
|
|
16
|
-
|
|
17
|
-
Appium Base driver has some properties that all drivers share:
|
|
18
|
-
|
|
19
|
-
- `driver.opts` - these are the options passed into the driver constructor. Your driver's constructor should take an object of options and pass it on the the Base driver by calling `super(opts)` in your constructor.
|
|
20
|
-
|
|
21
|
-
- `driver.desiredCapConstraints` - Base driver sets this property with a customer `setter` function so that when you create a driver, you can add an object which defines the validation contraints of which desired capabilities your new driver can handle. Of course each driver will have it's own specific desired capabilities. Look for examples on our other drivers.
|
|
22
|
-
|
|
23
|
-
- `driver.createSession(caps)` - this is the function which gets desired capabilities and creates a session. Make sure to call `super.createSession(caps)` so that things like `this.sessionId` and `this.caps` are populated, and the caps are validated against your `desiredCapConstraints`.
|
|
24
|
-
|
|
25
|
-
- `driver.caps` - these are the desired capabilities for the current session.
|
|
26
|
-
|
|
27
|
-
- `driver.sessionId` - this is the ID of the current session. It gets populated automaticall by `baseDriver.createSession`.
|
|
28
|
-
|
|
29
|
-
- `driver.proxyReqRes()` - used by mjsonwp module for proxying http commands to another process (like chromedriver or selendroid)
|
|
30
|
-
|
|
31
|
-
- `driver.jwpProxyAvoid` - used by mjsonwp module. You can specify what REST api routes which you want to SKIP the automatic proxy to another server (which is optional) and instead be handled by your driver.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Base driver exposes an event called `onUnexpectedShutdown` which is called when the driver is shut down unexpectedly (usually after invocation of the `startUnexpectedShutdown` method).
|
|
35
|
-
|
|
36
|
-
Your driver should also implement a startUnexpectedShutdown method?
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import log from './logger';
|
|
2
|
-
import _validator from 'validate.js';
|
|
3
|
-
import B from 'bluebird';
|
|
4
|
-
|
|
5
|
-
export const validator =
|
|
6
|
-
/** @type {import('validate.js').ValidateJS & {promise: typeof import('bluebird')}} */ (
|
|
7
|
-
_validator
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
validator.validators.isString = function isString(value) {
|
|
11
|
-
if (typeof value === 'string') {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (typeof value === 'undefined') {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return 'must be of type string';
|
|
20
|
-
};
|
|
21
|
-
validator.validators.isNumber = function isNumber(value) {
|
|
22
|
-
if (typeof value === 'number') {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (typeof value === 'undefined') {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// allow a string value
|
|
31
|
-
if (typeof value === 'string' && !isNaN(Number(value))) {
|
|
32
|
-
log.warn('Number capability passed in as string. Functionality may be compromised.');
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return 'must be of type number';
|
|
37
|
-
};
|
|
38
|
-
validator.validators.isBoolean = function isBoolean(value) {
|
|
39
|
-
if (typeof value === 'boolean') {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// allow a string value
|
|
44
|
-
if (typeof value === 'string' && ['true', 'false', ''].includes(value)) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (typeof value === 'undefined') {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return 'must be of type boolean';
|
|
53
|
-
};
|
|
54
|
-
validator.validators.isObject = function isObject(value) {
|
|
55
|
-
if (typeof value === 'object') {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (typeof value === 'undefined') {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return 'must be of type object';
|
|
64
|
-
};
|
|
65
|
-
validator.validators.isArray = function isArray(value) {
|
|
66
|
-
if (Array.isArray(value)) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof value === 'undefined') {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return 'must be of type array';
|
|
75
|
-
};
|
|
76
|
-
validator.validators.deprecated = function deprecated(value, options, key) {
|
|
77
|
-
// do not print caps that hasn't been provided.
|
|
78
|
-
if (typeof value !== 'undefined' && options) {
|
|
79
|
-
log.warn(
|
|
80
|
-
`The '${key}' capability has been deprecated and must not be used anymore. ` +
|
|
81
|
-
`Please check the driver documentation for possible alternatives.`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
};
|
|
86
|
-
validator.validators.inclusionCaseInsensitive = function inclusionCaseInsensitive(value, options) {
|
|
87
|
-
if (typeof value === 'undefined') {
|
|
88
|
-
return null;
|
|
89
|
-
} else if (typeof value !== 'string') {
|
|
90
|
-
return 'unrecognised';
|
|
91
|
-
}
|
|
92
|
-
for (let option of options) {
|
|
93
|
-
if (option.toLowerCase() === value.toLowerCase()) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return `${value} not part of ${options.toString()}`;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
validator.promise = B;
|
|
101
|
-
validator.prettify = function prettify(val) {
|
|
102
|
-
return val;
|
|
103
|
-
};
|
package/lib/express/README.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
## appium-express
|
|
2
|
-
|
|
3
|
-
[Express](http://expressjs.com/) server tuned for to serve [Appium](http://appium.io/).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Configuration
|
|
7
|
-
|
|
8
|
-
The `appium-express` server comes configured with:
|
|
9
|
-
|
|
10
|
-
1. appropriate logging formats
|
|
11
|
-
2. service of necessary static assets
|
|
12
|
-
3. allowance of cross-domain requests
|
|
13
|
-
4. default error handling
|
|
14
|
-
5. fix for invalid content types sent by certain clients
|
|
15
|
-
|
|
16
|
-
To configure routes, a function that takes an Express server is passed into the
|
|
17
|
-
server. This function can add whatever routes are wanted.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Usage
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
import { server } from 'appium-base-driver';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// configure the routes
|
|
27
|
-
function configureRoutes (app) {
|
|
28
|
-
app.get('/hello', (req, res) => {
|
|
29
|
-
res.header['content-type'] = 'text/html';
|
|
30
|
-
res.status(200).send('Hello');
|
|
31
|
-
});
|
|
32
|
-
app.get('/world', (req, res) => {
|
|
33
|
-
res.header['content-type'] = 'text/html';
|
|
34
|
-
res.status(200).send('World');
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const port = 5000;
|
|
39
|
-
const host = 'localhost';
|
|
40
|
-
|
|
41
|
-
const appiumServer = await server({
|
|
42
|
-
routeConfiguringFunction,
|
|
43
|
-
port,
|
|
44
|
-
host,
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## Watch
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
npm run watch
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Test
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
npm test
|
|
59
|
-
```
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
## appium-jsonwp-proxy
|
|
2
|
-
|
|
3
|
-
Proxy middleware for the Selenium [JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md). Allows
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Usage
|
|
7
|
-
|
|
8
|
-
The proxy is used by instantiating with the details of the Selenium server to which to proxy. The options for the constructor are passed as a hash with the following possible members:
|
|
9
|
-
|
|
10
|
-
- `scheme` - defaults to 'http'
|
|
11
|
-
- `server` - defaults to 'localhost'
|
|
12
|
-
- `port` - defaults to `4444`
|
|
13
|
-
- `base` - defaults to ''
|
|
14
|
-
- `sessionId` - the session id of the session on the remote server
|
|
15
|
-
- `reqBasePath` - the base path of the server which the request was originally sent to (defaults to '')
|
|
16
|
-
|
|
17
|
-
Once the proxy is created, there are two `async` methods:
|
|
18
|
-
|
|
19
|
-
`command (url, method, body)`
|
|
20
|
-
|
|
21
|
-
Sends a "command" to the proxied server, using the "url", which is the endpoing, with the HTTP method and optional body.
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { JWProxy } from 'appium-base-driver';
|
|
25
|
-
|
|
26
|
-
let host = 'my.host.com';
|
|
27
|
-
let port = 4445;
|
|
28
|
-
|
|
29
|
-
let proxy = new JWProxy({server: host, port: port});
|
|
30
|
-
|
|
31
|
-
// get the Selenium server status
|
|
32
|
-
let seStatus = await proxy.command('/status', 'GET');
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
`proxyReqRes (req, res)`
|
|
36
|
-
|
|
37
|
-
Proxies a request and response to the proxied server. Used to handle the entire conversation of a request/response cycle.
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
import { JWProxy } from 'appium-base-driver';
|
|
41
|
-
import http from 'http';
|
|
42
|
-
|
|
43
|
-
let host = 'my.host.com';
|
|
44
|
-
let port = 4445;
|
|
45
|
-
|
|
46
|
-
let proxy = new JWProxy({server: host, port: port});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
http.createServer(function (req, res) {
|
|
50
|
-
await proxy.proxyReqRes(res, res);
|
|
51
|
-
}).listen(9615);
|
|
52
|
-
```
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
## jsonwp-status
|
|
2
|
-
|
|
3
|
-
Library of status codes for the Selenium [JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Usage
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
import { statusCodes } from 'appium-base-driver';
|
|
10
|
-
|
|
11
|
-
statusCodes.NoSuchContext;
|
|
12
|
-
// -> {code: 35, summary: 'No such context found'}
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
import { getSummaryByCode } from 'appium-base-driver';
|
|
17
|
-
|
|
18
|
-
getSummaryByCode(0);
|
|
19
|
-
// -> 'The command executed successfully.'
|
|
20
|
-
```
|
package/lib/protocol/README.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
## webdriver and mobile-json-wire protocols
|
|
2
|
-
|
|
3
|
-
An abstraction of the Mobile JSON Wire Protocol ([spec](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)) and the W3C Wire Protocol ([spec](https://www.w3.org/TR/webdriver/) with Appium extensions (as specified [here](http://www.w3.org/TR/webdriver/#protocol-extensions)).
|
|
4
|
-
|
|
5
|
-
### Protocol Detection
|
|
6
|
-
|
|
7
|
-
In the event that a session is requested, and both MJSONWP _and_ W3C capabilities are provided, like this
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
{
|
|
11
|
-
"capabilities: {
|
|
12
|
-
"alwaysMatch": {...},
|
|
13
|
-
"firstMatch": [{...}, ...]
|
|
14
|
-
},
|
|
15
|
-
"desiredCapabilities": {...}
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
a W3C session will be served _unless_ the W3C Capabilities are incomplete. So if the `"desiredCapabilities"` object has more keys
|
|
20
|
-
then whatever the capabilities were matched for the W3C capabilities, then an MJSONWP session will be served instead
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Endpoints in the protocol
|
|
24
|
-
|
|
25
|
-
The Mobile JSON Wire Protocol package gives access to a number of endpoints documented [here](https://github.com/appium/appium-base-driver/blob/master/docs/mjsonwp/protocol-methods.md).
|
|
26
|
-
|
|
27
|
-
The W3C WebDriver Protocol package gives access to a number of endpoints documented in the [official documentation](https://www.w3.org/TR/webdriver/) and the
|
|
28
|
-
[simplified spec](https://github.com/jlipps/simple-wd-spec)
|
|
29
|
-
|
|
30
|
-
### Protocol
|
|
31
|
-
|
|
32
|
-
The basic class, subclassed by drivers that will use the protocol.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### routeConfiguringFunction (driver)
|
|
36
|
-
|
|
37
|
-
This function gives drivers access to the protocol routes. It returns a function that itself will take an [Express](http://expressjs.com/) application.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### isSessionCommand (command)
|
|
41
|
-
|
|
42
|
-
Checks if the `command` needs to have a session associated with it.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### ALL_COMMANDS
|
|
46
|
-
|
|
47
|
-
An array of all the commands that will be dispatched to by the Mobile JSON Wire Proxy endpoints.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### NO_SESSION_ID_COMMANDS
|
|
51
|
-
|
|
52
|
-
An array of commands that do not need a session associated with them.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Errors
|
|
56
|
-
|
|
57
|
-
This package exports a number of classes and methods related to Selenium error handling. There are error classes for each Selenium error type (see [JSONWP Errors](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes), as well as the context errors in the [mobile spec](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts).
|
|
58
|
-
|
|
59
|
-
The list of errors, and their meanings, can be found [here for JSONWP](https://github.com/appium/appium-base-driver/blob/master/docs/mjsonwp/errors.md) and
|
|
60
|
-
[here for W3C Errors](https://www.w3.org/TR/webdriver/#handling-errors))
|
|
61
|
-
|
|
62
|
-
There are, in addition, two helper methods for dealing with errors
|
|
63
|
-
|
|
64
|
-
`isErrorType (err, type)`
|
|
65
|
-
|
|
66
|
-
- checks if the `err` object is a Mobile JSON Wire Protocol error of a particular type
|
|
67
|
-
- arguments
|
|
68
|
-
- `err` - the error object to test
|
|
69
|
-
- `type` - the error class to test against
|
|
70
|
-
- usage
|
|
71
|
-
```js
|
|
72
|
-
import { errors, isErrorType } from 'mobile-json-wire-protocol';
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
// do some stuff...
|
|
76
|
-
} catch (err) {
|
|
77
|
-
if (isErrorType(err, errors.InvalidCookieDomainError)) {
|
|
78
|
-
// process...
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
`errorFromCode (code, message)`
|
|
84
|
-
|
|
85
|
-
- retrieve the appropriate error for an error code, with the supplied message.
|
|
86
|
-
- arguments
|
|
87
|
-
- `code` - the integer error code for a Mobile JSON Wire Protocol error
|
|
88
|
-
- `message` - the message to be encapsulated in the error
|
|
89
|
-
- usage
|
|
90
|
-
```js
|
|
91
|
-
import { errors, errorFromCode } from 'mobile-json-wire-protocol';
|
|
92
|
-
|
|
93
|
-
let error = errorFromCode(6, 'an error has occurred');
|
|
94
|
-
|
|
95
|
-
console.log(error instanceof errors.NoSuchDriverError);
|
|
96
|
-
// => true
|
|
97
|
-
|
|
98
|
-
console.log(error.message === 'an error has occurred');
|
|
99
|
-
// => true
|
|
100
|
-
```
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
|
|
3
|
-
function isNumber(o) {
|
|
4
|
-
return _.isNumber(o) || !_.isNaN(parseInt(o, 10)) || !_.isNaN(parseFloat(o));
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function msValidator(ms) {
|
|
8
|
-
if (!_.isNumber(ms) || ms < 0) {
|
|
9
|
-
throw new Error('Wait ms must be a number equal to 0 or greater');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const validators = {
|
|
14
|
-
setUrl: (url) => {
|
|
15
|
-
// either an `xyz://`, `about:`, or `data:` scheme is allowed
|
|
16
|
-
if (!url || !url.match(/^([a-zA-Z0-9_+.-]+:\/\/)|(about:)|(data:)/)) {
|
|
17
|
-
throw new Error('Url or Uri must start with <scheme>://');
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
implicitWait: (ms) => {
|
|
21
|
-
msValidator(ms);
|
|
22
|
-
},
|
|
23
|
-
asyncScriptTimeout: (ms) => {
|
|
24
|
-
msValidator(ms);
|
|
25
|
-
},
|
|
26
|
-
clickCurrent: (button) => {
|
|
27
|
-
if (!(isNumber(button) || _.isUndefined(button)) || button < 0 || button > 2) {
|
|
28
|
-
throw new Error('Click button must be 0, 1, or 2');
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
setNetworkConnection: (type) => {
|
|
32
|
-
if (!isNumber(type) || [0, 1, 2, 4, 6].indexOf(type) === -1) {
|
|
33
|
-
throw new Error('Network type must be one of 0, 1, 2, 4, 6');
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export {validators};
|