UNPKG

11.7 kBTypeScriptView Raw
1import * as webdriver from "./index";
2import * as remote from "./remote";
3
4export class Driver extends webdriver.ChromiumWebDriver {
5 /**
6 * Creates a new browser session for Microsoft's Edge browser.
7 *
8 * @param {(capabilities.Capabilities|Options)=} opt_config The configuration
9 * options.
10 * @param {remote.DriverService=} opt_service The session to use; will use
11 * the {@linkplain #getDefaultService default service} by default.
12 * @return {!Driver} A new driver instance.
13 */
14 static createSession(
15 opt_config?: webdriver.CreateSessionCapabilities,
16 opt_service?: remote.DriverService,
17 ): Driver;
18}
19
20export interface IOptionsValues {
21 args: string[];
22 binary?: string | undefined;
23 detach: boolean;
24 extensions: string[];
25 localState?: any;
26 logFile?: string | undefined;
27 prefs?: any;
28}
29
30export interface IPerfLoggingPrefs {
31 enableNetwork?: boolean | undefined;
32 enablePage?: boolean | undefined;
33 enableTimeline?: boolean | undefined;
34 traceCategories?: string | undefined;
35 bufferUsageReportingInterval?: number | undefined;
36}
37
38/**
39 * Class for managing MicrosoftEdgeDriver specific options.
40 */
41export class Options extends webdriver.Capabilities {
42 /** */
43 constructor();
44
45 /**
46 * Extracts the EdgeDriver specific options from the given capabilities
47 * object.
48 * @param {!webdriver.Capabilities} capabilities The capabilities object.
49 * @return {!Options} The EdgeDriver options.
50 */
51 static fromCapabilities(capabilities: webdriver.Capabilities): Options;
52
53 /**
54 * Add additional command line arguments to use when launching the Edge
55 * browser. Each argument may be specified with or without the '--' prefix
56 * (e.g. '--foo' and 'foo'). Arguments with an associated value should be
57 * delimited by an '=': 'foo=bar'.
58 * @param {...(string|!Array.<string>)} var_args The arguments to add.
59 * @return {!Options} A self reference.
60 */
61 addArguments(...var_args: string[]): Options;
62
63 /**
64 * Sets the initial window size.
65 *
66 * @param {{width: number, height: number}} size The desired window size.
67 * @return {!Options} A self reference.
68 * @throws {TypeError} if width or height is unspecified, not a number, or
69 * less than or equal to 0.
70 */
71 windowSize(size: { width: number; height: number }): Options;
72
73 /**
74 * List of Edge command line switches to exclude that EdgeDriver by
75 * default passes when starting Edge. Do not prefix switches with '--'.
76 *
77 * @param {...(string|!Array<string>)} var_args The switches to exclude.
78 * @return {!Options} A self reference.
79 */
80 excludeSwitches(...var_args: string[]): Options;
81
82 /**
83 * Add additional extensions to install when launching Edge. Each extension
84 * should be specified as the path to the packed CRX file, or a Buffer for an
85 * extension.
86 * @param {...(string|!Buffer|!Array.<(string|!Buffer)>)} var_args The
87 * extensions to add.
88 * @return {!Options} A self reference.
89 */
90 addExtensions(...var_args: any[]): Options;
91
92 /**
93 * Sets the path to the Edge binary to use. On Mac OS X, this path should
94 * reference the actual Edge executable, not just the application binary
95 * (e.g. '/Applications/Google Edge.app/Contents/MacOS/Google Edge').
96 *
97 * The binary path be absolute or relative to the edgedriver server
98 * executable, but it must exist on the machine that will launch Edge.
99 *
100 * @param {string} path The path to the Edge binary to use.
101 * @return {!Options} A self reference.
102 */
103 setChromeBinaryPath(path: string): Options;
104
105 /**
106 * Sets the path to the edge binary to use
107 *
108 * The binary path be absolute or relative to the msedgedriver server
109 * executable, but it must exist on the machine that will launch edge chromium.
110 * @param {string} path The path to the edgedriver binary to use.
111 * @return {!Options} A self reference.
112 */
113 setEdgeChromiumBinaryPath(path: string): Options;
114
115 /**
116 * Sets whether to leave the started Edge browser running if the controlling
117 * EdgeDriver service is killed before {@link webdriver.WebDriver#quit()} is
118 * called.
119 * @param {boolean} detach Whether to leave the browser running if the
120 * edgedriver service is killed before the session.
121 * @return {!Options} A self reference.
122 */
123 detachDriver(detach: boolean): Options;
124
125 /**
126 * Sets the user preferences for Edge's user profile. See the 'Preferences'
127 * file in Edge's user data directory for examples.
128 * @param {!Object} prefs Dictionary of user preferences to use.
129 * @return {!Options} A self reference.
130 */
131 setUserPreferences(prefs: any): Options;
132
133 /**
134 * Sets the performance logging preferences. Options include:
135 *
136 * - `enableNetwork`: Whether or not to collect events from Network domain.
137 * - `enablePage`: Whether or not to collect events from Page domain.
138 * - `enableTimeline`: Whether or not to collect events from Timeline domain.
139 * Note: when tracing is enabled, Timeline domain is implicitly disabled,
140 * unless `enableTimeline` is explicitly set to true.
141 * - `tracingCategories`: A comma-separated string of Edge tracing
142 * categories for which trace events should be collected. An unspecified or
143 * empty string disables tracing.
144 * - `bufferUsageReportingInterval`: The requested number of milliseconds
145 * between DevTools trace buffer usage events. For example, if 1000, then
146 * once per second, DevTools will report how full the trace buffer is. If
147 * a report indicates the buffer usage is 100%, a warning will be issued.
148 *
149 * @param {{enableNetwork: boolean,
150 * enablePage: boolean,
151 * enableTimeline: boolean,
152 * tracingCategories: string,
153 * bufferUsageReportingInterval: number}} prefs The performance
154 * logging preferences.
155 * @return {!Options} A self reference.
156 */
157 setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
158
159 /**
160 * Sets preferences for the 'Local State' file in Edge's user data
161 * directory.
162 * @param {!Object} state Dictionary of local state preferences.
163 * @return {!Options} A self reference.
164 */
165 setLocalState(state: any): Options;
166
167 /**
168 * Sets the name of the activity hosting a Edge-based Android WebView. This
169 * option must be set to connect to an [Android WebView](
170 * https://sites.google.com/a/chromium.org/edgedriver/getting-started/getting-started---android)
171 *
172 * @param {string} name The activity name.
173 * @return {!Options} A self reference.
174 */
175 androidActivity(name: string): Options;
176
177 /**
178 * Sets the device serial number to connect to via ADB. If not specified, the
179 * EdgeDriver will select an unused device at random. An error will be
180 * returned if all devices already have active sessions.
181 *
182 * @param {string} serial The device serial number to connect to.
183 * @return {!Options} A self reference.
184 */
185 androidDeviceSerial(serial: string): Options;
186
187 /**
188 * Configures the EdgeDriver to launch Edge on Android via adb. This
189 * function is shorthand for
190 * {@link #androidPackage options.androidPackage('com.android.edge')}.
191 * @return {!Options} A self reference.
192 */
193 androidEdge(): Options;
194
195 /**
196 * Sets the package name of the Edge or WebView app.
197 *
198 * @param {?string} pkg The package to connect to, or `null` to disable
199 * Android and switch back to using desktop Edge.
200 * @return {!Options} A self reference.
201 */
202 androidPackage(pkg: string): Options;
203
204 /**
205 * Sets the process name of the Activity hosting the WebView (as given by
206 * `ps`). If not specified, the process name is assumed to be the same as
207 * {@link #androidPackage}.
208 *
209 * @param {string} processName The main activity name.
210 * @return {!Options} A self reference.
211 */
212 androidProcess(processName: string): Options;
213
214 /**
215 * Sets whether to connect to an already-running instead of the specified
216 * {@linkplain #androidProcess app} instead of launching the app with a clean
217 * data directory.
218 *
219 * @param {boolean} useRunning Whether to connect to a running instance.
220 * @return {!Options} A self reference.
221 */
222 androidUseRunningApp(useRunning: boolean): Options;
223
224 /**
225 * Sets the path to Edge's log file. This path should exist on the machine
226 * that will launch Edge.
227 * @param {string} path Path to the log file to use.
228 * @return {!Options} A self reference.
229 */
230 setEdgeLogFile(path: string): Options;
231
232 /**
233 * Sets the directory to store Edge minidumps in. This option is only
234 * supported when EdgeDriver is running on Linux.
235 * @param {string} path The directory path.
236 * @return {!Options} A self reference.
237 */
238 setEdgeMinidumpPath(path: string): Options;
239
240 /**
241 * Configures Edge to emulate a mobile device. For more information, refer
242 * to the EdgeDriver project page on [mobile emulation][em]. Configuration
243 * options include:
244 *
245 * - `deviceName`: The name of a pre-configured [emulated device][devem]
246 * - `width`: screen width, in pixels
247 * - `height`: screen height, in pixels
248 * - `pixelRatio`: screen pixel ratio
249 *
250 * __Example 1: Using a Pre-configured Device__
251 *
252 * let options = new edge.Options().setMobileEmulation(
253 * {deviceName: 'Google Nexus 5'});
254 *
255 * let driver = new edge.Driver(options);
256 *
257 * __Example 2: Using Custom Screen Configuration__
258 *
259 * let options = new edge.Options().setMobileEmulation({
260 * width: 360,
261 * height: 640,
262 * pixelRatio: 3.0
263 * });
264 *
265 * let driver = new edge.Driver(options);
266 *
267 * [em]: https://sites.google.com/a/chromium.org/edgedriver/mobile-emulation
268 * [devem]: https://developer.edge.com/devtools/docs/device-mode
269 *
270 * @param {?({deviceName: string}|
271 * {width: number, height: number, pixelRatio: number})} config The
272 * mobile emulation configuration, or `null` to disable emulation.
273 * @return {!Options} A self reference.
274 */
275 setMobileEmulation(config: any): Options;
276}
277
278/**
279 * Creates {@link remote.DriverService} instances that manage a
280 * MicrosoftEdgeDriver server in a child process.
281 */
282export class ServiceBuilder extends remote.DriverService.Builder {
283 /**
284 * @param {string=} opt_exe Path to the server executable to use. If omitted,
285 * the builder will attempt to locate the MicrosoftEdgeDriver on the current
286 * PATH.
287 * @throws {Error} If provided executable does not exist, or the
288 * MicrosoftEdgeDriver cannot be found on the PATH.
289 */
290 constructor(opt_exe?: string);
291}
292
293/**
294 * Returns the default MicrosoftEdgeDriver service. If such a service has
295 * not been configured, one will be constructed using the default configuration
296 * for an MicrosoftEdgeDriver executable found on the system PATH.
297 * @return {!remote.DriverService} The default MicrosoftEdgeDriver service.
298 */
299export function getDefaultService(): remote.DriverService;
300
301/**
302 * Sets the default service to use for new MicrosoftEdgeDriver instances.
303 * @param {!remote.DriverService} service The service to use.
304 * @throws {Error} If the default service is currently running.
305 */
306export function setDefaultService(service: remote.DriverService): void;