Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a basic ServiceBuilder for Internet Explorer #6181

Merged
merged 2 commits into from Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 29 additions & 2 deletions javascript/node/selenium-webdriver/ie.js
Expand Up @@ -360,6 +360,23 @@ function createServiceFromCapabilities(capabilities) {
}


/**
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
* an [IEDriverServer](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
* server in a child process.
*/
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) {
super(opt_exe || IEDRIVER_EXE);
this.setLoopback(true); // Required.
}
}


/**
* A WebDriver client for Microsoft's Internet Explorer.
*/
Expand All @@ -368,12 +385,21 @@ class Driver extends webdriver.WebDriver {
* Creates a new session for Microsoft's Internet Explorer.
*
* @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(options) {
static createSession(options, opt_service) {
options = options || new Options();

let service = createServiceFromCapabilities(options);
let service;

if (opt_service instanceof remote.DriverService) {
service = opt_service;
} else {
service = createServiceFromCapabilities(options);
}

let client = service.start().then(url => new http.HttpClient(url));
let executor = new http.Executor(client);

Expand All @@ -396,5 +422,6 @@ class Driver extends webdriver.WebDriver {
exports.Driver = Driver;
exports.Options = Options;
exports.Level = Level;
exports.ServiceBuilder = ServiceBuilder;
exports.locateSynchronously = locateSynchronously;

18 changes: 17 additions & 1 deletion javascript/node/selenium-webdriver/index.js
Expand Up @@ -490,6 +490,18 @@ class Builder {
return this;
}

/**
* 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) {
this.ieService_ = service;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.ieService_ should be initialized to null in the constructor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

return this;
}

/**
* Set {@linkplain edge.Options options} specific to Microsoft's Edge browser
* for drivers created by this builder. Any proxy settings defined on the
Expand Down Expand Up @@ -656,7 +668,11 @@ class Builder {
}

case Browser.INTERNET_EXPLORER:
return createDriver(ie.Driver, capabilities);
let service = null;
if (this.ieService_) {
service = this.ieService_.build();
}
return createDriver(ie.Driver, capabilities, service);

case Browser.EDGE: {
let service = null;
Expand Down