@appium/fake-driver 3.2.13 → 4.0.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.
@@ -7,10 +7,10 @@ exports.default = void 0;
7
7
 
8
8
  require("source-map-support/register");
9
9
 
10
- var _support = require("@appium/support");
10
+ var _support = require("appium/support");
11
11
 
12
12
  const log = _support.logger.getLogger('FakeDriver');
13
13
 
14
14
  var _default = log;
15
15
  exports.default = _default;
16
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJsb2ciLCJsb2dnZXIiLCJnZXRMb2dnZXIiXSwic291cmNlcyI6WyIuLi8uLi9saWIvbG9nZ2VyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGxvZ2dlciB9IGZyb20gJ0BhcHBpdW0vc3VwcG9ydCc7XG5cblxuY29uc3QgbG9nID0gbG9nZ2VyLmdldExvZ2dlcignRmFrZURyaXZlcicpO1xuXG5leHBvcnQgZGVmYXVsdCBsb2c7XG4iXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBOztBQUdBLE1BQU1BLEdBQUcsR0FBR0MsZ0JBQU9DLFNBQVAsQ0FBaUIsWUFBakIsQ0FBWjs7ZUFFZUYsRyJ9
16
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJsb2ciLCJsb2dnZXIiLCJnZXRMb2dnZXIiXSwic291cmNlcyI6WyIuLi8uLi9saWIvbG9nZ2VyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7bG9nZ2VyfSBmcm9tICdhcHBpdW0vc3VwcG9ydCc7XG5cbmNvbnN0IGxvZyA9IGxvZ2dlci5nZXRMb2dnZXIoJ0Zha2VEcml2ZXInKTtcblxuZXhwb3J0IGRlZmF1bHQgbG9nO1xuIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFBQTs7QUFFQSxNQUFNQSxHQUFHLEdBQUdDLGVBQUEsQ0FBT0MsU0FBUCxDQUFpQixZQUFqQixDQUFaOztlQUVlRixHIn0=
@@ -7,4 +7,4 @@ require("source-map-support/register");
7
7
  var _logger = _interopRequireDefault(require("../logger"));
8
8
 
9
9
  _logger.default.info('Successfully ran the script');
10
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJsb2ciLCJpbmZvIl0sInNvdXJjZXMiOlsiLi4vLi4vLi4vbGliL3NjcmlwdHMvZmFrZS1zdWNjZXNzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBsb2cgZnJvbSAnLi4vbG9nZ2VyJztcblxubG9nLmluZm8oJ1N1Y2Nlc3NmdWxseSByYW4gdGhlIHNjcmlwdCcpO1xuIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7QUFFQUEsZ0JBQUlDLElBQUosQ0FBUyw2QkFBVCJ9
10
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJsb2ciLCJpbmZvIl0sInNvdXJjZXMiOlsiLi4vLi4vLi4vbGliL3NjcmlwdHMvZmFrZS1zdWNjZXNzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBsb2cgZnJvbSAnLi4vbG9nZ2VyJztcblxubG9nLmluZm8oJ1N1Y2Nlc3NmdWxseSByYW4gdGhlIHNjcmlwdCcpO1xuIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7QUFFQUEsZUFBQSxDQUFJQyxJQUFKLENBQVMsNkJBQVQifQ==
@@ -11,14 +11,14 @@ require("source-map-support/register");
11
11
 
12
12
  var _logger = _interopRequireDefault(require("./logger"));
13
13
 
14
- var _baseDriver = require("@appium/base-driver");
14
+ var _driver = require("appium/driver");
15
15
 
16
- var _driver = require("./driver");
16
+ var _driver2 = require("./driver");
17
17
 
18
18
  async function startServer(port, hostname) {
19
- const d = new _driver.FakeDriver();
20
- const server = await (0, _baseDriver.server)({
21
- routeConfiguringFunction: (0, _baseDriver.routeConfiguringFunction)(d),
19
+ const d = new _driver2.FakeDriver();
20
+ const server = await (0, _driver.server)({
21
+ routeConfiguringFunction: (0, _driver.routeConfiguringFunction)(d),
22
22
  port,
23
23
  hostname
24
24
  });
@@ -27,4 +27,4 @@ async function startServer(port, hostname) {
27
27
 
28
28
  return server;
29
29
  }
30
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJzdGFydFNlcnZlciIsInBvcnQiLCJob3N0bmFtZSIsImQiLCJGYWtlRHJpdmVyIiwic2VydmVyIiwicm91dGVDb25maWd1cmluZ0Z1bmN0aW9uIiwibG9nIiwiaW5mbyJdLCJzb3VyY2VzIjpbIi4uLy4uL2xpYi9zZXJ2ZXIuanMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGxvZyBmcm9tICcuL2xvZ2dlcic7XG5pbXBvcnQgeyBzZXJ2ZXIgYXMgYmFzZVNlcnZlciwgcm91dGVDb25maWd1cmluZ0Z1bmN0aW9uIH0gZnJvbSAnQGFwcGl1bS9iYXNlLWRyaXZlcic7XG5pbXBvcnQgeyBGYWtlRHJpdmVyIH0gZnJvbSAnLi9kcml2ZXInO1xuXG5cbmFzeW5jIGZ1bmN0aW9uIHN0YXJ0U2VydmVyIChwb3J0LCBob3N0bmFtZSkge1xuICBjb25zdCBkID0gbmV3IEZha2VEcml2ZXIoKTtcbiAgY29uc3Qgc2VydmVyID0gYXdhaXQgYmFzZVNlcnZlcih7XG4gICAgcm91dGVDb25maWd1cmluZ0Z1bmN0aW9uOiByb3V0ZUNvbmZpZ3VyaW5nRnVuY3Rpb24oZCksXG4gICAgcG9ydCxcbiAgICBob3N0bmFtZSxcbiAgfSk7XG4gIGxvZy5pbmZvKGBGYWtlRHJpdmVyIHNlcnZlciBsaXN0ZW5pbmcgb24gaHR0cDovLyR7aG9zdG5hbWV9OiR7cG9ydH1gKTtcbiAgcmV0dXJuIHNlcnZlcjtcbn1cblxuZXhwb3J0IHsgc3RhcnRTZXJ2ZXIgfTtcbiJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7QUFBQTs7QUFDQTs7QUFDQTs7QUFHQSxlQUFlQSxXQUFmLENBQTRCQyxJQUE1QixFQUFrQ0MsUUFBbEMsRUFBNEM7RUFDMUMsTUFBTUMsQ0FBQyxHQUFHLElBQUlDLGtCQUFKLEVBQVY7RUFDQSxNQUFNQyxNQUFNLEdBQUcsTUFBTSx3QkFBVztJQUM5QkMsd0JBQXdCLEVBQUUsMENBQXlCSCxDQUF6QixDQURJO0lBRTlCRixJQUY4QjtJQUc5QkM7RUFIOEIsQ0FBWCxDQUFyQjs7RUFLQUssZ0JBQUlDLElBQUosQ0FBVSx5Q0FBd0NOLFFBQVMsSUFBR0QsSUFBSyxFQUFuRTs7RUFDQSxPQUFPSSxNQUFQO0FBQ0QifQ==
30
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJzdGFydFNlcnZlciIsInBvcnQiLCJob3N0bmFtZSIsImQiLCJGYWtlRHJpdmVyIiwic2VydmVyIiwiYmFzZVNlcnZlciIsInJvdXRlQ29uZmlndXJpbmdGdW5jdGlvbiIsImxvZyIsImluZm8iXSwic291cmNlcyI6WyIuLi8uLi9saWIvc2VydmVyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBsb2cgZnJvbSAnLi9sb2dnZXInO1xuaW1wb3J0IHtzZXJ2ZXIgYXMgYmFzZVNlcnZlciwgcm91dGVDb25maWd1cmluZ0Z1bmN0aW9ufSBmcm9tICdhcHBpdW0vZHJpdmVyJztcbmltcG9ydCB7RmFrZURyaXZlcn0gZnJvbSAnLi9kcml2ZXInO1xuXG5hc3luYyBmdW5jdGlvbiBzdGFydFNlcnZlcihwb3J0LCBob3N0bmFtZSkge1xuICBjb25zdCBkID0gbmV3IEZha2VEcml2ZXIoKTtcbiAgY29uc3Qgc2VydmVyID0gYXdhaXQgYmFzZVNlcnZlcih7XG4gICAgcm91dGVDb25maWd1cmluZ0Z1bmN0aW9uOiByb3V0ZUNvbmZpZ3VyaW5nRnVuY3Rpb24oZCksXG4gICAgcG9ydCxcbiAgICBob3N0bmFtZSxcbiAgfSk7XG4gIGxvZy5pbmZvKGBGYWtlRHJpdmVyIHNlcnZlciBsaXN0ZW5pbmcgb24gaHR0cDovLyR7aG9zdG5hbWV9OiR7cG9ydH1gKTtcbiAgcmV0dXJuIHNlcnZlcjtcbn1cblxuZXhwb3J0IHtzdGFydFNlcnZlcn07XG4iXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0FBQUE7O0FBQ0E7O0FBQ0E7O0FBRUEsZUFBZUEsV0FBZixDQUEyQkMsSUFBM0IsRUFBaUNDLFFBQWpDLEVBQTJDO0VBQ3pDLE1BQU1DLENBQUMsR0FBRyxJQUFJQyxtQkFBSixFQUFWO0VBQ0EsTUFBTUMsTUFBTSxHQUFHLE1BQU0sSUFBQUMsY0FBQSxFQUFXO0lBQzlCQyx3QkFBd0IsRUFBRSxJQUFBQSxnQ0FBQSxFQUF5QkosQ0FBekIsQ0FESTtJQUU5QkYsSUFGOEI7SUFHOUJDO0VBSDhCLENBQVgsQ0FBckI7O0VBS0FNLGVBQUEsQ0FBSUMsSUFBSixDQUFVLHlDQUF3Q1AsUUFBUyxJQUFHRCxJQUFLLEVBQW5FOztFQUNBLE9BQU9JLE1BQVA7QUFDRCJ9
@@ -1,25 +1,27 @@
1
- import { errors } from '@appium/base-driver';
1
+ import {errors} from 'appium/driver';
2
2
 
3
- let commands = {}, helpers = {}, extensions = {};
3
+ let commands = {},
4
+ helpers = {},
5
+ extensions = {};
4
6
 
5
- helpers.assertNoAlert = function assertNoAlert () {
7
+ helpers.assertNoAlert = function assertNoAlert() {
6
8
  if (this.appModel.hasAlert()) {
7
9
  throw new errors.UnexpectedAlertOpenError();
8
10
  }
9
11
  };
10
12
 
11
- helpers.assertAlert = function assertAlert () {
13
+ helpers.assertAlert = function assertAlert() {
12
14
  if (!this.appModel.hasAlert()) {
13
15
  throw new errors.NoAlertOpenError();
14
16
  }
15
17
  };
16
18
 
17
- commands.getAlertText = async function getAlertText () {
19
+ commands.getAlertText = async function getAlertText() {
18
20
  this.assertAlert();
19
21
  return this.appModel.alertText();
20
22
  };
21
23
 
22
- commands.setAlertText = async function setAlertText (text) {
24
+ commands.setAlertText = async function setAlertText(text) {
23
25
  this.assertAlert();
24
26
  try {
25
27
  this.appModel.setAlertText(text);
@@ -28,7 +30,7 @@ commands.setAlertText = async function setAlertText (text) {
28
30
  }
29
31
  };
30
32
 
31
- commands.postAcceptAlert = async function postAcceptAlert () {
33
+ commands.postAcceptAlert = async function postAcceptAlert() {
32
34
  this.assertAlert();
33
35
  this.appModel.handleAlert();
34
36
  };
@@ -36,5 +38,5 @@ commands.postAcceptAlert = async function postAcceptAlert () {
36
38
  commands.postDismissAlert = commands.postAcceptAlert;
37
39
 
38
40
  Object.assign(extensions, commands, helpers);
39
- export { commands, helpers };
41
+ export {commands, helpers};
40
42
  export default extensions;
@@ -1,9 +1,11 @@
1
1
  import _ from 'lodash';
2
- import { errors } from '@appium/base-driver';
2
+ import {errors} from 'appium/driver';
3
3
 
4
- let commands = {}, helpers = {}, extensions = {};
4
+ let commands = {},
5
+ helpers = {},
6
+ extensions = {};
5
7
 
6
- helpers.getRawContexts = function getRawContexts () {
8
+ helpers.getRawContexts = function getRawContexts() {
7
9
  let contexts = {NATIVE_APP: null, PROXY: null};
8
10
  let wvs = this.appModel.getWebviews();
9
11
  for (let i = 1; i < wvs.length + 1; i++) {
@@ -12,21 +14,21 @@ helpers.getRawContexts = function getRawContexts () {
12
14
  return contexts;
13
15
  };
14
16
 
15
- helpers.assertWebviewContext = function assertWebviewContext () {
17
+ helpers.assertWebviewContext = function assertWebviewContext() {
16
18
  if (this.curContext === 'NATIVE_APP') {
17
19
  throw new errors.InvalidContextError();
18
20
  }
19
21
  };
20
22
 
21
- commands.getCurrentContext = async function getCurrentContext () {
23
+ commands.getCurrentContext = async function getCurrentContext() {
22
24
  return this.curContext;
23
25
  };
24
26
 
25
- commands.getContexts = async function getContexts () {
27
+ commands.getContexts = async function getContexts() {
26
28
  return _.keys(this.getRawContexts());
27
29
  };
28
30
 
29
- commands.setContext = async function setContext (context) {
31
+ commands.setContext = async function setContext(context) {
30
32
  let contexts = this.getRawContexts();
31
33
  if (_.includes(_.keys(contexts), context)) {
32
34
  this.curContext = context;
@@ -44,7 +46,7 @@ commands.setContext = async function setContext (context) {
44
46
  }
45
47
  };
46
48
 
47
- commands.setFrame = async function setFrame (frameId) {
49
+ commands.setFrame = async function setFrame(frameId) {
48
50
  this.assertWebviewContext();
49
51
  if (frameId === null) {
50
52
  this.appModel.deactivateFrame();
@@ -58,5 +60,5 @@ commands.setFrame = async function setFrame (frameId) {
58
60
  };
59
61
 
60
62
  Object.assign(extensions, commands, helpers);
61
- export { commands, helpers };
63
+ export {commands, helpers};
62
64
  export default extensions;
@@ -1,9 +1,11 @@
1
1
  import _ from 'lodash';
2
- import { errors } from '@appium/base-driver';
2
+ import {errors} from 'appium/driver';
3
3
 
4
- let commands = {}, helpers = {}, extensions = {};
4
+ let commands = {},
5
+ helpers = {},
6
+ extensions = {};
5
7
 
6
- helpers.getElements = function getElements (elIds) {
8
+ helpers.getElements = function getElements(elIds) {
7
9
  for (let elId of elIds) {
8
10
  if (!_.has(this.elMap, elId)) {
9
11
  throw new errors.StaleElementReferenceError();
@@ -12,31 +14,31 @@ helpers.getElements = function getElements (elIds) {
12
14
  return elIds.map((e) => this.elMap[e]);
13
15
  };
14
16
 
15
- helpers.getElement = function getElement (elId) {
17
+ helpers.getElement = function getElement(elId) {
16
18
  return this.getElements([elId])[0];
17
19
  };
18
20
 
19
- commands.getName = async function getName (elementId) {
21
+ commands.getName = async function getName(elementId) {
20
22
  let el = this.getElement(elementId);
21
23
  return el.tagName;
22
24
  };
23
25
 
24
- commands.elementDisplayed = async function elementDisplayed (elementId) {
26
+ commands.elementDisplayed = async function elementDisplayed(elementId) {
25
27
  let el = this.getElement(elementId);
26
28
  return el.isVisible();
27
29
  };
28
30
 
29
- commands.elementEnabled = async function elementEnabled (elementId) {
31
+ commands.elementEnabled = async function elementEnabled(elementId) {
30
32
  let el = this.getElement(elementId);
31
33
  return el.isEnabled();
32
34
  };
33
35
 
34
- commands.elementSelected = async function elementSelected (elementId) {
36
+ commands.elementSelected = async function elementSelected(elementId) {
35
37
  let el = this.getElement(elementId);
36
38
  return el.isSelected();
37
39
  };
38
40
 
39
- commands.setValue = async function setValue (keys, elementId) {
41
+ commands.setValue = async function setValue(keys, elementId) {
40
42
  let value = keys;
41
43
  if (keys instanceof Array) {
42
44
  value = keys.join('');
@@ -48,16 +50,16 @@ commands.setValue = async function setValue (keys, elementId) {
48
50
  el.setAttr('value', value);
49
51
  };
50
52
 
51
- commands.getText = async function getText (elementId) {
53
+ commands.getText = async function getText(elementId) {
52
54
  let el = this.getElement(elementId);
53
55
  return el.getAttr('value');
54
56
  };
55
57
 
56
- commands.clear = async function clear (elementId) {
58
+ commands.clear = async function clear(elementId) {
57
59
  await this.setValue('', elementId);
58
60
  };
59
61
 
60
- commands.click = async function click (elementId) {
62
+ commands.click = async function click(elementId) {
61
63
  this.assertNoAlert();
62
64
  let el = this.getElement(elementId);
63
65
  if (!el.isVisible()) {
@@ -67,22 +69,22 @@ commands.click = async function click (elementId) {
67
69
  this.focusedElId = elementId;
68
70
  };
69
71
 
70
- commands.getAttribute = async function getAttribute (attr, elementId) {
72
+ commands.getAttribute = async function getAttribute(attr, elementId) {
71
73
  let el = this.getElement(elementId);
72
74
  return el.getAttr(attr);
73
75
  };
74
76
 
75
- commands.getElementRect = function getElementRect (elementId) {
77
+ commands.getElementRect = function getElementRect(elementId) {
76
78
  let el = this.getElement(elementId);
77
79
  return el.getElementRect();
78
80
  };
79
81
 
80
- commands.getSize = function getSize (elementId) {
82
+ commands.getSize = function getSize(elementId) {
81
83
  let el = this.getElement(elementId);
82
84
  return el.getSize();
83
85
  };
84
86
 
85
- commands.equalsElement = function equalsElement (el1Id, el2Id) {
87
+ commands.equalsElement = function equalsElement(el1Id, el2Id) {
86
88
  let el1 = this.getElement(el1Id);
87
89
  let el2 = this.getElement(el2Id);
88
90
  return el1.equals(el2);
@@ -90,12 +92,12 @@ commands.equalsElement = function equalsElement (el1Id, el2Id) {
90
92
 
91
93
  commands.getLocationInView = commands.getLocation;
92
94
 
93
- commands.getCssProperty = async function getCssProperty (prop, elementId) {
95
+ commands.getCssProperty = async function getCssProperty(prop, elementId) {
94
96
  this.assertWebviewContext();
95
97
  let el = this.getElement(elementId);
96
98
  return el.getCss(prop);
97
99
  };
98
100
 
99
101
  Object.assign(extensions, commands, helpers);
100
- export { commands, helpers };
102
+ export {commands, helpers};
101
103
  export default extensions;
@@ -1,10 +1,12 @@
1
1
  import _ from 'lodash';
2
- import { errors } from '@appium/base-driver';
3
- import { FakeElement } from '../fake-element';
2
+ import {errors} from 'appium/driver';
3
+ import {FakeElement} from '../fake-element';
4
4
 
5
- let commands = {}, helpers = {}, extensions = {};
5
+ let commands = {},
6
+ helpers = {},
7
+ extensions = {};
6
8
 
7
- helpers.getExistingElementForNode = function getExistingElementForNode (node) {
9
+ helpers.getExistingElementForNode = function getExistingElementForNode(node) {
8
10
  for (let [id, el] of _.toPairs(this.elMap)) {
9
11
  if (el.node === node) {
10
12
  return id;
@@ -13,7 +15,7 @@ helpers.getExistingElementForNode = function getExistingElementForNode (node) {
13
15
  return null;
14
16
  };
15
17
 
16
- helpers.wrapNewEl = function wrapNewEl (obj) {
18
+ helpers.wrapNewEl = function wrapNewEl(obj) {
17
19
  // first check and see if we already have a ref to this element
18
20
  let existingElId = this.getExistingElementForNode(obj);
19
21
  if (existingElId) {
@@ -26,14 +28,14 @@ helpers.wrapNewEl = function wrapNewEl (obj) {
26
28
  return {ELEMENT: this.maxElId.toString()};
27
29
  };
28
30
 
29
- helpers.findElOrEls = async function findElOrEls (strategy, selector, mult, ctx) {
31
+ helpers.findElOrEls = async function findElOrEls(strategy, selector, mult, ctx) {
30
32
  let qMap = {
31
- 'xpath': 'xpathQuery',
32
- 'id': 'idQuery',
33
+ xpath: 'xpathQuery',
34
+ id: 'idQuery',
33
35
  'accessibility id': 'idQuery',
34
36
  'class name': 'classQuery',
35
37
  'tag name': 'classQuery',
36
- 'css selector': 'cssQuery'
38
+ 'css selector': 'cssQuery',
37
39
  };
38
40
  // TODO this error checking should probably be part of MJSONWP?
39
41
  if (!_.includes(_.keys(qMap), strategy)) {
@@ -60,24 +62,32 @@ helpers.findElOrEls = async function findElOrEls (strategy, selector, mult, ctx)
60
62
  }
61
63
  };
62
64
 
63
- commands.findElement = async function findElement (strategy, selector) {
65
+ commands.findElement = async function findElement(strategy, selector) {
64
66
  return this.findElOrEls(strategy, selector, false);
65
67
  };
66
68
 
67
- commands.findElements = async function findElements (strategy, selector) {
69
+ commands.findElements = async function findElements(strategy, selector) {
68
70
  return this.findElOrEls(strategy, selector, true);
69
71
  };
70
72
 
71
- commands.findElementFromElement = async function findElementFromElement (strategy, selector, elementId) {
73
+ commands.findElementFromElement = async function findElementFromElement(
74
+ strategy,
75
+ selector,
76
+ elementId
77
+ ) {
72
78
  let el = this.getElement(elementId);
73
79
  return this.findElOrEls(strategy, selector, false, el.xmlFragment);
74
80
  };
75
81
 
76
- commands.findElementsFromElement = async function findElementsFromElement (strategy, selector, elementId) {
82
+ commands.findElementsFromElement = async function findElementsFromElement(
83
+ strategy,
84
+ selector,
85
+ elementId
86
+ ) {
77
87
  let el = this.getElement(elementId);
78
88
  return this.findElOrEls(strategy, selector, true, el.xmlFragment);
79
89
  };
80
90
 
81
91
  Object.assign(extensions, commands, helpers);
82
- export { commands, helpers};
92
+ export {commands, helpers};
83
93
  export default extensions;
@@ -1,65 +1,66 @@
1
1
  import _ from 'lodash';
2
- import { errors } from '@appium/base-driver';
2
+ import {errors} from 'appium/driver';
3
3
 
4
- let commands = {}, helpers = {}, extensions = {};
4
+ let commands = {},
5
+ helpers = {},
6
+ extensions = {};
5
7
 
6
- commands.title = async function title () {
8
+ commands.title = async function title() {
7
9
  this.assertWebviewContext();
8
10
  return this.appModel.title;
9
11
  };
10
12
 
11
- commands.keys = async function keys (value) {
13
+ commands.keys = async function keys(value) {
12
14
  if (!this.focusedElId) {
13
15
  throw new errors.InvalidElementStateError();
14
16
  }
15
17
  await this.setValue(value, this.focusedElId);
16
18
  };
17
19
 
18
- commands.setGeoLocation = async function setGeoLocation (location) {
20
+ commands.setGeoLocation = async function setGeoLocation(location) {
19
21
  // TODO test this adequately once WD bug is fixed
20
22
  this.appModel.lat = location.latitude;
21
23
  this.appModel.long = location.longitude;
22
24
  };
23
25
 
24
- commands.getGeoLocation = async function getGeoLocation () {
26
+ commands.getGeoLocation = async function getGeoLocation() {
25
27
  return this.appModel.currentGeoLocation;
26
28
  };
27
29
 
28
- commands.getPageSource = async function getPageSource () {
30
+ commands.getPageSource = async function getPageSource() {
29
31
  return this.appModel.rawXml;
30
32
  };
31
33
 
32
- commands.getOrientation = async function getOrientation () {
34
+ commands.getOrientation = async function getOrientation() {
33
35
  return this.appModel.orientation;
34
36
  };
35
37
 
36
- commands.setOrientation = async function setOrientation (o) {
38
+ commands.setOrientation = async function setOrientation(o) {
37
39
  if (!_.includes(['LANDSCAPE', 'PORTRAIT'], o)) {
38
40
  throw new errors.UnknownError('Orientation must be LANDSCAPE or PORTRAIT');
39
41
  }
40
42
  this.appModel.orientation = o;
41
43
  };
42
44
 
43
- commands.getScreenshot = async function getScreenshot () {
45
+ commands.getScreenshot = async function getScreenshot() {
44
46
  return this.appModel.getScreenshot();
45
47
  };
46
48
 
47
- commands.getWindowSize = async function getWindowSize () {
49
+ commands.getWindowSize = async function getWindowSize() {
48
50
  return {width: this.appModel.width, height: this.appModel.height};
49
51
  };
50
52
 
51
- commands.getWindowRect = async function getWindowRect () {
53
+ commands.getWindowRect = async function getWindowRect() {
52
54
  return {width: this.appModel.width, height: this.appModel.height, x: 0, y: 0};
53
55
  };
54
56
 
55
- commands.performActions = async function performActions (actions) {
57
+ commands.performActions = async function performActions(actions) {
56
58
  this.appModel.actionLog.push(actions);
57
59
  };
58
60
 
59
- commands.releaseActions = async function releaseActions () {
60
- };
61
+ commands.releaseActions = async function releaseActions() {};
61
62
 
62
- commands.getLog = async function getLog (type) {
63
+ commands.getLog = async function getLog(type) {
63
64
  switch (type) {
64
65
  case 'actions':
65
66
  return this.appModel.actionLog;
@@ -69,5 +70,5 @@ commands.getLog = async function getLog (type) {
69
70
  };
70
71
 
71
72
  Object.assign(extensions, commands, helpers);
72
- export { commands, helpers };
73
+ export {commands, helpers};
73
74
  export default extensions;
@@ -7,12 +7,12 @@ import alertCommands from './alert';
7
7
  let commands = {};
8
8
 
9
9
  Object.assign(
10
- commands,
11
- contextCommands,
12
- findCommands,
13
- elementCommands,
14
- generalCommands,
15
- alertCommands
10
+ commands,
11
+ contextCommands,
12
+ findCommands,
13
+ elementCommands,
14
+ generalCommands,
15
+ alertCommands
16
16
  );
17
17
 
18
18
  export default commands;
package/lib/driver.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import B from 'bluebird';
2
2
  import _ from 'lodash';
3
- import { BaseDriver, errors } from '@appium/base-driver';
4
- import { FakeApp } from './fake-app';
3
+ import {BaseDriver, errors} from 'appium/driver';
4
+ import {FakeApp} from './fake-app';
5
5
  import commands from './commands';
6
6
 
7
7
  class FakeDriver extends BaseDriver {
8
- constructor (opts = {}, shouldValidateCaps = true) {
8
+ constructor(opts = {}, shouldValidateCaps = true) {
9
9
  super(opts, shouldValidateCaps);
10
10
  this.appModel = null;
11
11
  this.curContext = 'NATIVE_APP';
@@ -18,22 +18,22 @@ class FakeDriver extends BaseDriver {
18
18
  this._proxyActive = false;
19
19
 
20
20
  this.desiredCapConstraints = {
21
- 'app': {
21
+ app: {
22
22
  presence: true,
23
- isString: true
24
- }
23
+ isString: true,
24
+ },
25
25
  };
26
26
  }
27
27
 
28
- proxyActive () {
28
+ proxyActive() {
29
29
  return this._proxyActive;
30
30
  }
31
31
 
32
- canProxy () {
32
+ canProxy() {
33
33
  return true;
34
34
  }
35
35
 
36
- proxyReqRes (req, res) {
36
+ proxyReqRes(req, res) {
37
37
  // fake implementation of jwp proxy req res
38
38
  res.set('content-type', 'application/json');
39
39
  const resBodyObj = {value: 'proxied via proxyReqRes'};
@@ -42,12 +42,16 @@ class FakeDriver extends BaseDriver {
42
42
  res.status(200).send(JSON.stringify(resBodyObj));
43
43
  }
44
44
 
45
- proxyCommand (/*url, method, body*/) {
45
+ proxyCommand(/*url, method, body*/) {
46
46
  return 'proxied via proxyCommand';
47
47
  }
48
48
 
49
- async createSession (jsonwpDesiredCapabilities, jsonwpRequiredCaps, w3cCapabilities, otherSessionData = []) {
50
-
49
+ async createSession(
50
+ jsonwpDesiredCapabilities,
51
+ jsonwpRequiredCaps,
52
+ w3cCapabilities,
53
+ otherSessionData = []
54
+ ) {
51
55
  // TODO add validation on caps.app that we will get for free from
52
56
  // BaseDriver
53
57
 
@@ -55,12 +59,19 @@ class FakeDriver extends BaseDriver {
55
59
  // not being able to start a session because of system resources
56
60
  for (let d of otherSessionData) {
57
61
  if (d.isUnique) {
58
- throw new errors.SessionNotCreatedError('Cannot start session; another ' +
59
- 'unique session is in progress that requires all resources');
62
+ throw new errors.SessionNotCreatedError(
63
+ 'Cannot start session; another ' +
64
+ 'unique session is in progress that requires all resources'
65
+ );
60
66
  }
61
67
  }
62
68
 
63
- let [sessionId, caps] = await super.createSession(jsonwpDesiredCapabilities, jsonwpRequiredCaps, w3cCapabilities, otherSessionData);
69
+ let [sessionId, caps] = await super.createSession(
70
+ jsonwpDesiredCapabilities,
71
+ jsonwpRequiredCaps,
72
+ w3cCapabilities,
73
+ otherSessionData
74
+ );
64
75
  this.appModel = new FakeApp();
65
76
  if (_.isArray(caps) === true && caps.length === 1) {
66
77
  caps = caps[0];
@@ -70,24 +81,24 @@ class FakeDriver extends BaseDriver {
70
81
  return [sessionId, caps];
71
82
  }
72
83
 
73
- get driverData () {
84
+ get driverData() {
74
85
  return {
75
- isUnique: !!this.caps.uniqueApp
86
+ isUnique: !!this.caps.uniqueApp,
76
87
  };
77
88
  }
78
89
 
79
- async getFakeThing () {
90
+ async getFakeThing() {
80
91
  await B.delay(1);
81
92
  return this.fakeThing;
82
93
  }
83
94
 
84
- async setFakeThing (thing) {
95
+ async setFakeThing(thing) {
85
96
  await B.delay(1);
86
97
  this.fakeThing = thing;
87
98
  return null;
88
99
  }
89
100
 
90
- async getFakeDriverArgs () {
101
+ async getFakeDriverArgs() {
91
102
  await B.delay(1);
92
103
  return this.cliArgs;
93
104
  }
@@ -95,23 +106,23 @@ class FakeDriver extends BaseDriver {
95
106
  static newMethodMap = {
96
107
  '/session/:sessionId/fakedriver': {
97
108
  GET: {command: 'getFakeThing'},
98
- POST: {command: 'setFakeThing', payloadParams: {required: ['thing']}}
109
+ POST: {command: 'setFakeThing', payloadParams: {required: ['thing']}},
99
110
  },
100
111
  '/session/:sessionId/fakedriverargs': {
101
- GET: {command: 'getFakeDriverArgs'}
112
+ GET: {command: 'getFakeDriverArgs'},
102
113
  },
103
114
  };
104
115
 
105
- static fakeRoute (req, res) {
116
+ static fakeRoute(req, res) {
106
117
  res.send(JSON.stringify({fakedriver: 'fakeResponse'}));
107
118
  }
108
119
 
109
- static async updateServer (expressApp/*, httpServer*/) { // eslint-disable-line require-await
120
+ static async updateServer(expressApp /*, httpServer*/) {
121
+ // eslint-disable-line require-await
110
122
  expressApp.all('/fakedriver', FakeDriver.fakeRoute);
111
123
  }
112
-
113
124
  }
114
125
 
115
126
  Object.assign(FakeDriver.prototype, commands);
116
127
 
117
- export { FakeDriver };
128
+ export {FakeDriver};