UNPKG

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