Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 67b3dba

Browse files
authoredDec 15, 2018
typings(selenium): try out new version of typings (#5084)
1 parent cbde6a7 commit 67b3dba

15 files changed

+6605
-86
lines changed
 

‎.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ addons:
3636
- g++-4.8
3737

3838
before_install:
39-
- g++-4.8 --version
39+
- travis_wait g++-4.8 --version
4040

4141
before_script:
4242
- npm run install_testapp
4343
- npm run pretest
4444
- mkdir -p $LOGS_DIR
45-
- ./scripts/travis_setup.sh
45+
- travis_wait ./scripts/travis_setup.sh
4646

4747

4848
script:

‎lib/locators.ts

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class ProtractorBy extends WebdriverBy {
8080
this[name] = (...args: any[]): ProtractorLocator => {
8181
const locatorArguments = args;
8282
return {
83-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
83+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
8484
Promise<WebElement[]> => {
8585
let findElementArguments: any[] = [script];
8686
for (let i = 0; i < locatorArguments.length; i++) {
@@ -89,9 +89,7 @@ export class ProtractorBy extends WebdriverBy {
8989
findElementArguments.push(using);
9090
findElementArguments.push(rootSelector);
9191

92-
// TODO(selenium4): clean up cast to native Promise.
93-
return driver.findElements(By.js.apply(By, findElementArguments)) as
94-
Promise<WebElement[]>;
92+
return await driver.findElements(By.js.apply(By, findElementArguments));
9593
},
9694
toString: (): string => {
9795
return 'by.' + name + '("' + Array.prototype.join.call(locatorArguments, '", "') + '")';
@@ -132,12 +130,10 @@ export class ProtractorBy extends WebdriverBy {
132130
*/
133131
binding(bindingDescriptor: string): ProtractorLocator {
134132
return {
135-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
133+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
136134
Promise<WebElement[]> => {
137-
// TODO(selenium4): clean up cast to native Promise.
138-
return driver.findElements(By.js(
139-
clientSideScripts.findBindings, bindingDescriptor, false, using,
140-
rootSelector)) as Promise<WebElement[]>;
135+
return await driver.findElements(By.js(
136+
clientSideScripts.findBindings, bindingDescriptor, false, using, rootSelector));
141137
},
142138
toString: (): string => {
143139
return 'by.binding("' + bindingDescriptor + '")';
@@ -166,13 +162,11 @@ export class ProtractorBy extends WebdriverBy {
166162
*/
167163
exactBinding(bindingDescriptor: string): ProtractorLocator {
168164
return {
169-
findElementsOverride: (
170-
driver: WebDriver, using: WebElement, rootSelector: string): Promise<WebElement[]> => {
171-
// TODO(selenium4): clean up cast to native Promise.
172-
return driver.findElements(By.js(
173-
clientSideScripts.findBindings, bindingDescriptor, true, using, rootSelector)) as
174-
Promise<WebElement[]>;
175-
},
165+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
166+
Promise<WebElement[]> => {
167+
return await driver.findElements(By.js(
168+
clientSideScripts.findBindings, bindingDescriptor, true, using, rootSelector));
169+
},
176170
toString: (): string => {
177171
return 'by.exactBinding("' + bindingDescriptor + '")';
178172
}
@@ -196,12 +190,10 @@ export class ProtractorBy extends WebdriverBy {
196190
*/
197191
model(model: string): ProtractorLocator {
198192
return {
199-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
193+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
200194
Promise<WebElement[]> => {
201-
// TODO(selenium4): clean up cast to native Promise.
202-
return driver.findElements(
203-
By.js(clientSideScripts.findByModel, model, using, rootSelector)) as
204-
Promise<WebElement[]>;
195+
return await driver.findElements(
196+
By.js(clientSideScripts.findByModel, model, using, rootSelector));
205197
},
206198
toString: (): string => {
207199
return 'by.model("' + model + '")';
@@ -223,12 +215,10 @@ export class ProtractorBy extends WebdriverBy {
223215
*/
224216
buttonText(searchText: string): ProtractorLocator {
225217
return {
226-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
218+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
227219
Promise<WebElement[]> => {
228-
// TODO(selenium4): clean up cast to native Promise.
229-
return driver.findElements(By.js(
230-
clientSideScripts.findByButtonText, searchText, using, rootSelector)) as
231-
Promise<WebElement[]>;
220+
return driver.findElements(
221+
By.js(clientSideScripts.findByButtonText, searchText, using, rootSelector));
232222
},
233223
toString: (): string => {
234224
return 'by.buttonText("' + searchText + '")';
@@ -250,13 +240,11 @@ export class ProtractorBy extends WebdriverBy {
250240
*/
251241
partialButtonText(searchText: string): ProtractorLocator {
252242
return {
253-
findElementsOverride: (
254-
driver: WebDriver, using: WebElement, rootSelector: string): Promise<WebElement[]> => {
255-
// TODO(selenium4): clean up cast to native Promise.
256-
return driver.findElements(By.js(
257-
clientSideScripts.findByPartialButtonText, searchText, using, rootSelector)) as
258-
Promise<WebElement[]>;
259-
},
243+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
244+
Promise<WebElement[]> => {
245+
return driver.findElements(
246+
By.js(clientSideScripts.findByPartialButtonText, searchText, using, rootSelector));
247+
},
260248
toString: (): string => {
261249
return 'by.partialButtonText("' + searchText + '")';
262250
}
@@ -267,36 +255,34 @@ export class ProtractorBy extends WebdriverBy {
267255
private byRepeaterInner(exact: boolean, repeatDescriptor: string): ProtractorLocator {
268256
let name = 'by.' + (exact ? 'exactR' : 'r') + 'epeater';
269257
return {
270-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
271-
Promise<WebElement[]> => {
272-
// TODO(selenium4): clean up cast to native Promise.
273-
return driver.findElements(By.js(
274-
clientSideScripts.findAllRepeaterRows, repeatDescriptor, exact, using,
275-
rootSelector)) as Promise<WebElement[]>;
276-
},
258+
findElementsOverride: async(
259+
driver: WebDriver, using: WebElement, rootSelector: string): Promise<WebElement[]> => {
260+
return driver.findElements(By.js(
261+
clientSideScripts.findAllRepeaterRows, repeatDescriptor, exact, using, rootSelector));
262+
},
277263
toString: (): string => {
278264
return name + '("' + repeatDescriptor + '")';
279265
},
280266
row: (index: number): ProtractorLocator => {
281267
return {
282-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
268+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
283269
Promise<WebElement[]> => {
284-
return driver.findElements(By.js(
285-
clientSideScripts.findRepeaterRows, repeatDescriptor, exact, index,
286-
using, rootSelector)) as Promise<WebElement[]>;
270+
return await driver.findElements(By.js(
271+
clientSideScripts.findRepeaterRows, repeatDescriptor, exact, index, using,
272+
rootSelector));
287273
},
288274
toString: (): string => {
289275
return name + '(' + repeatDescriptor + '").row("' + index + '")"';
290276
},
291277
column: (binding: string): ProtractorLocator => {
292278
return {
293-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
294-
Promise<WebElement[]> => {
295-
// TODO(selenium4): clean up cast to native Promise.
296-
return driver.findElements(By.js(
297-
clientSideScripts.findRepeaterElement, repeatDescriptor, exact,
298-
index, binding, using, rootSelector)) as Promise<WebElement[]>;
299-
},
279+
findElementsOverride:
280+
async(driver: WebDriver, using: WebElement, rootSelector: string):
281+
Promise<WebElement[]> => {
282+
return driver.findElements(By.js(
283+
clientSideScripts.findRepeaterElement, repeatDescriptor, exact, index,
284+
binding, using, rootSelector));
285+
},
300286
toString: (): string => {
301287
return name + '("' + repeatDescriptor + '").row("' + index + '").column("' +
302288
binding + '")';
@@ -307,25 +293,24 @@ export class ProtractorBy extends WebdriverBy {
307293
},
308294
column: (binding: string): ProtractorLocator => {
309295
return {
310-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
296+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
311297
Promise<WebElement[]> => {
312-
// TODO(selenium4): clean up cast to native Promise.
313298
return driver.findElements(By.js(
314-
clientSideScripts.findRepeaterColumn, repeatDescriptor, exact, binding,
315-
using, rootSelector)) as Promise<WebElement[]>;
299+
clientSideScripts.findRepeaterColumn, repeatDescriptor, exact, binding, using,
300+
rootSelector));
316301
},
317302
toString: (): string => {
318303
return name + '("' + repeatDescriptor + '").column("' + binding + '")';
319304
},
320305
row: (index: number): ProtractorLocator => {
321306
return {
322-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
323-
Promise<WebElement[]> => {
324-
// TODO(selenium4): clean up cast to native Promise.
325-
return driver.findElements(By.js(
326-
clientSideScripts.findRepeaterElement, repeatDescriptor, exact,
327-
index, binding, using, rootSelector)) as Promise<WebElement[]>;
328-
},
307+
findElementsOverride:
308+
async(driver: WebDriver, using: WebElement, rootSelector: string):
309+
Promise<WebElement[]> => {
310+
return driver.findElements(By.js(
311+
clientSideScripts.findRepeaterElement, repeatDescriptor, exact, index,
312+
binding, using, rootSelector));
313+
},
329314
toString: (): string => {
330315
return name + '("' + repeatDescriptor + '").column("' + binding + '").row("' +
331316
index + '")';
@@ -437,12 +422,11 @@ export class ProtractorBy extends WebdriverBy {
437422
cssContainingText(cssSelector: string, searchText: string|RegExp): ProtractorLocator {
438423
searchText = (searchText instanceof RegExp) ? '__REGEXP__' + searchText.toString() : searchText;
439424
return {
440-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
425+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
441426
Promise<WebElement[]> => {
442-
// TODO(selenium4): clean up cast to native Promise.
443-
return driver.findElements(By.js(
444-
clientSideScripts.findByCssContainingText, cssSelector, searchText, using,
445-
rootSelector)) as Promise<WebElement[]>;
427+
return await driver.findElements(By.js(
428+
clientSideScripts.findByCssContainingText, cssSelector, searchText, using,
429+
rootSelector));
446430
},
447431
toString: (): string => {
448432
return 'by.cssContainingText("' + cssSelector + '", "' + searchText + '")';
@@ -471,12 +455,10 @@ export class ProtractorBy extends WebdriverBy {
471455
*/
472456
options(optionsDescriptor: string): ProtractorLocator {
473457
return {
474-
findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string):
458+
findElementsOverride: async(driver: WebDriver, using: WebElement, rootSelector: string):
475459
Promise<WebElement[]> => {
476-
// TODO(selenium4): clean up cast to native Promise.
477-
return driver.findElements(By.js(
478-
clientSideScripts.findByOptions, optionsDescriptor, using, rootSelector)) as
479-
Promise<WebElement[]>;
460+
return await driver.findElements(
461+
By.js(clientSideScripts.findByOptions, optionsDescriptor, using, rootSelector));
480462
},
481463
toString: (): string => {
482464
return 'by.option("' + optionsDescriptor + '")';

‎package-lock.json

Lines changed: 24 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"author": "Julie Ralph <ju.ralph@gmail.com>",
1414
"dependencies": {
1515
"@types/node": "^6.0.46",
16-
"@types/selenium-webdriver": "^3.0.0",
1716
"blocking-proxy": "^1.0.0",
1817
"browserstack": "^1.5.1",
1918
"chalk": "^1.1.3",

‎tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"website",
1717
"scripts",
1818
"exampleTypescript",
19-
"spec/**/*"
19+
"spec/**/*",
20+
"typings"
2021
]
2122
}

‎typings/chrome.d.ts

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

‎typings/edge.d.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
* @param {promise.ControlFlow=} opt_flow The control flow to use, or
13+
* {@code null} to use the currently active flow.
14+
* @return {!Driver} A new driver instance.
15+
*/
16+
static createSession(opt_config?: webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
17+
18+
/**
19+
* This function is a no-op as file detectors are not supported by this
20+
* implementation.
21+
* @override
22+
*/
23+
setFileDetector(): void;
24+
}
25+
26+
/**
27+
* Class for managing MicrosoftEdgeDriver specific options.
28+
*/
29+
export class Options {
30+
/**
31+
* Extracts the MicrosoftEdgeDriver specific options from the given
32+
* capabilities object.
33+
* @param {!capabilities.Capabilities} caps The capabilities object.
34+
* @return {!Options} The MicrosoftEdgeDriver options.
35+
*/
36+
static fromCapabilities(cap: webdriver.Capabilities): Options;
37+
38+
/**
39+
* Sets the proxy settings for the new session.
40+
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
41+
* @return {!Options} A self reference.
42+
*/
43+
setProxy(proxy: webdriver.ProxyConfig): Options;
44+
45+
/**
46+
* Sets the page load strategy for Edge.
47+
* Supported values are 'normal', 'eager', and 'none';
48+
*
49+
* @param {string} pageLoadStrategy The page load strategy to use.
50+
* @return {!Options} A self reference.
51+
*/
52+
setPageLoadStrategy(pageLoadStrategy: string): Options;
53+
54+
/**
55+
* Converts this options instance to a {@link capabilities.Capabilities}
56+
* object.
57+
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
58+
* merge these options into, if any.
59+
* @return {!capabilities.Capabilities} The capabilities.
60+
*/
61+
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
62+
}
63+
64+
/**
65+
* Creates {@link remote.DriverService} instances that manage a
66+
* MicrosoftEdgeDriver server in a child process.
67+
*/
68+
export class ServiceBuilder extends remote.DriverService.Builder {
69+
/**
70+
* @param {string=} opt_exe Path to the server executable to use. If omitted,
71+
* the builder will attempt to locate the MicrosoftEdgeDriver on the current
72+
* PATH.
73+
* @throws {Error} If provided executable does not exist, or the
74+
* MicrosoftEdgeDriver cannot be found on the PATH.
75+
*/
76+
constructor(opt_exe?: string);
77+
}
78+
79+
/**
80+
* Returns the default MicrosoftEdgeDriver service. If such a service has
81+
* not been configured, one will be constructed using the default configuration
82+
* for an MicrosoftEdgeDriver executable found on the system PATH.
83+
* @return {!remote.DriverService} The default MicrosoftEdgeDriver service.
84+
*/
85+
export function getDefaultService(): remote.DriverService;
86+
87+
/**
88+
* Sets the default service to use for new MicrosoftEdgeDriver instances.
89+
* @param {!remote.DriverService} service The service to use.
90+
* @throws {Error} If the default service is currently running.
91+
*/
92+
export function setDefaultService(service: remote.DriverService): void;

‎typings/firefox.d.ts

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
import * as webdriver from './index';
2+
import * as remote from './remote';
3+
import * as http from './http';
4+
5+
/**
6+
* Manages a Firefox subprocess configured for use with WebDriver.
7+
*/
8+
export class Binary {
9+
/**
10+
* @param {string=} opt_exe Path to the Firefox binary to use. If not
11+
* specified, will attempt to locate Firefox on the current system.
12+
* @constructor
13+
*/
14+
constructor(opt_exe?: string);
15+
16+
/**
17+
* Add arguments to the command line used to start Firefox.
18+
* @param {...(string|!Array.<string>)} var_args Either the arguments to add as
19+
* varargs, or the arguments as an array.
20+
*/
21+
addArguments(...var_args: string[]): void;
22+
23+
/**
24+
* Launches Firefox and eturns a promise that will be fulfilled when the process
25+
* terminates.
26+
* @param {string} profile Path to the profile directory to use.
27+
* @return {!promise.Promise.<!exec.Result>} A promise for the process result.
28+
* @throws {Error} If this instance has already been started.
29+
*/
30+
launch(profile: string): webdriver.promise.Promise<any>;
31+
32+
/**
33+
* Kills the managed Firefox process.
34+
* @return {!promise.Promise} A promise for when the process has terminated.
35+
*/
36+
kill(): webdriver.promise.Promise<void>;
37+
}
38+
39+
/**
40+
* Models a Firefox proifle directory for use with the FirefoxDriver. The
41+
* {@code Proifle} directory uses an in-memory model until {@link #writeToDisk}
42+
* is called.
43+
*/
44+
export class Profile {
45+
/**
46+
* @param {string=} opt_dir Path to an existing Firefox profile directory to
47+
* use a template for this profile. If not specified, a blank profile will
48+
* be used.
49+
* @constructor
50+
*/
51+
constructor(opt_dir?: string);
52+
53+
/**
54+
* Registers an extension to be included with this profile.
55+
* @param {string} extension Path to the extension to include, as either an
56+
* unpacked extension directory or the path to a xpi file.
57+
*/
58+
addExtension(extension: string): void;
59+
60+
/**
61+
* Sets a desired preference for this profile.
62+
* @param {string} key The preference key.
63+
* @param {(string|number|boolean)} value The preference value.
64+
* @throws {Error} If attempting to set a frozen preference.
65+
*/
66+
setPreference(key: string, value: string): void;
67+
setPreference(key: string, value: number): void;
68+
setPreference(key: string, value: boolean): void;
69+
70+
/**
71+
* Returns the currently configured value of a profile preference. This does
72+
* not include any defaults defined in the profile's template directory user.js
73+
* file (if a template were specified on construction).
74+
* @param {string} key The desired preference.
75+
* @return {(string|number|boolean|undefined)} The current value of the
76+
* requested preference.
77+
*/
78+
getPreference(key: string): any;
79+
80+
/**
81+
* @return {number} The port this profile is currently configured to use, or
82+
* 0 if the port will be selected at random when the profile is written
83+
* to disk.
84+
*/
85+
getPort(): number;
86+
87+
/**
88+
* Sets the port to use for the WebDriver extension loaded by this profile.
89+
* @param {number} port The desired port, or 0 to use any free port.
90+
*/
91+
setPort(port: number): void;
92+
93+
/**
94+
* @return {boolean} Whether the FirefoxDriver is configured to automatically
95+
* accept untrusted SSL certificates.
96+
*/
97+
acceptUntrustedCerts(): boolean;
98+
99+
/**
100+
* Sets whether the FirefoxDriver should automatically accept untrusted SSL
101+
* certificates.
102+
* @param {boolean} value .
103+
*/
104+
setAcceptUntrustedCerts(value: boolean): void;
105+
106+
/**
107+
* Sets whether to assume untrusted certificates come from untrusted issuers.
108+
* @param {boolean} value .
109+
*/
110+
setAssumeUntrustedCertIssuer(value: boolean): void;
111+
112+
/**
113+
* @return {boolean} Whether to assume untrusted certs come from untrusted
114+
* issuers.
115+
*/
116+
assumeUntrustedCertIssuer(): boolean;
117+
118+
/**
119+
* Sets whether to use native events with this profile.
120+
* @param {boolean} enabled .
121+
*/
122+
setNativeEventsEnabled(enabled: boolean): void;
123+
124+
/**
125+
* Returns whether native events are enabled in this profile.
126+
* @return {boolean} .
127+
*/
128+
nativeEventsEnabled(): boolean;
129+
130+
/**
131+
* Writes this profile to disk.
132+
* @param {boolean=} opt_excludeWebDriverExt Whether to exclude the WebDriver
133+
* extension from the generated profile. Used to reduce the size of an
134+
* {@link #encode() encoded profile} since the server will always install
135+
* the extension itself.
136+
* @return {!promise.Promise.<string>} A promise for the path to the new
137+
* profile directory.
138+
*/
139+
writeToDisk(opt_excludeWebDriverExt?: boolean): webdriver.promise.Promise<string>;
140+
141+
/**
142+
* Encodes this profile as a zipped, base64 encoded directory.
143+
* @return {!promise.Promise.<string>} A promise for the encoded profile.
144+
*/
145+
encode(): webdriver.promise.Promise<string>;
146+
}
147+
148+
/**
149+
* Configuration options for the FirefoxDriver.
150+
*/
151+
export class Options {
152+
/**
153+
* Sets the profile to use. The profile may be specified as a
154+
* {@link Profile} object or as the path to an existing Firefox profile to use
155+
* as a template.
156+
*
157+
* @param {(string|!Profile)} profile The profile to use.
158+
* @return {!Options} A self reference.
159+
*/
160+
setProfile(profile: string | any): Options;
161+
162+
/**
163+
* Sets the binary to use. The binary may be specified as the path to a Firefox
164+
* executable, or as a {@link Binary} object.
165+
*
166+
* @param {(string|!Binary)} binary The binary to use.
167+
* @return {!Options} A self reference.
168+
*/
169+
setBinary(binary: string | any): Options;
170+
171+
/**
172+
* Sets the logging preferences for the new session.
173+
* @param {logging.Preferences} prefs The logging preferences.
174+
* @return {!Options} A self reference.
175+
*/
176+
setLoggingPreferences(prefs: webdriver.logging.Preferences): Options;
177+
178+
/**
179+
* Sets the proxy to use.
180+
*
181+
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
182+
* @return {!Options} A self reference.
183+
*/
184+
setProxy(proxy: webdriver.ProxyConfig): Options;
185+
186+
/**
187+
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
188+
* is enabled by default and required for Firefox 47+.
189+
*
190+
* @param {boolean} enable Whether to enable the geckodriver.
191+
* @see https://github.com/mozilla/geckodriver
192+
*/
193+
useGeckoDriver(enable: boolean): Options;
194+
195+
/**
196+
* Converts these options to a {@link capabilities.Capabilities} instance.
197+
*
198+
* @return {!capabilities.Capabilities} A new capabilities object.
199+
*/
200+
toCapabilities(): webdriver.Capabilities;
201+
}
202+
203+
/**
204+
* @return {string} .
205+
* @throws {Error}
206+
*/
207+
export function findWires(): string;
208+
209+
/**
210+
* @param {(string|!Binary)} binary .
211+
* @return {!remote.DriverService} .
212+
*/
213+
export function createWiresService(binary: string | any): remote.DriverService;
214+
215+
/**
216+
* @param {(Profile|string)} profile The profile to prepare.
217+
* @param {number} port The port the FirefoxDriver should listen on.
218+
* @return {!Promise<string>} a promise for the path to the profile directory.
219+
*/
220+
export function prepareProfile(profile: string | any, port: number): any;
221+
222+
/**
223+
* A WebDriver client for Firefox.
224+
*/
225+
export class Driver extends webdriver.WebDriver {
226+
/**
227+
* Creates a new Firefox session.
228+
*
229+
* @param {(Options|capabilities.Capabilities|Object)=} opt_config The
230+
* configuration options for this driver, specified as either an
231+
* {@link Options} or {@link capabilities.Capabilities}, or as a raw hash
232+
* object.
233+
* @param {(http.Executor|remote.DriverService)=} opt_executor Either a
234+
* pre-configured command executor to use for communicating with an
235+
* externally managed remote end (which is assumed to already be running),
236+
* or the `DriverService` to use to start the geckodriver in a child
237+
* process.
238+
*
239+
* If an executor is provided, care should e taken not to use reuse it with
240+
* other clients as its internal command mappings will be updated to support
241+
* Firefox-specific commands.
242+
*
243+
* _This parameter may only be used with Mozilla's GeckoDriver._
244+
*
245+
* @param {promise.ControlFlow=} opt_flow The flow to
246+
* schedule commands through. Defaults to the active flow object.
247+
* @throws {Error} If a custom command executor is provided and the driver is
248+
* configured to use the legacy FirefoxDriver from the Selenium project.
249+
* @return {!Driver} A new driver instance.
250+
*/
251+
static createSession(opt_config?: Options | webdriver.Capabilities, opt_executor?: http.Executor | remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
252+
253+
/**
254+
* This function is a no-op as file detectors are not supported by this
255+
* implementation.
256+
* @override
257+
*/
258+
setFileDetector(): void;
259+
}
260+
261+
/**
262+
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
263+
* a [geckodriver](https://github.com/mozilla/geckodriver) server in a child
264+
* process.
265+
*/
266+
export class ServiceBuilder extends remote.DriverService.Builder {
267+
/**
268+
* @param {string=} opt_exe Path to the server executable to use. If omitted,
269+
* the builder will attempt to locate the geckodriver on the system PATH.
270+
*/
271+
constructor(opt_exe?: string);
272+
273+
/**
274+
* Enables verbose logging.
275+
*
276+
* @param {boolean=} opt_trace Whether to enable trace-level logging. By
277+
* default, only debug logging is enabled.
278+
* @return {!ServiceBuilder} A self reference.
279+
*/
280+
enableVerboseLogging(opt_trace?: boolean): this;
281+
282+
/**
283+
* Sets the path to the executable Firefox binary that the geckodriver should
284+
* use. If this method is not called, this builder will attempt to locate
285+
* Firefox in the default installation location for the current platform.
286+
*
287+
* @param {(string|!Binary)} binary Path to the executable Firefox binary to use.
288+
* @return {!ServiceBuilder} A self reference.
289+
* @see Binary#locate()
290+
*/
291+
setFirefoxBinary(binary: string | Binary): this;
292+
}

‎typings/http.d.ts

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import * as webdriver from './index';
2+
3+
/**
4+
* Converts a headers map to a HTTP header block string.
5+
* @param {!Map<string, string>} headers The map to convert.
6+
* @return {string} The headers as a string.
7+
*/
8+
export function headersToString(headers: any): string;
9+
10+
/**
11+
* Represents a HTTP request message. This class is a 'partial' request and only
12+
* defines the path on the server to send a request to. It is each client's
13+
* responsibility to build the full URL for the final request.
14+
* @final
15+
*/
16+
export class Request {
17+
/**
18+
* @param {string} method The HTTP method to use for the request.
19+
* @param {string} path The path on the server to send the request to.
20+
* @param {Object=} opt_data This request's non-serialized JSON payload data.
21+
*/
22+
constructor(method: string, path: string, opt_data?: Object);
23+
24+
/** @override */
25+
toString(): string;
26+
}
27+
28+
/**
29+
* Represents a HTTP response message.
30+
* @final
31+
*/
32+
export class Response {
33+
/**
34+
* @param {number} status The response code.
35+
* @param {!Object<string>} headers The response headers. All header names
36+
* will be converted to lowercase strings for consistent lookups.
37+
* @param {string} body The response body.
38+
*/
39+
constructor(status: number, headers: Object, body: string);
40+
41+
/** @override */
42+
toString(): string;
43+
}
44+
45+
export function post(path: string): any;
46+
export function del(path: string): any;
47+
export function get(path: string): any;
48+
export function resource(method: string, path: string): any;
49+
50+
/**
51+
* A basic HTTP client used to send messages to a remote end.
52+
*/
53+
export class HttpClient {
54+
/**
55+
* @param {string} serverUrl URL for the WebDriver server to send commands to.
56+
* @param {http.Agent=} opt_agent The agent to use for each request.
57+
* Defaults to `http.globalAgent`.
58+
* @param {?string=} opt_proxy The proxy to use for the connection to the
59+
* server. Default is to use no proxy.
60+
*/
61+
constructor(serverUrl: string, opt_agent?: any, opt_proxy?: string);
62+
63+
/**
64+
* Sends a request to the server. The client will automatically follow any
65+
* redirects returned by the server, fulfilling the returned promise with the
66+
* final response.
67+
*
68+
* @param {!HttpRequest} httpRequest The request to send.
69+
* @return {!promise.Promise<HttpResponse>} A promise that will be fulfilled
70+
* with the server's response.
71+
*/
72+
send(httpRequest: Request): webdriver.promise.Promise<Response>;
73+
}
74+
75+
/**
76+
* Sends a single HTTP request.
77+
* @param {!Object} options The request options.
78+
* @param {function(!HttpResponse)} onOk The function to call if the
79+
* request succeeds.
80+
* @param {function(!Error)} onError The function to call if the request fails.
81+
* @param {?string=} opt_data The data to send with the request.
82+
* @param {?string=} opt_proxy The proxy server to use for the request.
83+
*/
84+
export function sendRequest(options: Object, onOk: any, onError: any, opt_data?: string, opt_proxy?: string): any;
85+
86+
/**
87+
* A command executor that communicates with the server using HTTP + JSON.
88+
*
89+
* By default, each instance of this class will use the legacy wire protocol
90+
* from [Selenium project][json]. The executor will automatically switch to the
91+
* [W3C wire protocol][w3c] if the remote end returns a compliant response to
92+
* a new session command.
93+
*
94+
* [json]: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
95+
* [w3c]: https://w3c.github.io/webdriver/webdriver-spec.html
96+
*
97+
* @implements {cmd.Executor}
98+
*/
99+
export class Executor {
100+
/**
101+
* @param {!(HttpClient|IThenable<!HttpClient>)} client The client to use for sending
102+
* requests to the server, or a promise-like object that will resolve to
103+
* to the client.
104+
*/
105+
constructor(client: HttpClient | webdriver.promise.IThenable<HttpClient>);
106+
107+
/**
108+
* Defines a new command for use with this executor. When a command is sent,
109+
* the {@code path} will be preprocessed using the command's parameters; any
110+
* path segments prefixed with ':' will be replaced by the parameter of the
111+
* same name. For example, given '/person/:name' and the parameters
112+
* '{name: 'Bob'}', the final command path will be '/person/Bob'.
113+
*
114+
* @param {string} name The command name.
115+
* @param {string} method The HTTP method to use when sending this command.
116+
* @param {string} path The path to send the command to, relative to
117+
* the WebDriver server's command root and of the form
118+
* '/path/:variable/segment'.
119+
*/
120+
defineCommand(name: string, method: string, path: string): void;
121+
122+
/** @override */
123+
execute(command: any): any;
124+
}
125+
126+
/**
127+
* @param {string} str .
128+
* @return {?} .
129+
*/
130+
export function tryParse(str: string): any;
131+
132+
/**
133+
* Callback used to parse {@link HttpResponse} objects from a
134+
* {@link HttpClient}.
135+
* @param {!HttpResponse} httpResponse The HTTP response to parse.
136+
* @param {boolean} w3c Whether the response should be processed using the
137+
* W3C wire protocol.
138+
* @return {{value: ?}} The parsed response.
139+
* @throws {WebDriverError} If the HTTP response is an error.
140+
*/
141+
export function parseHttpResponse(httpResponse: Response, w3c: boolean): any;
142+
143+
/**
144+
* Builds a fully qualified path using the given set of command parameters. Each
145+
* path segment prefixed with ':' will be replaced by the value of the
146+
* corresponding parameter. All parameters spliced into the path will be
147+
* removed from the parameter map.
148+
* @param {string} path The original resource path.
149+
* @param {!Object<*>} parameters The parameters object to splice into the path.
150+
* @return {string} The modified path.
151+
*/
152+
export function buildPath(path: string, parameters: Object): string;

‎typings/ie.d.ts

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
import * as webdriver from './index';
2+
3+
/**
4+
* A WebDriver client for Microsoft's Internet Explorer.
5+
*/
6+
export class Driver extends webdriver.WebDriver {
7+
/**
8+
* Creates a new session for Microsoft's Internet Explorer.
9+
*
10+
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
11+
* options.
12+
* @param {promise.ControlFlow=} opt_flow The control flow to use,
13+
* or {@code null} to use the currently active flow.
14+
* @return {!Driver} A new driver instance.
15+
*/
16+
static createSession(opt_config?: webdriver.Capabilities | Options, opt_flow?: webdriver.promise.ControlFlow): Driver;
17+
18+
/**
19+
* This function is a no-op as file detectors are not supported by this
20+
* implementation.
21+
* @override
22+
*/
23+
setFileDetector(): void;
24+
}
25+
26+
/**
27+
* Class for managing IEDriver specific options.
28+
*/
29+
export class Options {
30+
constructor();
31+
32+
/**
33+
* Extracts the IEDriver specific options from the given capabilities
34+
* object.
35+
* @param {!capabilities.Capabilities} caps The capabilities object.
36+
* @return {!Options} The IEDriver options.
37+
*/
38+
static fromCapabilities(caps: webdriver.Capabilities): Options;
39+
40+
/**
41+
* Whether to disable the protected mode settings check when the session is
42+
* created. Disbling this setting may lead to significant instability as the
43+
* browser may become unresponsive/hang. Only 'best effort' support is provided
44+
* when using this capability.
45+
*
46+
* For more information, refer to the IEDriver's
47+
* [required system configuration](http://goo.gl/eH0Yi3).
48+
*
49+
* @param {boolean} ignoreSettings Whether to ignore protected mode settings.
50+
* @return {!Options} A self reference.
51+
*/
52+
introduceFlakinessByIgnoringProtectedModeSettings(ignoreSettings: boolean): Options;
53+
54+
/**
55+
* Indicates whether to skip the check that the browser's zoom level is set to
56+
* 100%.
57+
*
58+
* @param {boolean} ignore Whether to ignore the browser's zoom level settings.
59+
* @return {!Options} A self reference.
60+
*/
61+
ignoreZoomSetting(ignore: boolean): Options;
62+
63+
/**
64+
* Sets the initial URL loaded when IE starts. This is intended to be used with
65+
* {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in
66+
* the proper Protected Mode zone. Setting this option may cause browser
67+
* instability or flaky and unresponsive code. Only 'best effort' support is
68+
* provided when using this option.
69+
*
70+
* @param {string} url The initial browser URL.
71+
* @return {!Options} A self reference.
72+
*/
73+
initialBrowserUrl(url: string): Options;
74+
75+
/**
76+
* Configures whether to enable persistent mouse hovering (true by default).
77+
* Persistent hovering is achieved by continuously firing mouse over events at
78+
* the last location the mouse cursor has been moved to.
79+
*
80+
* @param {boolean} enable Whether to enable persistent hovering.
81+
* @return {!Options} A self reference.
82+
*/
83+
enablePersistentHover(enable: boolean): Options;
84+
85+
/**
86+
* Configures whether the driver should attempt to remove obsolete
87+
* {@linkplain webdriver.WebElement WebElements} from its internal cache on
88+
* page navigation (true by default). Disabling this option will cause the
89+
* driver to run with a larger memory footprint.
90+
*
91+
* @param {boolean} enable Whether to enable element reference cleanup.
92+
* @return {!Options} A self reference.
93+
*/
94+
enableElementCacheCleanup(enable: boolean): Options;
95+
96+
/**
97+
* Configures whether to require the IE window to have input focus before
98+
* performing any user interactions (i.e. mouse or keyboard events). This
99+
* option is disabled by default, but delivers much more accurate interaction
100+
* events when enabled.
101+
*
102+
* @param {boolean} require Whether to require window focus.
103+
* @return {!Options} A self reference.
104+
*/
105+
requireWindowFocus(require: boolean): Options;
106+
107+
/**
108+
* Configures the timeout, in milliseconds, that the driver will attempt to
109+
* located and attach to a newly opened instance of Internet Explorer. The
110+
* default is zero, which indicates waiting indefinitely.
111+
*
112+
* @param {number} timeout How long to wait for IE.
113+
* @return {!Options} A self reference.
114+
*/
115+
browserAttachTimeout(timeout: number): Options;
116+
117+
/**
118+
* Configures whether to launch Internet Explorer using the CreateProcess API.
119+
* If this option is not specified, IE is launched using IELaunchURL, if
120+
* available. For IE 8 and above, this option requires the TabProcGrowth
121+
* registry value to be set to 0.
122+
*
123+
* @param {boolean} force Whether to use the CreateProcess API.
124+
* @return {!Options} A self reference.
125+
*/
126+
forceCreateProcessApi(force: boolean): Options;
127+
128+
/**
129+
* Specifies command-line switches to use when launching Internet Explorer.
130+
* This is only valid when used with {@link #forceCreateProcessApi}.
131+
*
132+
* @param {...(string|!Array.<string>)} var_args The arguments to add.
133+
* @return {!Options} A self reference.
134+
*/
135+
addArguments(...var_args: string[]): Options;
136+
137+
/**
138+
* Configures whether proxies should be configured on a per-process basis. If
139+
* not set, setting a {@linkplain #setProxy proxy} will configure the system
140+
* proxy. The default behavior is to use the system proxy.
141+
*
142+
* @param {boolean} enable Whether to enable per-process proxy settings.
143+
* @return {!Options} A self reference.
144+
*/
145+
usePerProcessProxy(enable: boolean): Options;
146+
147+
/**
148+
* Configures whether to clear the cache, cookies, history, and saved form data
149+
* before starting the browser. _Using this capability will clear session data
150+
* for all running instances of Internet Explorer, including those started
151+
* manually._
152+
*
153+
* @param {boolean} cleanSession Whether to clear all session data on startup.
154+
* @return {!Options} A self reference.
155+
*/
156+
ensureCleanSession(cleanSession: boolean): Options;
157+
158+
/**
159+
* Sets the path to the log file the driver should log to.
160+
* @param {string} file The log file path.
161+
* @return {!Options} A self reference.
162+
*/
163+
setLogFile(file: string): Options;
164+
165+
/**
166+
* Sets the IEDriverServer's logging {@linkplain Level level}.
167+
* @param {Level} level The logging level.
168+
* @return {!Options} A self reference.
169+
*/
170+
setLogLevel(level: webdriver.logging.Level): Options;
171+
172+
/**
173+
* Sets the IP address of the driver's host adapter.
174+
* @param {string} host The IP address to use.
175+
* @return {!Options} A self reference.
176+
*/
177+
setHost(host: string): Options;
178+
179+
/**
180+
* Sets the path of the temporary data directory to use.
181+
* @param {string} path The log file path.
182+
* @return {!Options} A self reference.
183+
*/
184+
setExtractPath(path: string): Options;
185+
186+
/**
187+
* Sets whether the driver should start in silent mode.
188+
* @param {boolean} silent Whether to run in silent mode.
189+
* @return {!Options} A self reference.
190+
*/
191+
silent(silent: boolean): Options;
192+
193+
/**
194+
* Sets the proxy settings for the new session.
195+
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
196+
* @return {!Options} A self reference.
197+
*/
198+
setProxy(proxy: webdriver.ProxyConfig): Options;
199+
200+
/**
201+
* Converts this options instance to a {@link capabilities.Capabilities}
202+
* object.
203+
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
204+
* merge these options into, if any.
205+
* @return {!capabilities.Capabilities} The capabilities.
206+
*/
207+
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
208+
}

‎typings/index.d.ts

Lines changed: 4802 additions & 0 deletions
Large diffs are not rendered by default.

‎typings/opera.d.ts

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import * as webdriver from './index';
2+
import * as remote from './remote';
3+
4+
/**
5+
* Creates {@link remote.DriverService} instances that manages an
6+
* [OperaDriver](https://github.com/operasoftware/operachromiumdriver)
7+
* server in a child process.
8+
*/
9+
export class ServiceBuilder {
10+
/**
11+
* @param {string=} opt_exe Path to the server executable to use. If omitted,
12+
* the builder will attempt to locate the operadriver on the current
13+
* PATH.
14+
* @throws {Error} If provided executable does not exist, or the operadriver
15+
* cannot be found on the PATH.
16+
*/
17+
constructor(opt_exe?: string);
18+
19+
/**
20+
* Sets the port to start the OperaDriver on.
21+
* @param {number} port The port to use, or 0 for any free port.
22+
* @return {!ServiceBuilder} A self reference.
23+
* @throws {Error} If the port is invalid.
24+
*/
25+
usingPort(port: number): ServiceBuilder;
26+
27+
/**
28+
* Sets the path of the log file the driver should log to. If a log file is
29+
* not specified, the driver will log to stderr.
30+
* @param {string} path Path of the log file to use.
31+
* @return {!ServiceBuilder} A self reference.
32+
*/
33+
loggingTo(path: string): ServiceBuilder;
34+
35+
/**
36+
* Enables verbose logging.
37+
* @return {!ServiceBuilder} A self reference.
38+
*/
39+
enableVerboseLogging(): ServiceBuilder;
40+
41+
/**
42+
* Silence sthe drivers output.
43+
* @return {!ServiceBuilder} A self reference.
44+
*/
45+
silent(): ServiceBuilder;
46+
47+
/**
48+
* Defines the stdio configuration for the driver service. See
49+
* {@code child_process.spawn} for more information.
50+
* @param {(string|!Array<string|number|!stream.Stream|null|undefined>)}
51+
* config The configuration to use.
52+
* @return {!ServiceBuilder} A self reference.
53+
*/
54+
setStdio(config: string | Array<string | number | any>): ServiceBuilder;
55+
56+
/**
57+
* Defines the environment to start the server under. This settings will be
58+
* inherited by every browser session started by the server.
59+
* @param {!Object.<string, string>} env The environment to use.
60+
* @return {!ServiceBuilder} A self reference.
61+
*/
62+
withEnvironment(env: Object): ServiceBuilder;
63+
64+
/**
65+
* Creates a new DriverService using this instance's current configuration.
66+
* @return {!remote.DriverService} A new driver service using this instance's
67+
* current configuration.
68+
* @throws {Error} If the driver exectuable was not specified and a default
69+
* could not be found on the current PATH.
70+
*/
71+
build(): remote.DriverService;
72+
}
73+
74+
/**
75+
* Sets the default service to use for new OperaDriver instances.
76+
* @param {!remote.DriverService} service The service to use.
77+
* @throws {Error} If the default service is currently running.
78+
*/
79+
export function setDefaultService(service: remote.DriverService): any;
80+
81+
/**
82+
* Returns the default OperaDriver service. If such a service has not been
83+
* configured, one will be constructed using the default configuration for
84+
* a OperaDriver executable found on the system PATH.
85+
* @return {!remote.DriverService} The default OperaDriver service.
86+
*/
87+
export function getDefaultService(): remote.DriverService;
88+
89+
/**
90+
* Class for managing {@linkplain Driver OperaDriver} specific options.
91+
*/
92+
export class Options {
93+
/**
94+
* Extracts the OperaDriver specific options from the given capabilities
95+
* object.
96+
* @param {!capabilities.Capabilities} caps The capabilities object.
97+
* @return {!Options} The OperaDriver options.
98+
*/
99+
static fromCapabilities(caps: webdriver.Capabilities): Options;
100+
101+
/**
102+
* Add additional command line arguments to use when launching the Opera
103+
* browser. Each argument may be specified with or without the '--' prefix
104+
* (e.g. '--foo' and 'foo'). Arguments with an associated value should be
105+
* delimited by an '=': 'foo=bar'.
106+
* @param {...(string|!Array.<string>)} var_args The arguments to add.
107+
* @return {!Options} A self reference.
108+
*/
109+
addArguments(...var_args: string[]): Options;
110+
111+
/**
112+
* Add additional extensions to install when launching Opera. Each extension
113+
* should be specified as the path to the packed CRX file, or a Buffer for an
114+
* extension.
115+
* @param {...(string|!Buffer|!Array.<(string|!Buffer)>)} var_args The
116+
* extensions to add.
117+
* @return {!Options} A self reference.
118+
*/
119+
addExtensions(...var_args: any[]): Options;
120+
121+
/**
122+
* Sets the path to the Opera binary to use. On Mac OS X, this path should
123+
* reference the actual Opera executable, not just the application binary. The
124+
* binary path be absolute or relative to the operadriver server executable, but
125+
* it must exist on the machine that will launch Opera.
126+
*
127+
* @param {string} path The path to the Opera binary to use.
128+
* @return {!Options} A self reference.
129+
*/
130+
setOperaBinaryPath(path: string): Options;
131+
132+
/**
133+
* Sets the logging preferences for the new session.
134+
* @param {!./lib/logging.Preferences} prefs The logging preferences.
135+
* @return {!Options} A self reference.
136+
*/
137+
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
138+
139+
/**
140+
* Sets the proxy settings for the new session.
141+
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
142+
* @return {!Options} A self reference.
143+
*/
144+
setProxy(proxy: webdriver.ProxyConfig): Options;
145+
146+
/**
147+
* Converts this options instance to a {@link capabilities.Capabilities}
148+
* object.
149+
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
150+
* merge these options into, if any.
151+
* @return {!capabilities.Capabilities} The capabilities.
152+
*/
153+
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
154+
}
155+
156+
export class Driver extends webdriver.WebDriver {
157+
/**
158+
* Creates a new session for Opera.
159+
*
160+
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
161+
* options.
162+
* @param {remote.DriverService=} opt_service The session to use; will use
163+
* the {@link getDefaultService default service} by default.
164+
* @param {promise.ControlFlow=} opt_flow The control flow to use,
165+
* or {@code null} to use the currently active flow.
166+
* @return {!Driver} A new driver instance.
167+
*/
168+
static createSession(opt_config?: webdriver.Capabilities | Options, opt_service?: remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
169+
170+
/**
171+
* This function is a no-op as file detectors are not supported by this
172+
* implementation.
173+
* @override
174+
*/
175+
setFileDetector(): void;
176+
}

‎typings/remote.d.ts

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
import * as webdriver from './index';
2+
3+
/**
4+
* A record object that defines the configuration options for a DriverService
5+
* instance.
6+
*
7+
* @record
8+
*/
9+
export interface ServiceOptions { }
10+
11+
/**
12+
* Manages the life and death of a native executable WebDriver server.
13+
*
14+
* It is expected that the driver server implements the
15+
* https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol.
16+
* Furthermore, the managed server should support multiple concurrent sessions,
17+
* so that this class may be reused for multiple clients.
18+
*/
19+
export class DriverService {
20+
/**
21+
* @param {string} executable Path to the executable to run.
22+
* @param {!ServiceOptions} options Configuration options for the service.
23+
*/
24+
constructor(executable: string, options: ServiceOptions);
25+
26+
/**
27+
* @return {!promise.Promise<string>} A promise that resolves to
28+
* the server's address.
29+
* @throws {Error} If the server has not been started.
30+
*/
31+
address(): webdriver.promise.Promise<string>;
32+
33+
/**
34+
* Returns whether the underlying process is still running. This does not take
35+
* into account whether the process is in the process of shutting down.
36+
* @return {boolean} Whether the underlying service process is running.
37+
*/
38+
isRunning(): boolean;
39+
40+
/**
41+
* Starts the server if it is not already running.
42+
* @param {number=} opt_timeoutMs How long to wait, in milliseconds, for the
43+
* server to start accepting requests. Defaults to 30 seconds.
44+
* @return {!promise.Promise<string>} A promise that will resolve
45+
* to the server's base URL when it has started accepting requests. If the
46+
* timeout expires before the server has started, the promise will be
47+
* rejected.
48+
*/
49+
start(opt_timeoutMs?: number): webdriver.promise.Promise<string>;
50+
51+
/**
52+
* Stops the service if it is not currently running. This function will kill
53+
* the server immediately. To synchronize with the active control flow, use
54+
* {@link #stop()}.
55+
* @return {!promise.Promise} A promise that will be resolved when
56+
* the server has been stopped.
57+
*/
58+
kill(): webdriver.promise.Promise<any>;
59+
60+
/**
61+
* Schedules a task in the current control flow to stop the server if it is
62+
* currently running.
63+
* @return {!promise.Promise} A promise that will be resolved when
64+
* the server has been stopped.
65+
*/
66+
stop(): webdriver.promise.Promise<any>;
67+
}
68+
69+
export namespace DriverService {
70+
/**
71+
* Creates {@link DriverService} objects that manage a WebDriver server in a
72+
* child process.
73+
*/
74+
class Builder {
75+
/**
76+
* @param {string} exe Path to the executable to use. This executable must
77+
* accept the `--port` flag for defining the port to start the server on.
78+
* @throws {Error} If the provided executable path does not exist.
79+
*/
80+
constructor(exe: string);
81+
82+
/**
83+
* Define additional command line arguments to use when starting the server.
84+
*
85+
* @param {...CommandLineFlag} var_args The arguments to include.
86+
* @return {!THIS} A self reference.
87+
* @this {THIS}
88+
* @template THIS
89+
*/
90+
addArguments(...var_args: string[]): this;
91+
92+
/**
93+
* Sets the host name to access the server on. If specified, the
94+
* {@linkplain #setLoopback() loopback} setting will be ignored.
95+
*
96+
* @param {string} hostname
97+
* @return {!DriverService.Builder} A self reference.
98+
*/
99+
setHostname(hostname: string): this;
100+
101+
/**
102+
* Sets whether the service should be accessed at this host's loopback
103+
* address.
104+
*
105+
* @param {boolean} loopback
106+
* @return {!DriverService.Builder} A self reference.
107+
*/
108+
setLoopback(loopback: boolean): this;
109+
110+
/**
111+
* Sets the base path for WebDriver REST commands (e.g. "/wd/hub").
112+
* By default, the driver will accept commands relative to "/".
113+
*
114+
* @param {?string} basePath The base path to use, or `null` to use the
115+
* default.
116+
* @return {!DriverService.Builder} A self reference.
117+
*/
118+
setPath(basePath: string | null): this;
119+
120+
/**
121+
* Sets the port to start the server on.
122+
*
123+
* @param {number} port The port to use, or 0 for any free port.
124+
* @return {!DriverService.Builder} A self reference.
125+
* @throws {Error} If an invalid port is specified.
126+
*/
127+
setPort(port: number): this;
128+
129+
/**
130+
* Defines the environment to start the server under. This setting will be
131+
* inherited by every browser session started by the server. By default, the
132+
* server will inherit the enviroment of the current process.
133+
*
134+
* @param {(Map<string, string>|Object<string, string>|null)} env The desired
135+
* environment to use, or `null` if the server should inherit the
136+
* current environment.
137+
* @return {!DriverService.Builder} A self reference.
138+
*/
139+
setEnvironment(env: Map<string, string> | {[name: string]: string} | null): this;
140+
141+
/**
142+
* IO configuration for the spawned server process. For more information,
143+
* refer to the documentation of `child_process.spawn`.
144+
*
145+
* @param {StdIoOptions} config The desired IO configuration.
146+
* @return {!DriverService.Builder} A self reference.
147+
* @see https://nodejs.org/dist/latest-v4.x/docs/api/child_process.html#child_process_options_stdio
148+
*/
149+
setStdio(config: any): this;
150+
151+
/**
152+
* Creates a new DriverService using this instance's current configuration.
153+
*
154+
* @return {!DriverService} A new driver service.
155+
*/
156+
build(): DriverService;
157+
}
158+
}
159+
160+
/**
161+
* Manages the life and death of the
162+
* <a href="http://selenium-release.storage.googleapis.com/index.html">
163+
* standalone Selenium server</a>.
164+
*/
165+
export class SeleniumServer extends DriverService {
166+
/**
167+
* @param {string} jar Path to the Selenium server jar.
168+
* @param {SeleniumServer.Options=} opt_options Configuration options for the
169+
* server.
170+
* @throws {Error} If the path to the Selenium jar is not specified or if an
171+
* invalid port is specified.
172+
**/
173+
constructor(jar: string, opt_options?: SeleniumServer.Options);
174+
}
175+
176+
export namespace SeleniumServer {
177+
/**
178+
* Options for the Selenium server
179+
*/
180+
interface Options {
181+
/** Whether the server should only be accessed on this host's loopback address.*/
182+
loopback?: boolean;
183+
184+
/** The port to start the server on (must be > 0). If the port is provided
185+
as a promise, the service will wait for the promise to resolve before starting. */
186+
port?: number|webdriver.promise.IThenable<number>;
187+
188+
/** The arguments to pass to the service. If a promise is provided, the
189+
service will wait for it to resolve before starting. */
190+
args?: string[]|webdriver.promise.IThenable<string[]>;
191+
192+
/** The arguments to pass to the JVM. If a promise is provided, the service
193+
will wait for it to resolve before starting. */
194+
jvmArgs?: string[]|webdriver.promise.IThenable<string[]>;
195+
196+
/** The environment variables that should be visible to the server process.
197+
Defaults to inheriting the current process's environment.*/
198+
env?: {[key: string]: string};
199+
200+
/** IO configuration for the spawned server process. For more information,
201+
refer to the documentation of `child_process.spawn`*/
202+
stdio?: string|Array<string|number>;
203+
}
204+
}
205+
206+
/**
207+
* A {@link webdriver.FileDetector} that may be used when running
208+
* against a remote
209+
* [Selenium server](http://selenium-release.storage.googleapis.com/index.html).
210+
*
211+
* When a file path on the local machine running this script is entered with
212+
* {@link webdriver.WebElement#sendKeys WebElement#sendKeys}, this file detector
213+
* will transfer the specified file to the Selenium server's host; the sendKeys
214+
* command will be updated to use the transfered file's path.
215+
*
216+
* __Note:__ This class depends on a non-standard command supported on the
217+
* Java Selenium server. The file detector will fail if used with a server that
218+
* only supports standard WebDriver commands (such as the ChromeDriver).
219+
*
220+
* @final
221+
*/
222+
export class FileDetector extends webdriver.FileDetector {
223+
/**
224+
* @constructor
225+
**/
226+
constructor();
227+
228+
/**
229+
* Prepares a `file` for use with the remote browser. If the provided path
230+
* does not reference a normal file (i.e. it does not exist or is a
231+
* directory), then the promise returned by this method will be resolved with
232+
* the original file path. Otherwise, this method will upload the file to the
233+
* remote server, which will return the file's path on the remote system so
234+
* it may be referenced in subsequent commands.
235+
*
236+
* @param {!webdriver.WebDriver} driver The driver for the current browser.
237+
* @param {string} file The path of the file to process.
238+
* @return {!webdriver.promise.Promise<string>} A promise for the processed
239+
* file path.
240+
*/
241+
handleFile(driver: webdriver.WebDriver, file: string): webdriver.promise.Promise<string>;
242+
}

‎typings/safari.d.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import * as webdriver from './index';
2+
3+
export class Server { }
4+
5+
/**
6+
* @return {!Promise<string>} A promise that will resolve with the path
7+
* to Safari on the current system.
8+
*/
9+
export function findSafariExecutable(): any;
10+
11+
/**
12+
* @param {string} serverUrl The URL to connect to.
13+
* @return {!Promise<string>} A promise for the path to a file that Safari can
14+
* open on start-up to trigger a new connection to the WebSocket server.
15+
*/
16+
export function createConnectFile(serverUrl: string): any;
17+
18+
/**
19+
* Deletes all session data files if so desired.
20+
* @param {!Object} desiredCapabilities .
21+
* @return {!Array<promise.Promise>} A list of promises for the deleted files.
22+
*/
23+
export function cleanSession(desiredCapabilities: webdriver.Capabilities): any[];
24+
25+
/** @return {string} . */
26+
export function getRandomString(): string;
27+
28+
/**
29+
* @implements {command.Executor}
30+
*/
31+
export class CommandExecutor {
32+
}
33+
34+
/**
35+
* Configuration options specific to the {@link Driver SafariDriver}.
36+
*/
37+
export class Options {
38+
/**
39+
* Extracts the SafariDriver specific options from the given capabilities
40+
* object.
41+
* @param {!Capabilities} capabilities The capabilities object.
42+
* @return {!Options} The ChromeDriver options.
43+
*/
44+
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
45+
46+
/**
47+
* Sets whether to force Safari to start with a clean session. Enabling this
48+
* option will cause all global browser data to be deleted.
49+
* @param {boolean} clean Whether to make sure the session has no cookies,
50+
* cache entries, local storage, or databases.
51+
* @return {!Options} A self reference.
52+
*/
53+
setCleanSession(clean: boolean): Options;
54+
55+
/**
56+
* Sets the logging preferences for the new session.
57+
* @param {!./lib/logging.Preferences} prefs The logging preferences.
58+
* @return {!Options} A self reference.
59+
*/
60+
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
61+
62+
/**
63+
* Converts this options instance to a {@link Capabilities} object.
64+
* @param {Capabilities=} opt_capabilities The capabilities to
65+
* merge these options into, if any.
66+
* @return {!Capabilities} The capabilities.
67+
*/
68+
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
69+
}
70+
71+
/**
72+
* A WebDriver client for Safari. This class should never be instantiated
73+
* directly; instead, use the {@linkplain ./builder.Builder Builder}:
74+
*
75+
* var driver = new Builder()
76+
* .forBrowser('safari')
77+
* .build();
78+
*
79+
*/
80+
export class Driver extends webdriver.WebDriver {
81+
/**
82+
* Creates a new Safari session.
83+
*
84+
* @param {(Options|Capabilities)=} opt_config The configuration
85+
* options for the new session.
86+
* @param {promise.ControlFlow=} opt_flow The control flow to create
87+
* the driver under.
88+
* @return {!Driver} A new driver instance.
89+
*/
90+
static createSession(opt_config?: Options | webdriver.Capabilities, opt_flow?: webdriver.promise.ControlFlow): Driver;
91+
}

‎typings/testing.d.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { promise } from './index';
2+
import * as Testing from './testing';
3+
4+
export const describe: {
5+
/**
6+
* Registers a new test suite.
7+
* @param name The suite name.
8+
* @param fn The suite function, or {@code undefined} to define a pending test suite.
9+
*/
10+
(name: string, fn: Function): void;
11+
12+
/**
13+
* An alias for {@link #describe()} that marks the suite as exclusive,
14+
* suppressing all other test suites.
15+
* @param {string} name The suite name.
16+
* @param {function()=} opt_fn The suite function, or `undefined` to define
17+
* a pending test suite.
18+
*/
19+
only(name: string, fn: Function): void;
20+
21+
/**
22+
* Defines a suppressed test suite.
23+
* @param name The suite name.
24+
* @param fn The suite function, or {@code undefined} to define a pending test suite.
25+
*/
26+
skip(name: string, fn: Function): void;
27+
};
28+
29+
/**
30+
* Defines a suppressed test suite.
31+
* @param name The suite name.
32+
* @param fn The suite function, or {@code undefined} to define a pending test suite.
33+
*/
34+
export function xdescribe(name: string, fn: Function): void;
35+
36+
/**
37+
* Register a function to call after the current suite finishes.
38+
* @param fn
39+
*/
40+
export function after(fn: Function): void;
41+
42+
/**
43+
* Register a function to call after each test in a suite.
44+
* @param fn
45+
*/
46+
export function afterEach(fn: Function): void;
47+
48+
/**
49+
* Register a function to call before the current suite starts.
50+
* @param fn
51+
*/
52+
export function before(fn: Function): void;
53+
54+
/**
55+
* Register a function to call before each test in a suite.
56+
* @param fn
57+
*/
58+
export function beforeEach(fn: Function): void;
59+
60+
export const it: {
61+
/**
62+
* Add a test to the current suite.
63+
* @param name The test name.
64+
* @param fn The test function, or {@code undefined} to define a pending test case.
65+
*/
66+
(name: string, fn: Function): void;
67+
68+
/**
69+
* An alias for {@link #it()} that flags the test as the only one that should
70+
* be run within the current suite.
71+
* @param {string} name The test name.
72+
* @param {function()=} opt_fn The test function, or `undefined` to define
73+
* a pending test case.
74+
*/
75+
only(name: string, fn: Function): void;
76+
77+
/**
78+
* Adds a test to the current suite while suppressing it so it is not run.
79+
* @param name The test name.
80+
* @param fn The test function, or {@code undefined} to define a pending test case.
81+
*/
82+
skip(name: string, fn: Function): void;
83+
}
84+
85+
/**
86+
* Adds a test to the current suite while suppressing it so it is not run.
87+
* @param name The test name.
88+
* @param fn The test function, or {@code undefined} to define a pending test case.
89+
*/
90+
export function xit(name: string, fn: Function): void;
91+
92+
/**
93+
* @return {!promise.ControlFlow} the control flow instance used by this module
94+
* to coordinate test actions.
95+
*/
96+
export function controlFlow(): promise.ControlFlow;
97+
98+
/**
99+
* Ignores the test chained to this function if the provided predicate returns
100+
* true.
101+
* @param {function(): boolean} predicateFn A predicate to call to determine
102+
* if the test should be suppressed. This function MUST be synchronous.
103+
* @return {!Object} An object with wrapped versions of {@link #it()} and
104+
* {@link #describe()} that ignore tests as indicated by the predicate.
105+
*/
106+
export function ignore(predicateFn: () => boolean): typeof Testing;

0 commit comments

Comments
 (0)
This repository has been archived.