Skip to content

Commit

Permalink
JavaScript client side support for launch_app command of chromedriver:
Browse files Browse the repository at this point in the history
/session/$sessionId/chromium/launch_app
This is related to pull request #168
  • Loading branch information
sevaseva committed Aug 6, 2015
1 parent 1b6febd commit 395bd72
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion javascript/node/selenium-webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var fs = require('fs'),

var webdriver = require('./index'),
executors = require('./executors'),
http = require('./http'),
io = require('./io'),
portprober = require('./net/portprober'),
remote = require('./remote');
Expand All @@ -133,6 +134,32 @@ var CHROMEDRIVER_EXE =
process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver';


/**
* Custom command names supported by ChromeDriver.
* @enum {string}
*/
var Command = {
LAUNCH_APP: 'launchApp'
};


/**
* Creates a command executor with support for ChromeDriver's custom commands.
* @param {!webdriver.promise.Promise<string>} url The server's URL.
* @return {!webdriver.CommandExecutor} The new command executor.
*/
function createExecutor(url) {
return new executors.DeferredExecutor(url.then(function(url) {
var client = new http.HttpClient(url);
var executor = new http.Executor(client);
executor.defineCommand(
Command.LAUNCH_APP,
'POST', '/session/:sessionId/chromium/launch_app');
return executor;
}));
}


/**
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
* a [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)
Expand Down Expand Up @@ -774,7 +801,7 @@ Options.prototype.serialize = function() {
*/
var Driver = function(opt_config, opt_service, opt_flow) {
var service = opt_service || getDefaultService();
var executor = executors.createExecutor(service.start());
var executor = createExecutor(service.start());

var capabilities =
opt_config instanceof Options ? opt_config.toCapabilities() :
Expand All @@ -798,6 +825,19 @@ Driver.prototype.setFileDetector = function() {
};


/**
* Schedules a command to launch Chrome App with given ID.
* @param {string} id ID of the App to launch.
* @return {!webdriver.promise.Promise<void>} A promise that will be resolved
* when app is launched.
*/
Driver.prototype.launchApp = function(id) {
return this.schedule(
new webdriver.Command(Command.LAUNCH_APP).setParameter('id', id),
'Driver.launchApp()');
};


// PUBLIC API


Expand Down

0 comments on commit 395bd72

Please sign in to comment.