diff --git a/selenium-webdriver/chrome-tests.ts b/selenium-webdriver/chrome-tests.ts new file mode 100644 index 0000000000..2fce6bf6ca --- /dev/null +++ b/selenium-webdriver/chrome-tests.ts @@ -0,0 +1,61 @@ +import * as chrome from 'selenium-webdriver/chrome'; +import * as remote from 'selenium-webdriver/remote'; +import * as webdriver from 'selenium-webdriver'; + +function TestChromeDriver() { + var driver: chrome.Driver = new chrome.Driver(); + driver = new chrome.Driver(webdriver.Capabilities.chrome()); + driver = new chrome.Driver(webdriver.Capabilities.chrome(), + new remote.DriverService('executable', new chrome.Options()), + new webdriver.promise.ControlFlow()); + + var baseDriver: webdriver.WebDriver = driver; +} + +function TestChromeOptions() { + var options: chrome.Options = new chrome.Options(); + options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome()); + + options = options.addArguments('a', 'b', 'c'); + options = options.addExtensions('a', 'b', 'c'); + options = options.excludeSwitches('a', 'b', 'c'); + options = options.detachDriver(true); + options = options.setChromeBinaryPath('path'); + options = options.setChromeLogFile('logfile'); + options = options.setLocalState('state'); + options = options.androidActivity('com.example.Activity'); + options = options.androidDeviceSerial('emulator-5554'); + options = options.androidChrome(); + options = options.androidPackage('com.android.chrome'); + options = options.androidProcess('com.android.chrome'); + options = options.androidUseRunningApp(true); + options = options.setLoggingPrefs(new webdriver.logging.Preferences()); + options = options.setPerfLoggingPrefs({ + enableNetwork: true, enablePage: true, enableTimeline: true, + tracingCategories: 'category', bufferUsageReportingInterval: 1000 }); + options = options.setProxy({ proxyType: 'proxyType' }); + options = options.setUserPreferences('preferences'); + var capabilities: webdriver.Capabilities = options.toCapabilities(); + capabilities = options.toCapabilities(webdriver.Capabilities.chrome()); +} + +function TestServiceBuilder() { + var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder(); + builder = new chrome.ServiceBuilder('exe'); + + var anything: any = builder.build(); + builder = builder.usingPort(8080); + builder = builder.setAdbPort(5037); + builder = builder.loggingTo('path'); + builder = builder.enableVerboseLogging(); + builder = builder.setNumHttpThreads(5); + builder = builder.setUrlBasePath('path'); + builder = builder.setStdio('config'); + builder = builder.setStdio(['A', 'B']); + builder = builder.withEnvironment({ 'A': 'a', 'B': 'b' }); +} + +function TestChromeModule() { + var service: any = chrome.getDefaultService(); + chrome.setDefaultService(new remote.DriverService('executable', new chrome.Options())); +} diff --git a/selenium-webdriver/chrome.d.ts b/selenium-webdriver/chrome.d.ts index 55717d596d..2ecff8d2f8 100644 --- a/selenium-webdriver/chrome.d.ts +++ b/selenium-webdriver/chrome.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace chrome { /** @@ -58,9 +58,9 @@ declare namespace chrome { /** * Add additional command line arguments to use when launching the Chrome - * browser. Each argument may be specified with or without the "--" prefix - * (e.g. "--foo" and "foo"). Arguments with an associated value should be - * delimited by an "=": "foo=bar". + * browser. Each argument may be specified with or without the '--' prefix + * (e.g. '--foo' and 'foo'). Arguments with an associated value should be + * delimited by an '=': 'foo=bar'. * @param {...(string|!Array.)} var_args The arguments to add. * @return {!Options} A self reference. */ @@ -69,7 +69,7 @@ declare namespace chrome { /** * List of Chrome command line switches to exclude that ChromeDriver by default - * passes when starting Chrome. Do not prefix switches with "--". + * passes when starting Chrome. Do not prefix switches with '--'. * * @param {...(string|!Array)} var_args The switches to exclude. * @return {!Options} A self reference. @@ -91,7 +91,7 @@ declare namespace chrome { /** * Sets the path to the Chrome binary to use. On Mac OS X, this path should * reference the actual Chrome executable, not just the application binary - * (e.g. "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"). + * (e.g. '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'). * * The binary path be absolute or relative to the chromedriver server * executable, but it must exist on the machine that will launch Chrome. @@ -114,7 +114,7 @@ declare namespace chrome { /** - * Sets the user preferences for Chrome's user profile. See the "Preferences" + * Sets the user preferences for Chrome's user profile. See the 'Preferences' * file in Chrome's user data directory for examples. * @param {!Object} prefs Dictionary of user preferences to use. * @return {!Options} A self reference. @@ -157,7 +157,7 @@ declare namespace chrome { /** - * Sets preferences for the "Local State" file in Chrome's user data + * Sets preferences for the 'Local State' file in Chrome's user data * directory. * @param {!Object} state Dictionary of local state preferences. * @return {!Options} A self reference. @@ -362,8 +362,8 @@ declare namespace chrome { /** - * Sets the base path for WebDriver REST commands (e.g. "/wd/hub"). - * By default, the driver will accept commands relative to "/". + * Sets the base path for WebDriver REST commands (e.g. '/wd/hub'). + * By default, the driver will accept commands relative to '/'. * @param {string} path The base path to use. * @return {!ServiceBuilder} A self reference. */ @@ -415,4 +415,4 @@ declare namespace chrome { function setDefaultService(service: remote.DriverService): void; } -export = chrome; \ No newline at end of file +export = chrome; diff --git a/selenium-webdriver/edge.d.ts b/selenium-webdriver/edge.d.ts index 3bbc78ec83..fd59756c3d 100644 --- a/selenium-webdriver/edge.d.ts +++ b/selenium-webdriver/edge.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace edge { @@ -44,7 +44,7 @@ declare namespace edge { /** * Sets the page load strategy for Edge. - * Supported values are "normal", "eager", and "none"; + * Supported values are 'normal', 'eager', and 'none'; * * @param {string} pageLoadStrategy The page load strategy to use. * @return {!Options} A self reference. @@ -126,4 +126,4 @@ declare namespace edge { function setDefaultService(service: remote.DriverService): void; } -export = edge; \ No newline at end of file +export = edge; diff --git a/selenium-webdriver/executors.d.ts b/selenium-webdriver/executors.d.ts index 016345f27b..6cded31fec 100644 --- a/selenium-webdriver/executors.d.ts +++ b/selenium-webdriver/executors.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace executors { /** @@ -12,4 +12,4 @@ declare namespace executors { function createExecutor(url: string | webdriver.promise.Promise, opt_agent?: string, opt_proxy?: string): webdriver.Executor; } -export = executors; \ No newline at end of file +export = executors; diff --git a/selenium-webdriver/firefox-tests.ts b/selenium-webdriver/firefox-tests.ts new file mode 100644 index 0000000000..7ebe0aa856 --- /dev/null +++ b/selenium-webdriver/firefox-tests.ts @@ -0,0 +1,54 @@ +import * as firefox from 'selenium-webdriver/firefox'; +import * as remote from 'selenium-webdriver/remote'; +import * as webdriver from 'selenium-webdriver'; + +function TestBinary() { + var binary: firefox.Binary = new firefox.Binary(); + binary = new firefox.Binary('exe'); + + binary.addArguments('A', 'B', 'C'); + var promise: webdriver.promise.Promise = binary.kill(); + binary.launch('profile').then(function (result: any) { }); +} + +function TestFirefoxDriver() { + var driver: firefox.Driver = new firefox.Driver(); + driver = new firefox.Driver(webdriver.Capabilities.firefox()); + driver = new firefox.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow()); + + var baseDriver: webdriver.WebDriver = driver; +} + +function TestFirefoxOptions() { + var options: firefox.Options = new firefox.Options(); + + options = options.setBinary('binary'); + options = options.setBinary(new firefox.Binary()); + options = options.setLoggingPreferences(new webdriver.logging.Preferences()); + options = options.setProfile('profile'); + options = options.setProfile(new firefox.Profile()); + options = options.setProxy({ proxyType: 'proxy' }); + var capabilities: webdriver.Capabilities = options.toCapabilities(); +} + +function TestFirefoxProfile() { + var profile: firefox.Profile = new firefox.Profile(); + profile = new firefox.Profile('dir'); + + var bool: boolean = profile.acceptUntrustedCerts(); + profile.addExtension('ext'); + bool = profile.assumeUntrustedCertIssuer(); + profile.encode().then(function (prof: string) { }); + var num: number = profile.getPort(); + var anything: any = profile.getPreference('key'); + bool = profile.nativeEventsEnabled(); + profile.setAcceptUntrustedCerts(true); + profile.setAssumeUntrustedCertIssuer(true); + profile.setNativeEventsEnabled(true); + profile.setPort(8080); + profile.setPreference('key', 'value'); + profile.setPreference('key', 5); + profile.setPreference('key', true); + var stringPromise: webdriver.promise.Promise = profile.writeToDisk(); + stringPromise = profile.writeToDisk(true); +} diff --git a/selenium-webdriver/firefox.d.ts b/selenium-webdriver/firefox.d.ts index f8e1d2a804..25542f144f 100644 --- a/selenium-webdriver/firefox.d.ts +++ b/selenium-webdriver/firefox.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace firefox { /** @@ -254,4 +254,4 @@ declare namespace firefox { } } -export = firefox; \ No newline at end of file +export = firefox; diff --git a/selenium-webdriver/http.d.ts b/selenium-webdriver/http.d.ts index 3b32f29fac..b4ade88430 100644 --- a/selenium-webdriver/http.d.ts +++ b/selenium-webdriver/http.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace http { /** @@ -9,7 +9,7 @@ declare namespace http { function headersToString(headers: any): string; /** - * Represents a HTTP request message. This class is a "partial" request and only + * Represents a HTTP request message. This class is a 'partial' request and only * defines the path on the server to send a request to. It is each client's * responsibility to build the full URL for the final request. * @final @@ -108,15 +108,15 @@ declare namespace http { /** * Defines a new command for use with this executor. When a command is sent, * the {@code path} will be preprocessed using the command's parameters; any - * path segments prefixed with ":" will be replaced by the parameter of the - * same name. For example, given "/person/:name" and the parameters - * "{name: 'Bob'}", the final command path will be "/person/Bob". + * path segments prefixed with ':' will be replaced by the parameter of the + * same name. For example, given '/person/:name' and the parameters + * '{name: 'Bob'}', the final command path will be '/person/Bob'. * * @param {string} name The command name. * @param {string} method The HTTP method to use when sending this command. * @param {string} path The path to send the command to, relative to * the WebDriver server's command root and of the form - * "/path/:variable/segment". + * '/path/:variable/segment'. */ defineCommand(name: string, method: string, path: string): void; @@ -153,4 +153,4 @@ declare namespace http { function buildPath(path: string, parameters: Object): string; } -export = http; \ No newline at end of file +export = http; diff --git a/selenium-webdriver/ie.d.ts b/selenium-webdriver/ie.d.ts index 2489c1fd1a..5d9b51c64d 100644 --- a/selenium-webdriver/ie.d.ts +++ b/selenium-webdriver/ie.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace ie { @@ -39,7 +39,7 @@ declare namespace ie { /** * Whether to disable the protected mode settings check when the session is * created. Disbling this setting may lead to significant instability as the - * browser may become unresponsive/hang. Only "best effort" support is provided + * browser may become unresponsive/hang. Only 'best effort' support is provided * when using this capability. * * For more information, refer to the IEDriver's @@ -63,7 +63,7 @@ declare namespace ie { * Sets the initial URL loaded when IE starts. This is intended to be used with * {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in * the proper Protected Mode zone. Setting this option may cause browser - * instability or flaky and unresponsive code. Only "best effort" support is + * instability or flaky and unresponsive code. Only 'best effort' support is * provided when using this option. * * @param {string} url The initial browser URL. @@ -208,4 +208,4 @@ declare namespace ie { } -export = ie; \ No newline at end of file +export = ie; diff --git a/selenium-webdriver/selenium-webdriver-tests.ts b/selenium-webdriver/index-tests.ts similarity index 88% rename from selenium-webdriver/selenium-webdriver-tests.ts rename to selenium-webdriver/index-tests.ts index 5288debd96..ba2acb91ef 100644 --- a/selenium-webdriver/selenium-webdriver-tests.ts +++ b/selenium-webdriver/index-tests.ts @@ -1,117 +1,12 @@ -import * as webdriver from "selenium-webdriver"; -import * as chrome from "selenium-webdriver/chrome"; -import * as remote from "selenium-webdriver/remote"; -import * as executors from "selenium-webdriver/executors"; -import * as firefox from "selenium-webdriver/firefox"; -import * as testing from "selenium-webdriver/testing"; - -function TestChromeDriver() { - var driver: chrome.Driver = new chrome.Driver(); - driver = new chrome.Driver(webdriver.Capabilities.chrome()); - driver = new chrome.Driver(webdriver.Capabilities.chrome(), new remote.DriverService('executable', new chrome.Options()), new webdriver.promise.ControlFlow()); - - var baseDriver: webdriver.WebDriver = driver; -} - -function TestChromeOptions() { - var options: chrome.Options = new chrome.Options(); - options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome()); - - options = options.addArguments("a", "b", "c"); - options = options.addExtensions("a", "b", "c"); - options = options.excludeSwitches("a", "b", "c"); - options = options.detachDriver(true); - options = options.setChromeBinaryPath("path"); - options = options.setChromeLogFile("logfile"); - options = options.setLocalState("state"); - options = options.androidActivity("com.example.Activity"); - options = options.androidDeviceSerial("emulator-5554"); - options = options.androidChrome(); - options = options.androidPackage("com.android.chrome"); - options = options.androidProcess("com.android.chrome"); - options = options.androidUseRunningApp(true); - options = options.setLoggingPrefs(new webdriver.logging.Preferences()); - options = options.setPerfLoggingPrefs({ enableNetwork: true, enablePage: true, enableTimeline: true, tracingCategories: "category", bufferUsageReportingInterval: 1000 }); - options = options.setProxy({ proxyType: "proxyType" }); - options = options.setUserPreferences("preferences"); - var capabilities: webdriver.Capabilities = options.toCapabilities(); - capabilities = options.toCapabilities(webdriver.Capabilities.chrome()); -} - -function TestServiceBuilder() { - var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder(); - builder = new chrome.ServiceBuilder("exe"); - - var anything: any = builder.build(); - builder = builder.usingPort(8080); - builder = builder.setAdbPort(5037); - builder = builder.loggingTo("path"); - builder = builder.enableVerboseLogging(); - builder = builder.setNumHttpThreads(5); - builder = builder.setUrlBasePath("path"); - builder = builder.setStdio("config"); - builder = builder.setStdio(["A", "B"]); - builder = builder.withEnvironment({ "A": "a", "B": "b" }); -} - -function TestChromeModule() { - var service: any = chrome.getDefaultService(); - chrome.setDefaultService(new remote.DriverService('executable', new chrome.Options())); -} - -function TestBinary() { - var binary: firefox.Binary = new firefox.Binary(); - binary = new firefox.Binary("exe"); - - binary.addArguments("A", "B", "C"); - var promise: webdriver.promise.Promise = binary.kill(); - binary.launch("profile").then(function (result: any) { }); -} - -function TestFirefoxDriver() { - var driver: firefox.Driver = new firefox.Driver(); - driver = new firefox.Driver(webdriver.Capabilities.firefox()); - driver = new firefox.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow()); - - var baseDriver: webdriver.WebDriver = driver; -} - -function TestFirefoxOptions() { - var options: firefox.Options = new firefox.Options(); - - options = options.setBinary("binary"); - options = options.setBinary(new firefox.Binary()); - options = options.setLoggingPreferences(new webdriver.logging.Preferences()); - options = options.setProfile("profile"); - options = options.setProfile(new firefox.Profile()); - options = options.setProxy({ proxyType: "proxy" }); - var capabilities: webdriver.Capabilities = options.toCapabilities(); -} - -function TestFirefoxProfile() { - var profile: firefox.Profile = new firefox.Profile(); - profile = new firefox.Profile("dir"); - - var bool: boolean = profile.acceptUntrustedCerts(); - profile.addExtension("ext"); - bool = profile.assumeUntrustedCertIssuer(); - profile.encode().then(function (prof: string) { }); - var num: number = profile.getPort(); - var anything: any = profile.getPreference("key"); - bool = profile.nativeEventsEnabled(); - profile.setAcceptUntrustedCerts(true); - profile.setAssumeUntrustedCertIssuer(true); - profile.setNativeEventsEnabled(true); - profile.setPort(8080); - profile.setPreference("key", "value"); - profile.setPreference("key", 5); - profile.setPreference("key", true); - var stringPromise: webdriver.promise.Promise = profile.writeToDisk(); - stringPromise = profile.writeToDisk(true); -} +import * as webdriver from 'selenium-webdriver'; +import * as chrome from 'selenium-webdriver/chrome'; +import * as firefox from 'selenium-webdriver/firefox'; +import * as remote from 'selenium-webdriver/remote'; +import * as executors from 'selenium-webdriver/executors'; +import * as testing from 'selenium-webdriver/testing'; function TestExecutors() { - var exec: webdriver.Executor = executors.createExecutor("url"); + var exec: webdriver.Executor = executors.createExecutor('url'); var promise: webdriver.promise.Promise; exec = executors.createExecutor(promise); } @@ -133,7 +28,7 @@ function TestBuilder() { builder = builder.setEnableNativeEvents(true); builder = builder.setFirefoxOptions(new firefox.Options()); builder = builder.setLoggingPrefs(new webdriver.logging.Preferences()); - builder = builder.setLoggingPrefs({ "key": "value" }); + builder = builder.setLoggingPrefs({ 'key': 'value' }); builder = builder.setProxy({ proxyType: 'type' }); builder = builder.setScrollBehavior(1); builder = builder.usingServer('http://someserver'); @@ -191,7 +86,8 @@ function TestActionSequence() { sequence = sequence.mouseUp(element, webdriver.Button.LEFT); // SendKeys - sequence = sequence.sendKeys("A", "B", "C"); + sequence = sequence.sendKeys('A', 'B', 'C'); + sequence = sequence.sendKeys('A', webdriver.Key.NULL); sequence.perform().then(function () { }); } @@ -228,7 +124,7 @@ function TestAlert() { alert.accept().then(function () { }); alert.dismiss().then(function () { }); alert.getText().then(function (text: string) { }); - alert.sendKeys("ABC").then(function () { }); + alert.sendKeys('ABC').then(function () { }); } function TestBrowser() { @@ -268,7 +164,7 @@ function TestCapabilities() { capabilities = capabilities.set(webdriver.Capability.VERSION, { abc: 'def' }); capabilities = capabilities.set(webdriver.Capability.VERSION, null); capabilities = capabilities.setLoggingPrefs(new webdriver.logging.Preferences()); - capabilities = capabilities.setLoggingPrefs({ "key": "value" }); + capabilities = capabilities.setLoggingPrefs({ 'key': 'value' }); capabilities = capabilities.setProxy({ proxyType: 'Type' }); capabilities = capabilities.setEnableNativeEvents(true); capabilities = capabilities.setScrollBehavior(1); @@ -315,11 +211,11 @@ function TestCommand() { var command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE); var name: string = command.getName(); - var param: any = command.getParameter("param"); + var param: any = command.getParameter('param'); var params: any = command.getParameters(); - command = command.setParameter("param", 123); + command = command.setParameter('param', 123); command = command.setParameters({ param: 123 }); } @@ -544,7 +440,7 @@ function TestBy() { locator = webdriver.By.tagName('tag'); locator = webdriver.By.xpath('xpath'); - // Can import "By" without import declarations + // Can import 'By' without import declarations var By = webdriver.By; var locatorHash: webdriver.ByHash; @@ -689,7 +585,7 @@ function TestWebDriverWindow() { function TestWebDriver() { var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); var sessionPromise: webdriver.promise.Promise; - var executor: webdriver.Executor = executors.createExecutor("http://someserver"); + var executor: webdriver.Executor = executors.createExecutor('http://someserver'); var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow(); var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor); driver = new webdriver.WebDriver(session, executor, flow); @@ -810,7 +706,10 @@ function TestWebElement() { booleanPromise = element.isEnabled(); booleanPromise = element.isSelected(); voidPromise = element.sendKeys('A', 'B', 'C'); + voidPromise = element.sendKeys(1, 2, 3); + voidPromise = element.sendKeys(webdriver.Key.BACK_SPACE); voidPromise = element.sendKeys(stringPromise, stringPromise, stringPromise); + voidPromise = element.sendKeys('A', 1, webdriver.Key.BACK_SPACE, stringPromise); voidPromise = element.submit(); element.getId().then(function (id: string) { }); element.getRawId().then(function (id: string) { }); @@ -834,7 +733,7 @@ function TestWebElementPromise() { elementPromise.then(); elementPromise.then(function (element: webdriver.WebElement) { }); elementPromise.then(function (element: webdriver.WebElement) { }, function (error: any) { }); - elementPromise.then(function (element: webdriver.WebElement) { return "foo"; }, function (error: any) { }).then(function (result: string) { }); + elementPromise.then(function (element: webdriver.WebElement) { return 'foo'; }, function (error: any) { }).then(function (result: string) { }); elementPromise.thenCatch(function (error: any) { }).then(function (value: any) { }); @@ -886,7 +785,7 @@ function TestLoggingEntry() { function TestPromiseModule() { var cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError(); - cancellationError = new webdriver.promise.CancellationError("message"); + cancellationError = new webdriver.promise.CancellationError('message'); var str: string = cancellationError.message; str = cancellationError.name; @@ -1079,7 +978,7 @@ function TestPromiseClass() { function TestThenableClass() { var thenable: webdriver.promise.Promise = new webdriver.promise.Promise((resolve, reject) => { - resolve("a"); + resolve('a'); }); thenable.cancel('Abort'); @@ -1123,6 +1022,7 @@ function TestErrorCode() { errorCode = new webdriver.error.UnknownMethodError().code(); errorCode = new webdriver.error.UnsupportedOperationError().code(); } + async function TestAsyncAwaitable() { var thenable: webdriver.promise.Promise = new webdriver.promise.Promise((resolve, reject) => resolve('foo')); var str: string = await thenable; @@ -1135,17 +1035,17 @@ function TestTestingModule() { testing.beforeEach(function () { }); - testing.describe("My test suite", function () { - testing.it("My test", function () { + testing.describe('My test suite', function () { + testing.it('My test', function () { }); - testing.iit("My exclusive test.", function () { + testing.iit('My exclusive test.', function () { }); }); - testing.xdescribe("My disabled suite", function () { - testing.xit("My disabled test.", function () { + testing.xdescribe('My disabled suite', function () { + testing.xit('My disabled test.', function () { }); }); diff --git a/selenium-webdriver/index.d.ts b/selenium-webdriver/index.d.ts index 4f37fdb92f..17fba9ceae 100644 --- a/selenium-webdriver/index.d.ts +++ b/selenium-webdriver/index.d.ts @@ -3,12 +3,12 @@ // Definitions by: Bill Armstrong , Yuki Kokubun , Craig Nishina // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as chrome from "./chrome"; -import * as edge from "./edge"; -import * as firefox from "./firefox"; -import * as ie from "./ie"; -import * as opera from "./opera"; -import * as safari from "./safari"; +import * as chrome from './chrome'; +import * as edge from './edge'; +import * as firefox from './firefox'; +import * as ie from './ie'; +import * as opera from './opera'; +import * as safari from './safari'; declare namespace webdriver { @@ -393,8 +393,8 @@ declare namespace webdriver { /** * An object used to log debugging messages. Loggers use a hierarchical, - * dot-separated naming scheme. For instance, "foo" is considered the parent of - * the "foo.bar" and an ancestor of "foo.bar.baz". + * dot-separated naming scheme. For instance, 'foo' is considered the parent of + * the 'foo.bar' and an ancestor of 'foo.bar.baz'. * * Each logger may be assigned a {@linkplain #setLevel log level}, which * controls which level of messages will be reported to the @@ -603,7 +603,7 @@ declare namespace webdriver { /** * Determines whether a {@code value} should be treated as a promise. - * Any object whose "then" property is a function will be considered a promise. + * Any object whose 'then' property is a function will be considered a promise. * * @param {*} value The value to test. * @return {boolean} Whether the value is a promise. @@ -741,7 +741,7 @@ declare namespace webdriver { * }); * * @param {!Function} generatorFn The generator function to execute. - * @param {Object=} opt_self The object to use as "this" when invoking the + * @param {Object=} opt_self The object to use as 'this' when invoking the * initial generator. * @param {...*} var_args Any arguments to pass to the initial generator. * @return {!ManagedPromise} A promise that will resolve to the @@ -1136,7 +1136,7 @@ declare namespace webdriver { /** * Represents a value that will be resolved at some point in the future. This - * class represents the protected "producer" half of a Promise - each Deferred + * class represents the protected 'producer' half of a Promise - each Deferred * has a {@code promise} property that may be returned to consumers for * registering callbacks, reserving the ability to resolve the deferred to the * producer. @@ -1377,7 +1377,7 @@ declare namespace webdriver { class Condition { /** * @param {string} message A descriptive error message. Should complete the - * sentence "Waiting [...]" + * sentence 'Waiting [...]' * @param {function(!webdriver.WebDriver): OUT} fn The condition function to * evaluate on each iteration of the wait loop. * @constructor @@ -1661,9 +1661,9 @@ declare namespace webdriver { META: string; // alias for Windows key /** - * Simulate pressing many keys at once in a "chord". Takes a sequence of + * Simulate pressing many keys at once in a 'chord'. Takes a sequence of * keys or strings, appends each of the values to a string, - * and adds the chord termination key ({@link webdriver.Key.NULL}) and returns + * and adds the chord termination key ({@link webdriver.Key.NULL}) and returns * the resulting string. * * Note: when the low-level webdriver key handlers see Keys.NULL, active @@ -1671,8 +1671,8 @@ declare namespace webdriver { * * @param {...string} var_args The key sequence to concatenate. * @return {string} The null-terminated key sequence. - */ - chord: (...var_args: string[]) => string; + */ + chord: (...var_args: Array) => string; } /** @@ -1786,7 +1786,7 @@ declare namespace webdriver { mouseUp(opt_elementOrButton?: WebElement | string, opt_button?: string): ActionSequence; /** - * Convenience function for performing a "drag and drop" manuever. The target + * Convenience function for performing a 'drag and drop' manuever. The target * element may be moved to the location of another element, or by an offset (in * pixels). * @@ -1863,13 +1863,14 @@ declare namespace webdriver { /** * Simulates typing multiple keys. Each modifier key encountered in the * sequence will not be released until it is encountered again. All key events - * will be targetted at the currently focused element. - * @param {...(string|!webdriver.Key|!Array.<(string|!webdriver.Key)>)} var_args + * will be targeted at the currently focused element. + * + * @param {...(string|!input.Key|!Array<(string|!input.Key)>)} var_args * The keys to type. - * @return {!webdriver.ActionSequence} A self reference. + * @return {!ActionSequence} A self reference. * @throws {Error} If the key is not a valid modifier key. */ - sendKeys(...var_args: Array): ActionSequence; + sendKeys(...var_args: Array>): ActionSequence; //endregion } @@ -2023,7 +2024,7 @@ declare namespace webdriver { /** * Retrieves the message text displayed with this alert. For instance, if the - * alert were opened with alert("hello"), then this would return "hello". + * alert were opened with alert('hello'), then this would return 'hello'. * @return {!webdriver.promise.Promise} A promise that will be resolved to the * text displayed with this alert. */ @@ -2263,7 +2264,7 @@ declare namespace webdriver { * option always takes precedence over {@code SELENIUM_SERVER_JAR}. * * - {@code SELENIUM_SERVER_JAR}: defines the path to the - * + * * standalone Selenium server jar to use. The server will be started the * first time a WebDriver instance and be killed when the process exits. * @@ -2381,8 +2382,8 @@ declare namespace webdriver { /** * Sets the default action to take with an unexpected alert before returning * an error. - * @param {string} beahvior The desired behavior; should be "accept", "dismiss", - * or "ignore". Defaults to "dismiss". + * @param {string} beahvior The desired behavior; should be 'accept', 'dismiss', + * or 'ignore'. Defaults to 'dismiss'. * @return {!Builder} A self reference. */ setAlertBehavior(behavior: string): Builder; @@ -2562,7 +2563,7 @@ declare namespace webdriver { /** * Locates eleemnts by the ID attribute. This locator uses the CSS selector - * `*[id="$ID"]`, _not_ `document.getElementById`. + * `*[id='$ID']`, _not_ `document.getElementById`. * * @param {string} id The ID to search for. * @return {!By} The new locator. @@ -2753,7 +2754,7 @@ declare namespace webdriver { /** * Defines how the driver should handle unexpected alerts. The value should - * be one of "accept", "dismiss", or "ignore. + * be one of 'accept', 'dismiss', or 'ignore. */ UNEXPECTED_ALERT_BEHAVIOR: string; @@ -2834,8 +2835,8 @@ declare namespace webdriver { /** * Sets the default action to take with an unexpected alert before returning * an error. - * @param {string} behavior The desired behavior; should be "accept", "dismiss", - * or "ignore". Defaults to "dismiss". + * @param {string} behavior The desired behavior; should be 'accept', 'dismiss', + * or 'ignore'. Defaults to 'dismiss'. * @return {!webdriver.Capabilities} A self reference. */ setAlertBehavior(behavior: string): Capabilities; @@ -3637,7 +3638,7 @@ declare namespace webdriver { /** * Used with {@link webdriver.WebElement#sendKeys WebElement#sendKeys} on file - * input elements ({@code }) to detect when the entered key + * input elements ({@code }) to detect when the entered key * sequence defines the path to a file. * * By default, {@linkplain webdriver.WebElement WebElement's} will enter all @@ -3915,7 +3916,7 @@ declare namespace webdriver { * driver.executeAsyncScript(function() { * var callback = arguments[arguments.length - 1]; * var xhr = new XMLHttpRequest(); - * xhr.open("GET", "/resource/data.json", true); + * xhr.open('GET', '/resource/data.json', true); * xhr.onreadystatechange = function() { * if (xhr.readyState == 4) { * callback(xhr.responseText); @@ -4193,46 +4194,62 @@ declare namespace webdriver { click(): webdriver.promise.Promise; /** - * Schedules a command to type a sequence on the DOM element represented by this - * instance. - *

+ * Schedules a command to type a sequence on the DOM element represented by + * this instance. + * * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is - * processed in the keysequence, that key state is toggled until one of the + * processed in the key sequence, that key state is toggled until one of the * following occurs: - *

    - *
  • The modifier key is encountered again in the sequence. At this point the - * state of the key is toggled (along with the appropriate keyup/down events). - *
  • - *
  • The {@code webdriver.Key.NULL} key is encountered in the sequence. When - * this key is encountered, all modifier keys current in the down state are - * released (with accompanying keyup events). The NULL key can be used to - * simulate common keyboard shortcuts: - * - * element.sendKeys("text was", - * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, - * "now text is"); - * // Alternatively: - * element.sendKeys("text was", - * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), - * "now text is"); - *
  • - *
  • The end of the keysequence is encountered. When there are no more keys - * to type, all depressed modifier keys are released (with accompanying keyup - * events). - *
  • - *
- * Note: On browsers where native keyboard events are not yet - * supported (e.g. Firefox on OS X), key events will be synthesized. Special - * punctionation keys will be synthesized according to a standard QWERTY en-us + * + * - The modifier key is encountered again in the sequence. At this point the + * state of the key is toggled (along with the appropriate keyup/down + * events). + * - The {@link input.Key.NULL} key is encountered in the sequence. When + * this key is encountered, all modifier keys current in the down state are + * released (with accompanying keyup events). The NULL key can be used to + * simulate common keyboard shortcuts: + * + * element.sendKeys('text was', + * Key.CONTROL, 'a', Key.NULL, + * 'now text is'); + * // Alternatively: + * element.sendKeys('text was', + * Key.chord(Key.CONTROL, 'a'), + * 'now text is'); + * + * - The end of the key sequence is encountered. When there are no more keys + * to type, all depressed modifier keys are released (with accompanying + * keyup events). + * + * If this element is a file input ({@code }), the + * specified key sequence should specify the path to the file to attach to + * the element. This is analogous to the user clicking 'Browse...' and entering + * the path into the file select dialog. + * + * var form = driver.findElement(By.css('form')); + * var element = form.findElement(By.css('input[type=file]')); + * element.sendKeys('/path/to/file.txt'); + * form.submit(); + * + * For uploads to function correctly, the entered path must reference a file + * on the _browser's_ machine, not the local machine running this script. When + * running against a remote Selenium server, a {@link input.FileDetector} + * may be used to transparently copy files to the remote machine before + * attempting to upload them in the browser. + * + * __Note:__ On browsers where native keyboard events are not supported + * (e.g. Firefox on OS X), key events will be synthesized. Special + * punctuation keys will be synthesized according to a standard QWERTY en-us * keyboard layout. * - * @param {...string} var_args The sequence of keys to - * type. All arguments will be joined into a single sequence (var_args is - * permitted for convenience). + * @param {...(number|string|!IThenable<(number|string)>)} var_args The + * sequence of keys to type. Number keys may be referenced numerically or + * by string (1 or '1'). All arguments will be joined into a single + * sequence. * @return {!webdriver.promise.Promise} A promise that will be resolved when all * keys have been typed. */ - sendKeys(...var_args: string[]): webdriver.promise.Promise; + sendKeys(...var_args: Array>): webdriver.promise.Promise; /** * Schedules a command to query for the tag/node name of this element. @@ -4264,9 +4281,9 @@ declare namespace webdriver { * page has been loaded. More exactly, this method will return the value of the * given attribute, unless that attribute is not present, in which case the * value of the property with the same name is returned. If neither value is - * set, null is returned. The "style" attribute is converted as best can be to a + * set, null is returned. The 'style' attribute is converted as best can be to a * text representation with a trailing semi-colon. The following are deemed to - * be "boolean" attributes and will be returned as thus: + * be 'boolean' attributes and will be returned as thus: * *

async, autofocus, autoplay, checked, compact, complete, controls, declare, * defaultchecked, defaultselected, defer, disabled, draggable, ended, @@ -4278,8 +4295,8 @@ declare namespace webdriver { *

Finally, the following commonly mis-capitalized attribute/property names * are evaluated as expected: *

    - *
  • "class" - *
  • "readonly" + *
  • 'class' + *
  • 'readonly' *
* @param {string} attributeName The name of the attribute to query. * @return {!webdriver.promise.Promise} A promise that will be resolved with the @@ -4629,21 +4646,21 @@ declare namespace webdriver { * released (with accompanying keyup events). The NULL key can be used to * simulate common keyboard shortcuts: * - * element.sendKeys("text was", - * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, - * "now text is"); + * element.sendKeys('text was', + * webdriver.Key.CONTROL, 'a', webdriver.Key.NULL, + * 'now text is'); * // Alternatively: - * element.sendKeys("text was", - * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), - * "now text is"); + * element.sendKeys('text was', + * webdriver.Key.chord(webdriver.Key.CONTROL, 'a'), + * 'now text is'); * * - The end of the keysequence is encountered. When there are no more keys * to type, all depressed modifier keys are released (with accompanying keyup * events). * - * If this element is a file input ({@code }), the + * If this element is a file input ({@code }), the * specified key sequence should specify the path to the file to attach to - * the element. This is analgous to the user clicking "Browse..." and entering + * the element. This is analgous to the user clicking 'Browse...' and entering * the path into the file select dialog. * * var form = driver.findElement(By.css('form')); @@ -4667,7 +4684,7 @@ declare namespace webdriver { * @return {!webdriver.promise.Promise.} A promise that will be resolved * when all keys have been typed. */ - sendKeys(...var_args: Array>): webdriver.promise.Promise; + sendKeys(...var_args: Array>): webdriver.promise.Promise; /** * Schedules a command to query for the tag/node name of this element. @@ -4699,10 +4716,10 @@ declare namespace webdriver { * the page has been loaded. More exactly, this method will return the value of * the given attribute, unless that attribute is not present, in which case the * value of the property with the same name is returned. If neither value is - * set, null is returned (for example, the "value" property of a textarea - * element). The "style" attribute is converted as best can be to a + * set, null is returned (for example, the 'value' property of a textarea + * element). The 'style' attribute is converted as best can be to a * text representation with a trailing semi-colon. The following are deemed to - * be "boolean" attributes and will return either "true" or null: + * be 'boolean' attributes and will return either 'true' or null: * * async, autofocus, autoplay, checked, compact, complete, controls, declare, * defaultchecked, defaultselected, defer, disabled, draggable, ended, @@ -4714,8 +4731,8 @@ declare namespace webdriver { * Finally, the following commonly mis-capitalized attribute/property names * are evaluated as expected: * - * - "class" - * - "readonly" + * - 'class' + * - 'readonly' * * @param {string} attributeName The name of the attribute to query. * @return {!webdriver.promise.Promise.} A promise that will be diff --git a/selenium-webdriver/opera.d.ts b/selenium-webdriver/opera.d.ts index d0eee8d858..0d3aee1a13 100644 --- a/selenium-webdriver/opera.d.ts +++ b/selenium-webdriver/opera.d.ts @@ -1,5 +1,5 @@ -import * as webdriver from "./index"; -import * as remote from "./remote"; +import * as webdriver from './index'; +import * as remote from './remote'; declare namespace opera { /** @@ -101,9 +101,9 @@ declare namespace opera { /** * Add additional command line arguments to use when launching the Opera - * browser. Each argument may be specified with or without the "--" prefix - * (e.g. "--foo" and "foo"). Arguments with an associated value should be - * delimited by an "=": "foo=bar". + * browser. Each argument may be specified with or without the '--' prefix + * (e.g. '--foo' and 'foo'). Arguments with an associated value should be + * delimited by an '=': 'foo=bar'. * @param {...(string|!Array.)} var_args The arguments to add. * @return {!Options} A self reference. */ @@ -174,4 +174,4 @@ declare namespace opera { } } -export = opera; \ No newline at end of file +export = opera; diff --git a/selenium-webdriver/remote.d.ts b/selenium-webdriver/remote.d.ts index e49a62d939..d3cadb746a 100644 --- a/selenium-webdriver/remote.d.ts +++ b/selenium-webdriver/remote.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace remote { /** @@ -68,4 +68,4 @@ declare namespace remote { } } -export = remote; \ No newline at end of file +export = remote; diff --git a/selenium-webdriver/safari.d.ts b/selenium-webdriver/safari.d.ts index a374c31d25..82fd835b20 100644 --- a/selenium-webdriver/safari.d.ts +++ b/selenium-webdriver/safari.d.ts @@ -1,4 +1,4 @@ -import * as webdriver from "./index"; +import * as webdriver from './index'; declare namespace safari { class Server { } @@ -90,4 +90,4 @@ declare namespace safari { } } -export = safari; \ No newline at end of file +export = safari; diff --git a/selenium-webdriver/tsconfig.json b/selenium-webdriver/tsconfig.json index 0f00ce9165..89e3b4fd9f 100644 --- a/selenium-webdriver/tsconfig.json +++ b/selenium-webdriver/tsconfig.json @@ -15,16 +15,18 @@ }, "files": [ "index.d.ts", + "index-tests.ts", "chrome.d.ts", + "chrome-tests.ts", "edge.d.ts", "executors.d.ts", "firefox.d.ts", + "firefox-tests.ts", "http.d.ts", "ie.d.ts", "opera.d.ts", "remote.d.ts", "safari.d.ts", - "testing.d.ts", - "selenium-webdriver-tests.ts" + "testing.d.ts" ] -} \ No newline at end of file +}