@@ -119,6 +119,7 @@ var fs = require('fs'),
119
119
120
120
var webdriver = require ( './index' ) ,
121
121
executors = require ( './executors' ) ,
122
+ http = require ( './http' ) ,
122
123
io = require ( './io' ) ,
123
124
portprober = require ( './net/portprober' ) ,
124
125
remote = require ( './remote' ) ;
@@ -133,6 +134,32 @@ var CHROMEDRIVER_EXE =
133
134
process . platform === 'win32' ? 'chromedriver.exe' : 'chromedriver' ;
134
135
135
136
137
+ /**
138
+ * Custom command names supported by ChromeDriver.
139
+ * @enum {string}
140
+ */
141
+ var Command = {
142
+ LAUNCH_APP : 'launchApp'
143
+ } ;
144
+
145
+
146
+ /**
147
+ * Creates a command executor with support for ChromeDriver's custom commands.
148
+ * @param {!webdriver.promise.Promise<string> } url The server's URL.
149
+ * @return {!webdriver.CommandExecutor } The new command executor.
150
+ */
151
+ function createExecutor ( url ) {
152
+ return new executors . DeferredExecutor ( url . then ( function ( url ) {
153
+ var client = new http . HttpClient ( url ) ;
154
+ var executor = new http . Executor ( client ) ;
155
+ executor . defineCommand (
156
+ Command . LAUNCH_APP ,
157
+ 'POST' , '/session/:sessionId/chromium/launch_app' ) ;
158
+ return executor ;
159
+ } ) ) ;
160
+ }
161
+
162
+
136
163
/**
137
164
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
138
165
* a [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)
@@ -774,7 +801,7 @@ Options.prototype.serialize = function() {
774
801
*/
775
802
var Driver = function ( opt_config , opt_service , opt_flow ) {
776
803
var service = opt_service || getDefaultService ( ) ;
777
- var executor = executors . createExecutor ( service . start ( ) ) ;
804
+ var executor = createExecutor ( service . start ( ) ) ;
778
805
779
806
var capabilities =
780
807
opt_config instanceof Options ? opt_config . toCapabilities ( ) :
@@ -798,6 +825,19 @@ Driver.prototype.setFileDetector = function() {
798
825
} ;
799
826
800
827
828
+ /**
829
+ * Schedules a command to launch Chrome App with given ID.
830
+ * @param {string } id ID of the App to launch.
831
+ * @return {!webdriver.promise.Promise<void> } A promise that will be resolved
832
+ * when app is launched.
833
+ */
834
+ Driver . prototype . launchApp = function ( id ) {
835
+ return this . schedule (
836
+ new webdriver . Command ( Command . LAUNCH_APP ) . setParameter ( 'id' , id ) ,
837
+ 'Driver.launchApp()' ) ;
838
+ } ;
839
+
840
+
801
841
// PUBLIC API
802
842
803
843
0 commit comments