@appium/fake-driver 3.0.5 → 3.2.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/build/lib/commands/alert.js +1 -1
- package/build/lib/commands/contexts.js +8 -3
- package/build/lib/commands/element.js +1 -1
- package/build/lib/commands/find.js +1 -1
- package/build/lib/commands/general.js +1 -1
- package/build/lib/driver.js +29 -18
- package/build/lib/fake-driver-schema.js +31 -0
- package/build/lib/index.js +48 -0
- package/build/lib/scripts/fake-error.js +2 -2
- package/build/lib/scripts/fake-success.js +2 -2
- package/build/screen.png +0 -0
- package/build/test/alert-tests.js +64 -0
- package/build/test/command-specs.js +33 -0
- package/build/test/context-tests.js +63 -0
- package/build/test/driver-e2e-specs.js +85 -0
- package/build/test/driver-specs.js +49 -0
- package/build/test/element-interaction-tests.js +133 -0
- package/build/test/find-element-tests.js +88 -0
- package/build/test/fixtures/app.xml +38 -0
- package/build/test/general-tests.js +118 -0
- package/build/test/helpers.js +69 -0
- package/index.js +1 -27
- package/lib/commands/contexts.js +5 -1
- package/lib/driver.js +23 -14
- package/lib/fake-driver-schema.js +36 -0
- package/lib/index.js +29 -0
- package/lib/scripts/fake-error.js +1 -1
- package/lib/scripts/fake-success.js +1 -1
- package/package.json +10 -17
- package/build/index.js +0 -48
package/lib/driver.js
CHANGED
|
@@ -5,17 +5,6 @@ import { FakeApp } from './fake-app';
|
|
|
5
5
|
import commands from './commands';
|
|
6
6
|
|
|
7
7
|
class FakeDriver extends BaseDriver {
|
|
8
|
-
static get argsConstraints () {
|
|
9
|
-
return {
|
|
10
|
-
sillyWebServerPort: {
|
|
11
|
-
isNumber: true
|
|
12
|
-
},
|
|
13
|
-
sillyWebServerHost: {
|
|
14
|
-
isString: true
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
8
|
constructor (opts = {}, shouldValidateCaps = true) {
|
|
20
9
|
super(opts, shouldValidateCaps);
|
|
21
10
|
this.appModel = null;
|
|
@@ -26,6 +15,7 @@ class FakeDriver extends BaseDriver {
|
|
|
26
15
|
this.caps = {};
|
|
27
16
|
this.fakeThing = null;
|
|
28
17
|
this.cliArgs = {};
|
|
18
|
+
this._proxyActive = false;
|
|
29
19
|
|
|
30
20
|
this.desiredCapConstraints = {
|
|
31
21
|
'app': {
|
|
@@ -35,6 +25,27 @@ class FakeDriver extends BaseDriver {
|
|
|
35
25
|
};
|
|
36
26
|
}
|
|
37
27
|
|
|
28
|
+
proxyActive () {
|
|
29
|
+
return this._proxyActive;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
canProxy () {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
proxyReqRes (req, res) {
|
|
37
|
+
// fake implementation of jwp proxy req res
|
|
38
|
+
res.set('content-type', 'application/json');
|
|
39
|
+
const resBodyObj = {value: 'proxied via proxyReqRes'};
|
|
40
|
+
const match = req.originalUrl.match(/\/session\/([^/]+)/);
|
|
41
|
+
resBodyObj.sessionId = match ? match[1] : null;
|
|
42
|
+
res.status(200).send(JSON.stringify(resBodyObj));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
proxyCommand (/*url, method, body*/) {
|
|
46
|
+
return 'proxied via proxyCommand';
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
async createSession (jsonwpDesiredCapabilities, jsonwpRequiredCaps, w3cCapabilities, otherSessionData = []) {
|
|
39
50
|
|
|
40
51
|
// TODO add validation on caps.app that we will get for free from
|
|
@@ -101,8 +112,6 @@ class FakeDriver extends BaseDriver {
|
|
|
101
112
|
|
|
102
113
|
}
|
|
103
114
|
|
|
104
|
-
|
|
105
|
-
FakeDriver.prototype[cmd] = fn;
|
|
106
|
-
}
|
|
115
|
+
Object.assign(FakeDriver.prototype, commands);
|
|
107
116
|
|
|
108
117
|
export { FakeDriver };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// this could be a .json file, too:
|
|
2
|
+
// {
|
|
3
|
+
// "$schema": "http://json-schema.org/draft-07/schema",
|
|
4
|
+
// "$id": "https://appium.io/fake-driver.json",
|
|
5
|
+
// "type": "object",
|
|
6
|
+
// "title": "Fake Driver Configuration",
|
|
7
|
+
// "description": "A schema for Fake Driver arguments",
|
|
8
|
+
// "properties": {
|
|
9
|
+
// "answer": {
|
|
10
|
+
// "type": "number",
|
|
11
|
+
// "description": "The answer to life, the universe, and everything",
|
|
12
|
+
// "default": 42
|
|
13
|
+
// }
|
|
14
|
+
// }
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
type: 'object',
|
|
20
|
+
title: 'Fake Driver Configuration',
|
|
21
|
+
description: 'A schema for Fake Driver arguments',
|
|
22
|
+
properties: {
|
|
23
|
+
// the prop name will always be normalized to camelCase
|
|
24
|
+
'silly-web-server-port': {
|
|
25
|
+
type: 'integer',
|
|
26
|
+
minimum: 1,
|
|
27
|
+
maximum: 65535,
|
|
28
|
+
description: 'The port to use for the fake web server',
|
|
29
|
+
},
|
|
30
|
+
sillyWebServerHost: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'The host to use for the fake web server',
|
|
33
|
+
default: 'sillyhost'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// transpile:main
|
|
3
|
+
|
|
4
|
+
import { asyncify } from 'asyncbox';
|
|
5
|
+
import * as driver from './driver';
|
|
6
|
+
import * as server from './server';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const { FakeDriver } = driver;
|
|
10
|
+
const { startServer } = server;
|
|
11
|
+
|
|
12
|
+
const DEFAULT_HOST = 'localhost';
|
|
13
|
+
const DEFAULT_PORT = 4774;
|
|
14
|
+
|
|
15
|
+
async function main () {
|
|
16
|
+
const getArgValue = (argName) => {
|
|
17
|
+
const argIndex = process.argv.indexOf(argName);
|
|
18
|
+
return argIndex > 0 ? process.argv[argIndex + 1] : null;
|
|
19
|
+
};
|
|
20
|
+
const port = parseInt(getArgValue('--port'), 10) || DEFAULT_PORT;
|
|
21
|
+
const host = getArgValue('--host') || DEFAULT_HOST;
|
|
22
|
+
return await startServer(port, host);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
asyncify(main);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { FakeDriver, startServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
throw Error('
|
|
1
|
+
throw Error('Unsuccessfully ran the script');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/fake-driver",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Description goes here.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"author": "https://github.com/appium",
|
|
24
|
-
"main": "./build/index.js",
|
|
25
24
|
"bin": {
|
|
26
|
-
"appium-fake-driver": "
|
|
25
|
+
"appium-fake-driver": "index.js"
|
|
27
26
|
},
|
|
28
27
|
"directories": {
|
|
29
28
|
"lib": "lib"
|
|
@@ -31,25 +30,21 @@
|
|
|
31
30
|
"files": [
|
|
32
31
|
"index.js",
|
|
33
32
|
"lib",
|
|
34
|
-
"build
|
|
35
|
-
"build/lib",
|
|
33
|
+
"build",
|
|
36
34
|
"test/fixtures",
|
|
37
35
|
"screen.png"
|
|
38
36
|
],
|
|
39
37
|
"dependencies": {
|
|
40
|
-
"@appium/base-driver": "^8.
|
|
41
|
-
"@appium/support": "^2.
|
|
42
|
-
"@babel/runtime": "7.
|
|
43
|
-
"asyncbox": "2.9.
|
|
38
|
+
"@appium/base-driver": "^8.2.2",
|
|
39
|
+
"@appium/support": "^2.55.2",
|
|
40
|
+
"@babel/runtime": "7.16.3",
|
|
41
|
+
"asyncbox": "2.9.2",
|
|
44
42
|
"bluebird": "3.7.2",
|
|
45
43
|
"lodash": "4.17.21",
|
|
46
|
-
"source-map-support": "0.5.
|
|
44
|
+
"source-map-support": "0.5.21",
|
|
47
45
|
"xmldom": "0.6.0",
|
|
48
46
|
"xpath": "0.0.32"
|
|
49
47
|
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@appium/gulp-plugins": "^5.5.3"
|
|
52
|
-
},
|
|
53
48
|
"engines": {
|
|
54
49
|
"node": ">=12",
|
|
55
50
|
"npm": ">=6"
|
|
@@ -62,17 +57,15 @@
|
|
|
62
57
|
"Fake"
|
|
63
58
|
],
|
|
64
59
|
"mainClass": "FakeDriver",
|
|
60
|
+
"schema": "./build/lib/fake-driver-schema.js",
|
|
65
61
|
"scripts": {
|
|
66
62
|
"fake-error": "./build/lib/scripts/fake-error.js",
|
|
67
63
|
"fake-success": "./build/lib/scripts/fake-success.js"
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
|
-
"greenkeeper": {
|
|
71
|
-
"ignore": []
|
|
72
|
-
},
|
|
73
66
|
"publishConfig": {
|
|
74
67
|
"access": "public"
|
|
75
68
|
},
|
|
76
69
|
"homepage": "https://appium.io",
|
|
77
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "280d409df6c02d36b4ffc4d02a95ab3f4649b08c"
|
|
78
71
|
}
|
package/build/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.startServer = exports.FakeDriver = void 0;
|
|
8
|
-
|
|
9
|
-
require("source-map-support/register");
|
|
10
|
-
|
|
11
|
-
var _asyncbox = require("asyncbox");
|
|
12
|
-
|
|
13
|
-
var driver = _interopRequireWildcard(require("./lib/driver"));
|
|
14
|
-
|
|
15
|
-
var server = _interopRequireWildcard(require("./lib/server"));
|
|
16
|
-
|
|
17
|
-
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); }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
const {
|
|
22
|
-
FakeDriver
|
|
23
|
-
} = driver;
|
|
24
|
-
exports.FakeDriver = FakeDriver;
|
|
25
|
-
const {
|
|
26
|
-
startServer
|
|
27
|
-
} = server;
|
|
28
|
-
exports.startServer = startServer;
|
|
29
|
-
const DEFAULT_HOST = 'localhost';
|
|
30
|
-
const DEFAULT_PORT = 4774;
|
|
31
|
-
|
|
32
|
-
async function main() {
|
|
33
|
-
const getArgValue = argName => {
|
|
34
|
-
const argIndex = process.argv.indexOf(argName);
|
|
35
|
-
return argIndex > 0 ? process.argv[argIndex + 1] : null;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const port = parseInt(getArgValue('--port'), 10) || DEFAULT_PORT;
|
|
39
|
-
const host = getArgValue('--host') || DEFAULT_HOST;
|
|
40
|
-
return await startServer(port, host);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (require.main === module) {
|
|
44
|
-
(0, _asyncbox.asyncify)(main);
|
|
45
|
-
}require('source-map-support').install();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIkZha2VEcml2ZXIiLCJkcml2ZXIiLCJzdGFydFNlcnZlciIsInNlcnZlciIsIkRFRkFVTFRfSE9TVCIsIkRFRkFVTFRfUE9SVCIsIm1haW4iLCJnZXRBcmdWYWx1ZSIsImFyZ05hbWUiLCJhcmdJbmRleCIsInByb2Nlc3MiLCJhcmd2IiwiaW5kZXhPZiIsInBvcnQiLCJwYXJzZUludCIsImhvc3QiLCJyZXF1aXJlIiwibW9kdWxlIl0sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7OztBQUdBOztBQUNBOztBQUNBOzs7Ozs7QUFHQSxNQUFNO0FBQUVBLEVBQUFBO0FBQUYsSUFBaUJDLE1BQXZCOztBQUNBLE1BQU07QUFBRUMsRUFBQUE7QUFBRixJQUFrQkMsTUFBeEI7O0FBRUEsTUFBTUMsWUFBWSxHQUFHLFdBQXJCO0FBQ0EsTUFBTUMsWUFBWSxHQUFHLElBQXJCOztBQUVBLGVBQWVDLElBQWYsR0FBdUI7QUFDckIsUUFBTUMsV0FBVyxHQUFJQyxPQUFELElBQWE7QUFDL0IsVUFBTUMsUUFBUSxHQUFHQyxPQUFPLENBQUNDLElBQVIsQ0FBYUMsT0FBYixDQUFxQkosT0FBckIsQ0FBakI7QUFDQSxXQUFPQyxRQUFRLEdBQUcsQ0FBWCxHQUFlQyxPQUFPLENBQUNDLElBQVIsQ0FBYUYsUUFBUSxHQUFHLENBQXhCLENBQWYsR0FBNEMsSUFBbkQ7QUFDRCxHQUhEOztBQUlBLFFBQU1JLElBQUksR0FBR0MsUUFBUSxDQUFDUCxXQ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