diff --git a/types/selenium-webdriver/remote.d.ts b/types/selenium-webdriver/remote.d.ts index d1c5e4616c..3ef73c953d 100644 --- a/types/selenium-webdriver/remote.d.ts +++ b/types/selenium-webdriver/remote.d.ts @@ -157,6 +157,52 @@ export namespace DriverService { } } +/** + * Manages the life and death of the + * + * standalone Selenium server. + */ +export class SeleniumServer extends DriverService { + /** + * @param {string} jar Path to the Selenium server jar. + * @param {SeleniumServer.Options=} opt_options Configuration options for the + * server. + * @throws {Error} If the path to the Selenium jar is not specified or if an + * invalid port is specified. + **/ + constructor(jar: string, opt_options?: SeleniumServer.Options); +} + +export namespace SeleniumServer { + /** + * Options for the Selenium server + */ + interface Options { + /** Whether the server should only be accessed on this host's loopback address.*/ + loopback?: boolean; + + /** The port to start the server on (must be > 0). If the port is provided + as a promise, the service will wait for the promise to resolve before starting. */ + port?: number|webdriver.promise.IThenable; + + /** The arguments to pass to the service. If a promise is provided, the + service will wait for it to resolve before starting. */ + args?: string[]|webdriver.promise.IThenable; + + /** The arguments to pass to the JVM. If a promise is provided, the service + will wait for it to resolve before starting. */ + jvmArgs?: string[]|webdriver.promise.IThenable; + + /** The environment variables that should be visible to the server process. + Defaults to inheriting the current process's environment.*/ + env?: {[key: string]: string}; + + /** IO configuration for the spawned server process. For more information, + refer to the documentation of `child_process.spawn`*/ + stdio?: string|Array; + } +} + /** * A {@link webdriver.FileDetector} that may be used when running * against a remote diff --git a/types/selenium-webdriver/test/remote.ts b/types/selenium-webdriver/test/remote.ts index a783101290..014fd33af4 100644 --- a/types/selenium-webdriver/test/remote.ts +++ b/types/selenium-webdriver/test/remote.ts @@ -9,3 +9,21 @@ function TestRemoteFileDetector() { const fileDetector: remote.FileDetector = new remote.FileDetector(); fileDetector.handleFile(driver, 'path/to/file').then((path: string) => { /* empty */ }); } + +function TestSeleniumServer() { + const pathToJar = '/path/to/jar'; + const seleniumServer: remote.SeleniumServer = new remote.SeleniumServer(pathToJar); +} + +function TestSeleniumServerOptions() { + const pathToJar = '/path/to/jar'; + const options: remote.SeleniumServer.Options = { + loopback: false, + port: 4444, + args: ['--testArg'], + jvmArgs: ['--testJvmArg'], + env: {test1: 'test1', test2: 'test2'}, + stdio: 'inherit' + } + const seleniumServer: remote.SeleniumServer = new remote.SeleniumServer(pathToJar, options); +}