@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.
- package/LICENSE +1 -1
- package/build/lib/basedriver/commands/event.d.ts +5 -9
- package/build/lib/basedriver/commands/event.d.ts.map +1 -1
- package/build/lib/basedriver/commands/event.js +28 -49
- package/build/lib/basedriver/commands/event.js.map +1 -1
- package/build/lib/basedriver/commands/execute.d.ts +5 -11
- package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
- package/build/lib/basedriver/commands/execute.js +15 -39
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/find.d.ts +5 -12
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +38 -98
- package/build/lib/basedriver/commands/find.js.map +1 -1
- package/build/lib/basedriver/commands/index.d.ts +7 -3
- package/build/lib/basedriver/commands/index.d.ts.map +1 -1
- package/build/lib/basedriver/commands/index.js +20 -27
- package/build/lib/basedriver/commands/index.js.map +1 -1
- package/build/lib/basedriver/commands/log.d.ts +5 -10
- package/build/lib/basedriver/commands/log.d.ts.map +1 -1
- package/build/lib/basedriver/commands/log.js +17 -50
- package/build/lib/basedriver/commands/log.js.map +1 -1
- package/build/lib/basedriver/commands/mixin.d.ts +12 -0
- package/build/lib/basedriver/commands/mixin.d.ts.map +1 -0
- package/build/lib/basedriver/commands/mixin.js +17 -0
- package/build/lib/basedriver/commands/mixin.js.map +1 -0
- package/build/lib/basedriver/commands/session.d.ts +5 -11
- package/build/lib/basedriver/commands/session.d.ts.map +1 -1
- package/build/lib/basedriver/commands/session.js +20 -52
- package/build/lib/basedriver/commands/session.js.map +1 -1
- package/build/lib/basedriver/commands/settings.d.ts +5 -9
- package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
- package/build/lib/basedriver/commands/settings.js +14 -34
- package/build/lib/basedriver/commands/settings.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.d.ts +5 -9
- package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +107 -126
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +2 -4
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +0 -2
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/driver.d.ts +12 -12
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +22 -14
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/express/server.d.ts +3 -15
- package/build/lib/express/server.d.ts.map +1 -1
- package/lib/basedriver/commands/event.ts +48 -0
- package/lib/basedriver/commands/execute.ts +39 -0
- package/lib/basedriver/commands/find.ts +79 -0
- package/lib/basedriver/commands/index.ts +7 -0
- package/lib/basedriver/commands/log.ts +36 -0
- package/lib/basedriver/commands/mixin.ts +14 -0
- package/lib/basedriver/commands/session.ts +34 -0
- package/lib/basedriver/commands/settings.ts +25 -0
- package/lib/basedriver/commands/timeout.ts +155 -0
- package/lib/basedriver/core.js +0 -3
- package/lib/basedriver/driver.js +8 -11
- package/package.json +6 -6
- package/lib/basedriver/commands/event.js +0 -63
- package/lib/basedriver/commands/execute.js +0 -45
- package/lib/basedriver/commands/find.js +0 -108
- package/lib/basedriver/commands/index.js +0 -35
- package/lib/basedriver/commands/log.js +0 -64
- package/lib/basedriver/commands/session.js +0 -57
- package/lib/basedriver/commands/settings.js +0 -38
- 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
|
-
*/
|