1 | import * as webdriver from './index';
|
2 | import * as remote from './remote';
|
3 |
|
4 | export 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 |
|
25 | export 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 |
|
35 | export 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 | */
|
46 | export 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 | * {!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 | * Instruct the EdgeDriver to use Edge Chromium if true.
|
125 | * Otherwise, use Edge Legacy (EdgeHTML). Defaults to using Edge Legacy.
|
126 | *
|
127 | * @param {boolean} useEdgeChromium
|
128 | * @return {!Options} A self reference.
|
129 | */
|
130 | setEdgeChromium(useEdgeChromium: boolean): Options;
|
131 |
|
132 | /**
|
133 | * Sets whether to leave the started Edge browser running if the controlling
|
134 | * EdgeDriver service is killed before {@link webdriver.WebDriver#quit()} is
|
135 | * called.
|
136 | * @param {boolean} detach Whether to leave the browser running if the
|
137 | * edgedriver service is killed before the session.
|
138 | * @return {!Options} A self reference.
|
139 | */
|
140 | detachDriver(detach: boolean): Options;
|
141 |
|
142 | /**
|
143 | * Sets the user preferences for Edge's user profile. See the 'Preferences'
|
144 | * file in Edge's user data directory for examples.
|
145 | * @param {!Object} prefs Dictionary of user preferences to use.
|
146 | * @return {!Options} A self reference.
|
147 | */
|
148 | setUserPreferences(prefs: any): Options;
|
149 |
|
150 | /**
|
151 | * Sets the performance logging preferences. Options include:
|
152 | *
|
153 | * - `enableNetwork`: Whether or not to collect events from Network domain.
|
154 | * - `enablePage`: Whether or not to collect events from Page domain.
|
155 | * - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
156 | * Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
157 | * unless `enableTimeline` is explicitly set to true.
|
158 | * - `tracingCategories`: A comma-separated string of Edge tracing
|
159 | * categories for which trace events should be collected. An unspecified or
|
160 | * empty string disables tracing.
|
161 | * - `bufferUsageReportingInterval`: The requested number of milliseconds
|
162 | * between DevTools trace buffer usage events. For example, if 1000, then
|
163 | * once per second, DevTools will report how full the trace buffer is. If
|
164 | * a report indicates the buffer usage is 100%, a warning will be issued.
|
165 | *
|
166 | * @param {{enableNetwork: boolean,
|
167 | * enablePage: boolean,
|
168 | * enableTimeline: boolean,
|
169 | * tracingCategories: string,
|
170 | * bufferUsageReportingInterval: number}} prefs The performance
|
171 | * logging preferences.
|
172 | * @return {!Options} A self reference.
|
173 | */
|
174 | setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
|
175 |
|
176 | /**
|
177 | * Sets preferences for the 'Local State' file in Edge's user data
|
178 | * directory.
|
179 | * @param {!Object} state Dictionary of local state preferences.
|
180 | * @return {!Options} A self reference.
|
181 | */
|
182 | setLocalState(state: any): Options;
|
183 |
|
184 | /**
|
185 | * Sets the name of the activity hosting a Edge-based Android WebView. This
|
186 | * option must be set to connect to an [Android WebView](
|
187 | * https://sites.google.com/a/chromium.org/edgedriver/getting-started/getting-started---android)
|
188 | *
|
189 | * @param {string} name The activity name.
|
190 | * @return {!Options} A self reference.
|
191 | */
|
192 | androidActivity(name: string): Options;
|
193 |
|
194 | /**
|
195 | * Sets the device serial number to connect to via ADB. If not specified, the
|
196 | * EdgeDriver will select an unused device at random. An error will be
|
197 | * returned if all devices already have active sessions.
|
198 | *
|
199 | * @param {string} serial The device serial number to connect to.
|
200 | * @return {!Options} A self reference.
|
201 | */
|
202 | androidDeviceSerial(serial: string): Options;
|
203 |
|
204 | /**
|
205 | * Configures the EdgeDriver to launch Edge on Android via adb. This
|
206 | * function is shorthand for
|
207 | * {@link #androidPackage options.androidPackage('com.android.edge')}.
|
208 | * @return {!Options} A self reference.
|
209 | */
|
210 | androidEdge(): Options;
|
211 |
|
212 | /**
|
213 | * Sets the package name of the Edge or WebView app.
|
214 | *
|
215 | * @param {?string} pkg The package to connect to, or `null` to disable
|
216 | * Android and switch back to using desktop Edge.
|
217 | * @return {!Options} A self reference.
|
218 | */
|
219 | androidPackage(pkg: string): Options;
|
220 |
|
221 | /**
|
222 | * Sets the process name of the Activity hosting the WebView (as given by
|
223 | * `ps`). If not specified, the process name is assumed to be the same as
|
224 | * {@link #androidPackage}.
|
225 | *
|
226 | * @param {string} processName The main activity name.
|
227 | * @return {!Options} A self reference.
|
228 | */
|
229 | androidProcess(processName: string): Options;
|
230 |
|
231 | /**
|
232 | * Sets whether to connect to an already-running instead of the specified
|
233 | * {@linkplain #androidProcess app} instead of launching the app with a clean
|
234 | * data directory.
|
235 | *
|
236 | * @param {boolean} useRunning Whether to connect to a running instance.
|
237 | * @return {!Options} A self reference.
|
238 | */
|
239 | androidUseRunningApp(useRunning: boolean): Options;
|
240 |
|
241 | /**
|
242 | * Sets the path to Edge's log file. This path should exist on the machine
|
243 | * that will launch Edge.
|
244 | * @param {string} path Path to the log file to use.
|
245 | * @return {!Options} A self reference.
|
246 | */
|
247 | setEdgeLogFile(path: string): Options;
|
248 |
|
249 | /**
|
250 | * Sets the directory to store Edge minidumps in. This option is only
|
251 | * supported when EdgeDriver is running on Linux.
|
252 | * @param {string} path The directory path.
|
253 | * @return {!Options} A self reference.
|
254 | */
|
255 | setEdgeMinidumpPath(path: string): Options;
|
256 |
|
257 | /**
|
258 | * Configures Edge to emulate a mobile device. For more information, refer
|
259 | * to the EdgeDriver project page on [mobile emulation][em]. Configuration
|
260 | * options include:
|
261 | *
|
262 | * - `deviceName`: The name of a pre-configured [emulated device][devem]
|
263 | * - `width`: screen width, in pixels
|
264 | * - `height`: screen height, in pixels
|
265 | * - `pixelRatio`: screen pixel ratio
|
266 | *
|
267 | * __Example 1: Using a Pre-configured Device__
|
268 | *
|
269 | * let options = new edge.Options().setMobileEmulation(
|
270 | * {deviceName: 'Google Nexus 5'});
|
271 | *
|
272 | * let driver = new edge.Driver(options);
|
273 | *
|
274 | * __Example 2: Using Custom Screen Configuration__
|
275 | *
|
276 | * let options = new edge.Options().setMobileEmulation({
|
277 | * width: 360,
|
278 | * height: 640,
|
279 | * pixelRatio: 3.0
|
280 | * });
|
281 | *
|
282 | * let driver = new edge.Driver(options);
|
283 | *
|
284 | *
|
285 | * [em]: https://sites.google.com/a/chromium.org/edgedriver/mobile-emulation
|
286 | * [devem]: https://developer.edge.com/devtools/docs/device-mode
|
287 | *
|
288 | * @param {?({deviceName: string}|
|
289 | * {width: number, height: number, pixelRatio: number})} config The
|
290 | * mobile emulation configuration, or `null` to disable emulation.
|
291 | * @return {!Options} A self reference.
|
292 | */
|
293 | setMobileEmulation(config: any): Options;
|
294 | }
|
295 |
|
296 | /**
|
297 | * Creates {@link remote.DriverService} instances that manage a
|
298 | * MicrosoftEdgeDriver server in a child process.
|
299 | */
|
300 | export class ServiceBuilder extends remote.DriverService.Builder {
|
301 | /**
|
302 | * @param {string=} opt_exe Path to the server executable to use. If omitted,
|
303 | * the builder will attempt to locate the MicrosoftEdgeDriver on the current
|
304 | * PATH.
|
305 | * @throws {Error} If provided executable does not exist, or the
|
306 | * MicrosoftEdgeDriver cannot be found on the PATH.
|
307 | */
|
308 | constructor(opt_exe?: string);
|
309 | }
|
310 |
|
311 | /**
|
312 | * Returns the default MicrosoftEdgeDriver service. If such a service has
|
313 | * not been configured, one will be constructed using the default configuration
|
314 | * for an MicrosoftEdgeDriver executable found on the system PATH.
|
315 | * @return {!remote.DriverService} The default MicrosoftEdgeDriver service.
|
316 | */
|
317 | export function getDefaultService(): remote.DriverService;
|
318 |
|
319 | /**
|
320 | * Sets the default service to use for new MicrosoftEdgeDriver instances.
|
321 | * @param {!remote.DriverService} service The service to use.
|
322 | * @throws {Error} If the default service is currently running.
|
323 | */
|
324 | export function setDefaultService(service: remote.DriverService): void;
|