@appium/base-driver 9.3.2 → 9.3.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.
Files changed (67) hide show
  1. package/LICENSE +1 -1
  2. package/build/lib/basedriver/commands/event.d.ts +5 -9
  3. package/build/lib/basedriver/commands/event.d.ts.map +1 -1
  4. package/build/lib/basedriver/commands/event.js +28 -49
  5. package/build/lib/basedriver/commands/event.js.map +1 -1
  6. package/build/lib/basedriver/commands/execute.d.ts +5 -11
  7. package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
  8. package/build/lib/basedriver/commands/execute.js +15 -39
  9. package/build/lib/basedriver/commands/execute.js.map +1 -1
  10. package/build/lib/basedriver/commands/find.d.ts +5 -12
  11. package/build/lib/basedriver/commands/find.d.ts.map +1 -1
  12. package/build/lib/basedriver/commands/find.js +38 -98
  13. package/build/lib/basedriver/commands/find.js.map +1 -1
  14. package/build/lib/basedriver/commands/index.d.ts +7 -3
  15. package/build/lib/basedriver/commands/index.d.ts.map +1 -1
  16. package/build/lib/basedriver/commands/index.js +20 -27
  17. package/build/lib/basedriver/commands/index.js.map +1 -1
  18. package/build/lib/basedriver/commands/log.d.ts +5 -10
  19. package/build/lib/basedriver/commands/log.d.ts.map +1 -1
  20. package/build/lib/basedriver/commands/log.js +17 -50
  21. package/build/lib/basedriver/commands/log.js.map +1 -1
  22. package/build/lib/basedriver/commands/mixin.d.ts +12 -0
  23. package/build/lib/basedriver/commands/mixin.d.ts.map +1 -0
  24. package/build/lib/basedriver/commands/mixin.js +17 -0
  25. package/build/lib/basedriver/commands/mixin.js.map +1 -0
  26. package/build/lib/basedriver/commands/session.d.ts +5 -11
  27. package/build/lib/basedriver/commands/session.d.ts.map +1 -1
  28. package/build/lib/basedriver/commands/session.js +20 -52
  29. package/build/lib/basedriver/commands/session.js.map +1 -1
  30. package/build/lib/basedriver/commands/settings.d.ts +5 -9
  31. package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
  32. package/build/lib/basedriver/commands/settings.js +14 -34
  33. package/build/lib/basedriver/commands/settings.js.map +1 -1
  34. package/build/lib/basedriver/commands/timeout.d.ts +5 -9
  35. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
  36. package/build/lib/basedriver/commands/timeout.js +107 -126
  37. package/build/lib/basedriver/commands/timeout.js.map +1 -1
  38. package/build/lib/basedriver/core.d.ts +2 -4
  39. package/build/lib/basedriver/core.d.ts.map +1 -1
  40. package/build/lib/basedriver/core.js +0 -2
  41. package/build/lib/basedriver/core.js.map +1 -1
  42. package/build/lib/basedriver/driver.d.ts +12 -12
  43. package/build/lib/basedriver/driver.d.ts.map +1 -1
  44. package/build/lib/basedriver/driver.js +22 -14
  45. package/build/lib/basedriver/driver.js.map +1 -1
  46. package/build/lib/express/server.d.ts +3 -15
  47. package/build/lib/express/server.d.ts.map +1 -1
  48. package/lib/basedriver/commands/event.ts +48 -0
  49. package/lib/basedriver/commands/execute.ts +39 -0
  50. package/lib/basedriver/commands/find.ts +79 -0
  51. package/lib/basedriver/commands/index.ts +7 -0
  52. package/lib/basedriver/commands/log.ts +36 -0
  53. package/lib/basedriver/commands/mixin.ts +14 -0
  54. package/lib/basedriver/commands/session.ts +34 -0
  55. package/lib/basedriver/commands/settings.ts +25 -0
  56. package/lib/basedriver/commands/timeout.ts +155 -0
  57. package/lib/basedriver/core.js +0 -3
  58. package/lib/basedriver/driver.js +8 -11
  59. package/package.json +6 -6
  60. package/lib/basedriver/commands/event.js +0 -63
  61. package/lib/basedriver/commands/execute.js +0 -45
  62. package/lib/basedriver/commands/find.js +0 -108
  63. package/lib/basedriver/commands/index.js +0 -35
  64. package/lib/basedriver/commands/log.js +0 -64
  65. package/lib/basedriver/commands/session.js +0 -57
  66. package/lib/basedriver/commands/settings.js +0 -38
  67. package/lib/basedriver/commands/timeout.js +0 -168
@@ -1,168 +0,0 @@
1
- // @ts-check
2
-
3
- /* eslint-disable no-unused-vars */
4
- /* eslint-disable require-await */
5
- import {waitForCondition} from 'asyncbox';
6
- import _ from 'lodash';
7
- import {util} from '@appium/support';
8
- import {errors} from '../../protocol';
9
-
10
- const MIN_TIMEOUT = 0;
11
-
12
- /**
13
- * @template {Constraints} C
14
- * @param {import('../driver').BaseDriverBase<C>} Base
15
- * @returns {TimeoutBase<C>}
16
- */
17
- export function TimeoutMixin(Base) {
18
- /**
19
- * @implements {ITimeoutCommands}
20
- */
21
- class TimeoutCommands extends Base {
22
- async timeouts(type, ms, script, pageLoad, implicit) {
23
- if (util.hasValue(type) && util.hasValue(ms)) {
24
- this.log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
25
-
26
- switch (type) {
27
- case 'command':
28
- await this.newCommandTimeout(ms);
29
- return;
30
- case 'implicit':
31
- await this.implicitWaitMJSONWP(ms);
32
- return;
33
- case 'page load':
34
- await this.pageLoadTimeoutMJSONWP(ms);
35
- return;
36
- case 'script':
37
- await this.scriptTimeoutMJSONWP(ms);
38
- return;
39
- default:
40
- throw new Error(`'${type}' type is not supported for MJSONWP timeout`);
41
- }
42
- }
43
-
44
- // Otherwise assume it is W3C protocol
45
- this.log.debug(
46
- `W3C timeout argument: ${JSON.stringify({
47
- script,
48
- pageLoad,
49
- implicit,
50
- })}}`
51
- );
52
- if (util.hasValue(script)) {
53
- await this.scriptTimeoutW3C(script);
54
- }
55
- if (util.hasValue(pageLoad)) {
56
- await this.pageLoadTimeoutW3C(pageLoad);
57
- }
58
- if (util.hasValue(implicit)) {
59
- await this.implicitWaitW3C(implicit);
60
- }
61
- }
62
-
63
- async getTimeouts() {
64
- return {
65
- command: this.newCommandTimeoutMs,
66
- implicit: this.implicitWaitMs,
67
- };
68
- }
69
-
70
- // implicit
71
- async implicitWaitW3C(ms) {
72
- await this.implicitWait(ms);
73
- }
74
-
75
- async implicitWaitMJSONWP(ms) {
76
- await this.implicitWait(ms);
77
- }
78
-
79
- async implicitWait(ms) {
80
- await this.setImplicitWait(this.parseTimeoutArgument(ms));
81
- }
82
-
83
- // pageLoad
84
- async pageLoadTimeoutW3C(ms) {
85
- throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
86
- }
87
-
88
- async pageLoadTimeoutMJSONWP(ms) {
89
- throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
90
- }
91
-
92
- // script
93
- async scriptTimeoutW3C(ms) {
94
- throw new errors.NotImplementedError('Not implemented yet for script.');
95
- }
96
-
97
- async scriptTimeoutMJSONWP(ms) {
98
- throw new errors.NotImplementedError('Not implemented yet for script.');
99
- }
100
-
101
- // command
102
- async newCommandTimeout(ms) {
103
- this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
104
- }
105
-
106
- setImplicitWait(ms) {
107
- // eslint-disable-line require-await
108
- this.implicitWaitMs = ms;
109
- this.log.debug(`Set implicit wait to ${ms}ms`);
110
- if (this.managedDrivers && this.managedDrivers.length) {
111
- this.log.debug('Setting implicit wait on managed drivers');
112
- for (let driver of this.managedDrivers) {
113
- if (_.isFunction(driver.setImplicitWait)) {
114
- driver.setImplicitWait(ms);
115
- }
116
- }
117
- }
118
- }
119
-
120
- setNewCommandTimeout(ms) {
121
- this.newCommandTimeoutMs = ms;
122
- this.log.debug(`Set new command timeout to ${ms}ms`);
123
- if (this.managedDrivers && this.managedDrivers.length) {
124
- this.log.debug('Setting new command timeout on managed drivers');
125
- for (let driver of this.managedDrivers) {
126
- if (_.isFunction(driver.setNewCommandTimeout)) {
127
- driver.setNewCommandTimeout(ms);
128
- }
129
- }
130
- }
131
- }
132
-
133
- async implicitWaitForCondition(condFn) {
134
- this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
135
- let wrappedCondFn = async (...args) => {
136
- // reset command timeout
137
- await this.clearNewCommandTimeout();
138
-
139
- return await condFn(...args);
140
- };
141
- return await waitForCondition(wrappedCondFn, {
142
- waitMs: this.implicitWaitMs,
143
- intervalMs: 500,
144
- logger: this.log,
145
- });
146
- }
147
-
148
- parseTimeoutArgument(ms) {
149
- let duration = parseInt(ms, 10);
150
- if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
151
- throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
152
- }
153
- return duration;
154
- }
155
- }
156
-
157
- return TimeoutCommands;
158
- }
159
-
160
- /**
161
- * @typedef {import('@appium/types').ITimeoutCommands} ITimeoutCommands
162
- * @typedef {import('@appium/types').Constraints} Constraints
163
- */
164
-
165
- /**
166
- * @template {Constraints} C
167
- * @typedef {import('../driver').BaseDriverBase<C, ITimeoutCommands>} TimeoutBase
168
- */