@@ -50,8 +50,8 @@ export class Android extends ChannelOwner<channels.AndroidChannel, channels.Andr
50
50
}
51
51
52
52
async devices ( ) : Promise < AndroidDevice [ ] > {
53
- return this . _wrapApiCall ( 'android.devices' , async ( ) => {
54
- const { devices } = await this . _channel . devices ( ) ;
53
+ return this . _wrapApiCall ( 'android.devices' , async ( channel : channels . AndroidChannel ) => {
54
+ const { devices } = await channel . devices ( ) ;
55
55
return devices . map ( d => AndroidDevice . from ( d ) ) ;
56
56
} ) ;
57
57
}
@@ -116,14 +116,14 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel, c
116
116
}
117
117
118
118
async wait ( selector : api . AndroidSelector , options ?: { state ?: 'gone' } & types . TimeoutOptions ) {
119
- await this . _wrapApiCall ( 'androidDevice.wait' , async ( ) => {
120
- await this . _channel . wait ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
119
+ await this . _wrapApiCall ( 'androidDevice.wait' , async ( channel : channels . AndroidDeviceChannel ) => {
120
+ await channel . wait ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
121
121
} ) ;
122
122
}
123
123
124
124
async fill ( selector : api . AndroidSelector , text : string , options ?: types . TimeoutOptions ) {
125
- await this . _wrapApiCall ( 'androidDevice.fill' , async ( ) => {
126
- await this . _channel . fill ( { selector : toSelectorChannel ( selector ) , text, ...options } ) ;
125
+ await this . _wrapApiCall ( 'androidDevice.fill' , async ( channel : channels . AndroidDeviceChannel ) => {
126
+ await channel . fill ( { selector : toSelectorChannel ( selector ) , text, ...options } ) ;
127
127
} ) ;
128
128
}
129
129
@@ -133,62 +133,62 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel, c
133
133
}
134
134
135
135
async tap ( selector : api . AndroidSelector , options ?: { duration ?: number } & types . TimeoutOptions ) {
136
- await this . _wrapApiCall ( 'androidDevice.tap' , async ( ) => {
137
- await this . _channel . tap ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
136
+ await this . _wrapApiCall ( 'androidDevice.tap' , async ( channel : channels . AndroidDeviceChannel ) => {
137
+ await channel . tap ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
138
138
} ) ;
139
139
}
140
140
141
141
async drag ( selector : api . AndroidSelector , dest : types . Point , options ?: SpeedOptions & types . TimeoutOptions ) {
142
- await this . _wrapApiCall ( 'androidDevice.drag' , async ( ) => {
143
- await this . _channel . drag ( { selector : toSelectorChannel ( selector ) , dest, ...options } ) ;
142
+ await this . _wrapApiCall ( 'androidDevice.drag' , async ( channel : channels . AndroidDeviceChannel ) => {
143
+ await channel . drag ( { selector : toSelectorChannel ( selector ) , dest, ...options } ) ;
144
144
} ) ;
145
145
}
146
146
147
147
async fling ( selector : api . AndroidSelector , direction : Direction , options ?: SpeedOptions & types . TimeoutOptions ) {
148
- await this . _wrapApiCall ( 'androidDevice.fling' , async ( ) => {
149
- await this . _channel . fling ( { selector : toSelectorChannel ( selector ) , direction, ...options } ) ;
148
+ await this . _wrapApiCall ( 'androidDevice.fling' , async ( channel : channels . AndroidDeviceChannel ) => {
149
+ await channel . fling ( { selector : toSelectorChannel ( selector ) , direction, ...options } ) ;
150
150
} ) ;
151
151
}
152
152
153
153
async longTap ( selector : api . AndroidSelector , options ?: types . TimeoutOptions ) {
154
- await this . _wrapApiCall ( 'androidDevice.longTap' , async ( ) => {
155
- await this . _channel . longTap ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
154
+ await this . _wrapApiCall ( 'androidDevice.longTap' , async ( channel : channels . AndroidDeviceChannel ) => {
155
+ await channel . longTap ( { selector : toSelectorChannel ( selector ) , ...options } ) ;
156
156
} ) ;
157
157
}
158
158
159
159
async pinchClose ( selector : api . AndroidSelector , percent : number , options ?: SpeedOptions & types . TimeoutOptions ) {
160
- await this . _wrapApiCall ( 'androidDevice.pinchClose' , async ( ) => {
161
- await this . _channel . pinchClose ( { selector : toSelectorChannel ( selector ) , percent, ...options } ) ;
160
+ await this . _wrapApiCall ( 'androidDevice.pinchClose' , async ( channel : channels . AndroidDeviceChannel ) => {
161
+ await channel . pinchClose ( { selector : toSelectorChannel ( selector ) , percent, ...options } ) ;
162
162
} ) ;
163
163
}
164
164
165
165
async pinchOpen ( selector : api . AndroidSelector , percent : number , options ?: SpeedOptions & types . TimeoutOptions ) {
166
- await this . _wrapApiCall ( 'androidDevice.pinchOpen' , async ( ) => {
167
- await this . _channel . pinchOpen ( { selector : toSelectorChannel ( selector ) , percent, ...options } ) ;
166
+ await this . _wrapApiCall ( 'androidDevice.pinchOpen' , async ( channel : channels . AndroidDeviceChannel ) => {
167
+ await channel . pinchOpen ( { selector : toSelectorChannel ( selector ) , percent, ...options } ) ;
168
168
} ) ;
169
169
}
170
170
171
171
async scroll ( selector : api . AndroidSelector , direction : Direction , percent : number , options ?: SpeedOptions & types . TimeoutOptions ) {
172
- await this . _wrapApiCall ( 'androidDevice.scroll' , async ( ) => {
173
- await this . _channel . scroll ( { selector : toSelectorChannel ( selector ) , direction, percent, ...options } ) ;
172
+ await this . _wrapApiCall ( 'androidDevice.scroll' , async ( channel : channels . AndroidDeviceChannel ) => {
173
+ await channel . scroll ( { selector : toSelectorChannel ( selector ) , direction, percent, ...options } ) ;
174
174
} ) ;
175
175
}
176
176
177
177
async swipe ( selector : api . AndroidSelector , direction : Direction , percent : number , options ?: SpeedOptions & types . TimeoutOptions ) {
178
- await this . _wrapApiCall ( 'androidDevice.swipe' , async ( ) => {
179
- await this . _channel . swipe ( { selector : toSelectorChannel ( selector ) , direction, percent, ...options } ) ;
178
+ await this . _wrapApiCall ( 'androidDevice.swipe' , async ( channel : channels . AndroidDeviceChannel ) => {
179
+ await channel . swipe ( { selector : toSelectorChannel ( selector ) , direction, percent, ...options } ) ;
180
180
} ) ;
181
181
}
182
182
183
183
async info ( selector : api . AndroidSelector ) : Promise < api . AndroidElementInfo > {
184
- return await this . _wrapApiCall ( 'androidDevice.info' , async ( ) => {
185
- return ( await this . _channel . info ( { selector : toSelectorChannel ( selector ) } ) ) . info ;
184
+ return await this . _wrapApiCall ( 'androidDevice.info' , async ( channel : channels . AndroidDeviceChannel ) => {
185
+ return ( await channel . info ( { selector : toSelectorChannel ( selector ) } ) ) . info ;
186
186
} ) ;
187
187
}
188
188
189
189
async screenshot ( options : { path ?: string } = { } ) : Promise < Buffer > {
190
- return await this . _wrapApiCall ( 'androidDevice.screenshot' , async ( ) => {
191
- const { binary } = await this . _channel . screenshot ( ) ;
190
+ return await this . _wrapApiCall ( 'androidDevice.screenshot' , async ( channel : channels . AndroidDeviceChannel ) => {
191
+ const { binary } = await channel . screenshot ( ) ;
192
192
const buffer = Buffer . from ( binary , 'base64' ) ;
193
193
if ( options . path )
194
194
await util . promisify ( fs . writeFile ) ( options . path , buffer ) ;
@@ -197,41 +197,41 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel, c
197
197
}
198
198
199
199
async close ( ) {
200
- return this . _wrapApiCall ( 'androidDevice.close' , async ( ) => {
201
- await this . _channel . close ( ) ;
200
+ return this . _wrapApiCall ( 'androidDevice.close' , async ( channel : channels . AndroidDeviceChannel ) => {
201
+ await channel . close ( ) ;
202
202
this . emit ( Events . AndroidDevice . Close ) ;
203
203
} ) ;
204
204
}
205
205
206
206
async shell ( command : string ) : Promise < Buffer > {
207
- return this . _wrapApiCall ( 'androidDevice.shell' , async ( ) => {
208
- const { result } = await this . _channel . shell ( { command } ) ;
207
+ return this . _wrapApiCall ( 'androidDevice.shell' , async ( channel : channels . AndroidDeviceChannel ) => {
208
+ const { result } = await channel . shell ( { command } ) ;
209
209
return Buffer . from ( result , 'base64' ) ;
210
210
} ) ;
211
211
}
212
212
213
213
async open ( command : string ) : Promise < AndroidSocket > {
214
- return this . _wrapApiCall ( 'androidDevice.open' , async ( ) => {
215
- return AndroidSocket . from ( ( await this . _channel . open ( { command } ) ) . socket ) ;
214
+ return this . _wrapApiCall ( 'androidDevice.open' , async ( channel : channels . AndroidDeviceChannel ) => {
215
+ return AndroidSocket . from ( ( await channel . open ( { command } ) ) . socket ) ;
216
216
} ) ;
217
217
}
218
218
219
219
async installApk ( file : string | Buffer , options ?: { args : string [ ] } ) : Promise < void > {
220
- return this . _wrapApiCall ( 'androidDevice.installApk' , async ( ) => {
221
- await this . _channel . installApk ( { file : await loadFile ( file ) , args : options && options . args } ) ;
220
+ return this . _wrapApiCall ( 'androidDevice.installApk' , async ( channel : channels . AndroidDeviceChannel ) => {
221
+ await channel . installApk ( { file : await loadFile ( file ) , args : options && options . args } ) ;
222
222
} ) ;
223
223
}
224
224
225
225
async push ( file : string | Buffer , path : string , options ?: { mode : number } ) : Promise < void > {
226
- return this . _wrapApiCall ( 'androidDevice.push' , async ( ) => {
227
- await this . _channel . push ( { file : await loadFile ( file ) , path, mode : options ? options . mode : undefined } ) ;
226
+ return this . _wrapApiCall ( 'androidDevice.push' , async ( channel : channels . AndroidDeviceChannel ) => {
227
+ await channel . push ( { file : await loadFile ( file ) , path, mode : options ? options . mode : undefined } ) ;
228
228
} ) ;
229
229
}
230
230
231
231
async launchBrowser ( options : types . BrowserContextOptions & { pkg ?: string } = { } ) : Promise < ChromiumBrowserContext > {
232
- return this . _wrapApiCall ( 'androidDevice.launchBrowser' , async ( ) => {
232
+ return this . _wrapApiCall ( 'androidDevice.launchBrowser' , async ( channel : channels . AndroidDeviceChannel ) => {
233
233
const contextOptions = await prepareBrowserContextParams ( options ) ;
234
- const { context } = await this . _channel . launchBrowser ( contextOptions ) ;
234
+ const { context } = await channel . launchBrowser ( contextOptions ) ;
235
235
return BrowserContext . from ( context ) as ChromiumBrowserContext ;
236
236
} ) ;
237
237
}
@@ -261,14 +261,14 @@ export class AndroidSocket extends ChannelOwner<channels.AndroidSocketChannel, c
261
261
}
262
262
263
263
async write ( data : Buffer ) : Promise < void > {
264
- return this . _wrapApiCall ( 'androidDevice.write' , async ( ) => {
265
- await this . _channel . write ( { data : data . toString ( 'base64' ) } ) ;
264
+ return this . _wrapApiCall ( 'androidDevice.write' , async ( channel : channels . AndroidSocketChannel ) => {
265
+ await channel . write ( { data : data . toString ( 'base64' ) } ) ;
266
266
} ) ;
267
267
}
268
268
269
269
async close ( ) : Promise < void > {
270
- return this . _wrapApiCall ( 'androidDevice.close' , async ( ) => {
271
- await this . _channel . close ( ) ;
270
+ return this . _wrapApiCall ( 'androidDevice.close' , async ( channel : channels . AndroidSocketChannel ) => {
271
+ await channel . close ( ) ;
272
272
} ) ;
273
273
}
274
274
}
@@ -287,32 +287,32 @@ export class AndroidInput implements api.AndroidInput {
287
287
}
288
288
289
289
async type ( text : string ) {
290
- return this . _device . _wrapApiCall ( 'androidDevice.inputType' , async ( ) => {
291
- await this . _device . _channel . inputType ( { text } ) ;
290
+ return this . _device . _wrapApiCall ( 'androidDevice.inputType' , async ( channel : channels . AndroidDeviceChannel ) => {
291
+ await channel . inputType ( { text } ) ;
292
292
} ) ;
293
293
}
294
294
295
295
async press ( key : api . AndroidKey ) {
296
- return this . _device . _wrapApiCall ( 'androidDevice.inputPress' , async ( ) => {
297
- await this . _device . _channel . inputPress ( { key } ) ;
296
+ return this . _device . _wrapApiCall ( 'androidDevice.inputPress' , async ( channel : channels . AndroidDeviceChannel ) => {
297
+ await channel . inputPress ( { key } ) ;
298
298
} ) ;
299
299
}
300
300
301
301
async tap ( point : types . Point ) {
302
- return this . _device . _wrapApiCall ( 'androidDevice.inputTap' , async ( ) => {
303
- await this . _device . _channel . inputTap ( { point } ) ;
302
+ return this . _device . _wrapApiCall ( 'androidDevice.inputTap' , async ( channel : channels . AndroidDeviceChannel ) => {
303
+ await channel . inputTap ( { point } ) ;
304
304
} ) ;
305
305
}
306
306
307
307
async swipe ( from : types . Point , segments : types . Point [ ] , steps : number ) {
308
- return this . _device . _wrapApiCall ( 'androidDevice.inputSwipe' , async ( ) => {
309
- await this . _device . _channel . inputSwipe ( { segments, steps } ) ;
308
+ return this . _device . _wrapApiCall ( 'androidDevice.inputSwipe' , async ( channel : channels . AndroidDeviceChannel ) => {
309
+ await channel . inputSwipe ( { segments, steps } ) ;
310
310
} ) ;
311
311
}
312
312
313
313
async drag ( from : types . Point , to : types . Point , steps : number ) {
314
- return this . _device . _wrapApiCall ( 'androidDevice.inputDragAndDrop' , async ( ) => {
315
- await this . _device . _channel . inputDrag ( { from, to, steps } ) ;
314
+ return this . _device . _wrapApiCall ( 'androidDevice.inputDragAndDrop' , async ( channel : channels . AndroidDeviceChannel ) => {
315
+ await channel . inputDrag ( { from, to, steps } ) ;
316
316
} ) ;
317
317
}
318
318
}
@@ -393,8 +393,8 @@ export class AndroidWebView extends EventEmitter implements api.AndroidWebView {
393
393
}
394
394
395
395
private async _fetchPage ( ) : Promise < Page > {
396
- return this . _device . _wrapApiCall ( 'androidWebView.page' , async ( ) => {
397
- const { context } = await this . _device . _channel . connectToWebView ( { pid : this . _data . pid , sdkLanguage : 'javascript' } ) ;
396
+ return this . _device . _wrapApiCall ( 'androidWebView.page' , async ( channel : channels . AndroidDeviceChannel ) => {
397
+ const { context } = await channel . connectToWebView ( { pid : this . _data . pid , sdkLanguage : 'javascript' } ) ;
398
398
return BrowserContext . from ( context ) . pages ( ) [ 0 ] ;
399
399
} ) ;
400
400
}
0 commit comments