This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.ts
165 lines (118 loc) · 8.17 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import {promise as wdpromise, WebDriver} from 'selenium-webdriver';
import * as commandDefinitions from './command_definitions';
import {Extender} from './extender';
export interface ExtendedWebDriver extends WebDriver {
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/getNetworkConnection
getNetworkConnection: () => wdpromise.Promise<0|1|2|3|4|5|6|7>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/setNetworkConnection
// This implementation differs slightly, allowing you to use three booleans instead of one bitmask
setNetworkConnection:
(typeOrAirplaneMode: 0|1|2|3|4|5|6|7|boolean, wifi?: boolean,
data?: boolean) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/toggleAirplaneMode
toggleAirplaneMode: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/toggleWiFi
toggleWiFi: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/toggleData
toggleData: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/toggleLocationServices
toggleLocationServices: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/location
// This implementation differs slightly, putting setters and getters into different methods
getGeolocation: () => wdpromise.Promise<{latitude: number, longitude: number, altitude: number}>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/location
// This implementation differs slightly, putting setters and getters into different methods
setGeolocation:
(latitude?: number, longitude?: number, altitude?: number) => wdpromise.Promise<void>;
// See
// https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/getCurrentDeviceActivity
getCurrentDeviceActivity: () => wdpromise.Promise<string>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/startActivity.js
startDeviceActivity:
(appPackage: string, appActivity: string, appWaitPackage?: string,
appWaitActivity?: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/settings.js
// This implementation differs slightly, putting setters and getters into different methods
getAppiumSettings: () => wdpromise.Promise<{[name: string]: any}>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/settings.js
// This implementation differs slightly, putting setters and getters into different methods
setAppiumSettings: (settings: {[name: string]: any}) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/context.js
// This implementation differs slightly, putting setters and getters into different methods
getCurrentContext: () => wdpromise.Promise<string>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/context.js
// This implementation differs slightly, putting setters and getters into different methods
selectContext: (name: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/contexts.js
listContexts: () => wdpromise.Promise<string[]>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/orientation
// This implementation differs slightly, putting setters and getters into different methods
getScreenOrientation: () => wdpromise.Promise<'LANDSCAPE'|'PORTRAIT'>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/orientation
// This implementation differs slightly, putting setters and getters into different methods
setScreenOrientation: (orientation: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/isLocked
isDeviceLocked: () => wdpromise.Promise<boolean>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/lock
lockDevice: (delay?: number) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/unlock
unlockDevice: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/installApp
installApp: (appPath: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/isAppInstalled
isAppInstalled: (bundleId: string) => wdpromise.Promise<boolean>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/removeApp
removeApp: (appId: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/pullFile
pullFileFromDevice: (path: string) => wdpromise.Promise<string>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/pullFolder
pullFolderFromDevice: (path: string) => wdpromise.Promise<any>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/pushFile
pushFileToDevice: (path: string, base64Data: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/file
uploadFile: (base64Data: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/frameParent
switchToParentFrame: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/windowHandleFullscreen
fullscreen: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/background
sendAppToBackground: (delay?: number) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/closeApp
closeApp: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/getAppStrings
getAppStrings: (language?: string) => wdpromise.Promise<string[]>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/launch
launchSession: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/reset
resetApp: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/hideDeviceKeyboard
hideSoftKeyboard:
(strategy?: 'default'|'tapOutside'|'tapOut'|'swipeDown'|'pressKey'|'press',
key?: string) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/getDeviceTime
getDeviceTime: () => wdpromise.Promise<string>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/openNotifications
openDeviceNotifications: () => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/rotate
// This implementation differs slightly, defaulting to a 180 degree rotation
rotationGesture:
(x?: number, y?: number, duration?: number, rotation?: number,
touchCount?: 1|2|3|4|5) => wdpromise.Promise<void>;
// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/shake
shakeDevice: () => wdpromise.Promise<void>;
sendChromiumCommand: (cmd: string, params: Object) => wdpromise.Promise<void>;
sendChromiumCommandAndGetResult: (cmd: string, params: Object) => wdpromise.Promise<Object>;
// See https://appium.readthedocs.io/en/latest/en/commands/device/recording-screen/start-recording-screen/
startRecordingScreen: () => wdpromise.Promise<void>;
// See https://appium.readthedocs.io/en/latest/en/commands/device/recording-screen/stop-recording-screen/
stopRecordingScreen: () => wdpromise.Promise<string>;
}
export function extend(baseDriver: WebDriver, fallbackGracefully = false): ExtendedWebDriver {
var extender = new Extender(baseDriver);
let extendedDriver: ExtendedWebDriver = baseDriver as ExtendedWebDriver;
for (let commandName in commandDefinitions) {
(extendedDriver as any)[commandName] =
(commandDefinitions as any)[commandName].compile(extender, fallbackGracefully);
}
return extendedDriver;
}