[selenium-webdriver] Fix missing/incorrect webdriver.Builder methods (#37854)

* Add missing/incorrect builder methods and prerequisite ie infra

* Remove unnecessary UserPromptHandler change

* make ie.Driver.createSession options optional
This commit is contained in:
Dan Bjorge
2019-09-24 14:50:52 -07:00
committed by Michael Crane
parent 31b515911c
commit 32e7c93356
5 changed files with 148 additions and 8 deletions
+27 -4
View File
@@ -1,4 +1,11 @@
import * as webdriver from './index';
import * as remote from './remote';
/**
* IEDriverServer logging levels.
* @enum {string}
*/
export type Level = 'FATAL' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG' | 'TRACE';
/**
* A WebDriver client for Microsoft's Internet Explorer.
@@ -7,11 +14,14 @@ export class Driver extends webdriver.WebDriver {
/**
* Creates a new session for Microsoft's Internet Explorer.
*
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
* options.
* @param {(Capabilities|Options)=} options The configuration options.
* @param {(remote.DriverService)=} opt_service The `DriverService` to use
* to start the IEDriverServer in a child process, optionally.
* @return {!Driver} A new driver instance.
*/
static createSession(opt_config?: webdriver.Capabilities|Options): Driver;
static createSession(
options?: webdriver.Capabilities|Options,
opt_service?: remote.DriverService): Driver;
/**
* This function is a no-op as file detectors are not supported by this
@@ -159,7 +169,7 @@ export class Options extends webdriver.Capabilities {
* @param {Level} level The logging level.
* @return {!Options} A self reference.
*/
setLogLevel(level: webdriver.logging.Level): Options;
setLogLevel(level: Level): Options;
/**
* Sets the IP address of the driver's host adapter.
@@ -189,3 +199,16 @@ export class Options extends webdriver.Capabilities {
*/
setProxy(proxy: webdriver.ProxyConfig): Options;
}
/**
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
* an [IEDriverServer](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
* server in a child process.
*/
export class ServiceBuilder extends remote.DriverService.Builder {
/**
* @param {string=} opt_exe Path to the server executable to use. If omitted,
* the builder will attempt to locate the IEDriverServer on the system PATH.
*/
constructor(opt_exe?: string);
}
+63 -4
View File
@@ -1069,7 +1069,7 @@ export class Builder {
* @return {?string} The URL of the proxy server to use for the WebDriver's
* HTTP connections, or `null` if not set.
*/
getWebDriverProxy(): string;
getWebDriverProxy(): string|null;
/**
* Sets the default action to take with an unexpected alert before returning
@@ -1078,7 +1078,7 @@ export class Builder {
* 'dismiss', or 'ignore'. Defaults to 'dismiss'.
* @return {!Builder} A self reference.
*/
setAlertBehavior(behavior: string): Builder;
setAlertBehavior(behavior?: string): Builder;
/**
* Sets Chrome-specific options for drivers created by this builder. Any
@@ -1091,6 +1091,21 @@ export class Builder {
*/
setChromeOptions(options: chrome.Options): Builder;
/**
* @return {chrome.Options} the Chrome specific options currently configured
* for this builder.
*/
getChromeOptions(): chrome.Options;
/**
* Sets the service builder to use for managing the chromedriver child process
* when creating new Chrome sessions.
*
* @param {chrome.ServiceBuilder} service the service to use.
* @return {!Builder} A self reference.
*/
setChromeService(service: chrome.ServiceBuilder): Builder;
/**
* Set {@linkplain edge.Options options} specific to Microsoft's Edge browser
* for drivers created by this builder. Any proxy settings defined on the
@@ -1102,6 +1117,15 @@ export class Builder {
*/
setEdgeOptions(options: edge.Options): Builder;
/**
* Sets the {@link edge.ServiceBuilder} to use to manage the
* MicrosoftEdgeDriver child process when creating sessions locally.
*
* @param {edge.ServiceBuilder} service the service to use.
* @return {!Builder} a self reference.
*/
setEdgeService(service: edge.ServiceBuilder): Builder;
/**
* Sets Firefox-specific options for drivers created by this builder. Any
* logging or proxy settings defined on the given options will take precedence
@@ -1113,6 +1137,21 @@ export class Builder {
*/
setFirefoxOptions(options: firefox.Options): Builder;
/**
* @return {firefox.Options} the Firefox specific options currently configured
* for this instance.
*/
getFirefoxOptions(): firefox.Options;
/**
* Sets the {@link firefox.ServiceBuilder} to use to manage the geckodriver
* child process when creating Firefox sessions locally.
*
* @param {firefox.ServiceBuilder} service the service to use.
* @return {!Builder} a self reference.
*/
setFirefoxService(service: firefox.ServiceBuilder): Builder;
/**
* Set Internet Explorer specific {@linkplain ie.Options options} for drivers
* created by this builder. Any proxy settings defined on the given options
@@ -1123,6 +1162,15 @@ export class Builder {
*/
setIeOptions(options: ie.Options): Builder;
/**
* Sets the {@link ie.ServiceBuilder} to use to manage the geckodriver
* child process when creating IE sessions locally.
*
* @param {ie.ServiceBuilder} service the service to use.
* @return {!Builder} a self reference.
*/
setIeService(service: ie.ServiceBuilder): Builder;
/**
* Sets the logging preferences for the created session. Preferences may be
* changed by repeated calls, or by calling {@link #withCapabilities}.
@@ -1149,7 +1197,13 @@ export class Builder {
* @param {!safari.Options} options The Safari options to use.
* @return {!Builder} A self reference.
*/
setSafari(options: safari.Options): Builder;
setSafariOptions(options: safari.Options): Builder;
/**
* @return {safari.Options} the Safari specific options currently configured
* for this instance.
*/
getSafariOptions(): safari.Options;
/**
* Sets the http agent to use for each request.
@@ -1161,6 +1215,11 @@ export class Builder {
*/
usingHttpAgent(agent: any): Builder;
/**
* @return {http.Agent} The http agent used for each request
*/
getHttpAgent(): any|null;
/**
* Sets the URL of a remote WebDriver server to use. Once a remote URL has
* been specified, the builder direct all new clients to that server. If this
@@ -1372,7 +1431,7 @@ export class Capabilities {
* 'dismiss', or 'ignore'. Defaults to 'dismiss'.
* @return {!Capabilities} A self reference.
*/
setAlertBehavior(behavior: string): Capabilities;
setAlertBehavior(behavior?: string): Capabilities;
/**
* @param {string} key The capability to return.
+42
View File
@@ -0,0 +1,42 @@
import * as ie from 'selenium-webdriver/ie';
import * as remote from 'selenium-webdriver/remote';
import * as webdriver from 'selenium-webdriver';
function TestIeDriver() {
let driver: ie.Driver;
driver = ie.Driver.createSession();
driver = ie.Driver.createSession(webdriver.Capabilities.ie());
driver = ie.Driver.createSession(new ie.Options());
driver = ie.Driver.createSession(new ie.Options(), new remote.DriverService('/dev/null', {}));
driver.setFileDetector();
let baseDriver: webdriver.WebDriver = driver;
}
function TestIeOptions() {
let options: ie.Options = new ie.Options();
options = options.introduceFlakinessByIgnoringProtectedModeSettings(true);
options = options.ignoreZoomSetting(true);
options = options.initialBrowserUrl('url');
options = options.enablePersistentHover(true);
options = options.enableElementCacheCleanup(true);
options = options.requireWindowFocus(true);
options = options.browserAttachTimeout(10);
options = options.forceCreateProcessApi(true);
options = options.addArguments('a', 'b');
options = options.usePerProcessProxy(true);
options = options.ensureCleanSession(true);
options = options.setLogFile('path');
options = options.setLogLevel('FATAL');
options = options.setHost('hostname');
options = options.setExtractPath('path');
options = options.silent(true);
}
function TestIeServiceBuilder() {
let builder: ie.ServiceBuilder = new ie.ServiceBuilder();
builder = new ie.ServiceBuilder('exe');
let service: remote.DriverService = builder.build();
}
+15
View File
@@ -3,6 +3,8 @@ import * as chrome from 'selenium-webdriver/chrome';
import * as edge from 'selenium-webdriver/edge';
import * as firefox from 'selenium-webdriver/firefox';
import * as http from 'selenium-webdriver/http';
import * as ie from 'selenium-webdriver/ie';
import * as safari from 'selenium-webdriver/safari';
import { Command } from 'selenium-webdriver/lib/command';
function TestBuilder() {
@@ -17,12 +19,24 @@ function TestBuilder() {
let str: string = builder.getServerUrl();
builder = builder.setAlertBehavior('behavior');
builder = builder.setAlertBehavior();
builder = builder.setChromeOptions(new chrome.Options());
let chromeOpts: chrome.Options = builder.getChromeOptions();
builder = builder.setChromeService(new chrome.ServiceBuilder());
builder = builder.setEdgeOptions(new edge.Options());
builder = builder.setEdgeService(new edge.ServiceBuilder());
builder = builder.setFirefoxOptions(new firefox.Options());
let firefoxOpts: firefox.Options = builder.getFirefoxOptions();
builder = builder.setFirefoxService(new firefox.ServiceBuilder());
builder = builder.setIeOptions(new ie.Options());
builder = builder.setIeService(new ie.ServiceBuilder());
builder = builder.setLoggingPrefs(new webdriver.logging.Preferences());
builder = builder.setLoggingPrefs({ key: 'value' });
builder = builder.setProxy({ proxyType: 'type' });
builder = builder.setSafariOptions(new safari.Options());
let safariOpts: safari.Options = builder.getSafariOptions();
builder = builder.usingHttpAgent({});
let httpAgent = builder.getHttpAgent();
builder = builder.usingServer('http://someserver');
builder = builder.withCapabilities(new webdriver.Capabilities());
builder = builder.withCapabilities({ something: true });
@@ -97,6 +111,7 @@ function TestCapabilities() {
capabilities = capabilities.setEnableNativeEvents(true);
capabilities = capabilities.setScrollBehavior(1);
capabilities = capabilities.setAlertBehavior('accept');
capabilities = capabilities.setAlertBehavior();
anything = capabilities.toJSON();
+1
View File
@@ -26,6 +26,7 @@
"ie.d.ts",
"remote.d.ts",
"safari.d.ts",
"test/ie.ts",
"test/index.ts",
"test/chrome.ts",
"test/firefox.ts",