@@ -91,13 +91,17 @@ webdriver.WebDriver = function(session, executor, opt_flow) {
91
91
* @param {!webdriver.CommandExecutor } executor Command executor to use when
92
92
* querying for session details.
93
93
* @param {string } sessionId ID of the session to attach to.
94
+ * @param {webdriver.promise.ControlFlow= } opt_flow The control flow all driver
95
+ * commands should execute under. Defaults to the
96
+ * {@link webdriver.promise.controlFlow() currently active} control flow.
94
97
* @return {!webdriver.WebDriver } A new client for the specified session.
95
98
*/
96
- webdriver . WebDriver . attachToSession = function ( executor , sessionId ) {
99
+ webdriver . WebDriver . attachToSession = function ( executor , sessionId , opt_flow ) {
97
100
return webdriver . WebDriver . acquireSession_ ( executor ,
98
101
new webdriver . Command ( webdriver . CommandName . DESCRIBE_SESSION ) .
99
102
setParameter ( 'sessionId' , sessionId ) ,
100
- 'WebDriver.attachToSession()' ) ;
103
+ 'WebDriver.attachToSession()' ,
104
+ opt_flow ) ;
101
105
} ;
102
106
103
107
@@ -107,13 +111,19 @@ webdriver.WebDriver.attachToSession = function(executor, sessionId) {
107
111
* session with.
108
112
* @param {!webdriver.Capabilities } desiredCapabilities The desired
109
113
* capabilities for the new session.
114
+ * @param {webdriver.promise.ControlFlow= } opt_flow The control flow all driver
115
+ * commands should execute under, including the initial session creation.
116
+ * Defaults to the {@link webdriver.promise.controlFlow() currently active}
117
+ * control flow.
110
118
* @return {!webdriver.WebDriver } The driver for the newly created session.
111
119
*/
112
- webdriver . WebDriver . createSession = function ( executor , desiredCapabilities ) {
120
+ webdriver . WebDriver . createSession = function (
121
+ executor , desiredCapabilities , opt_flow ) {
113
122
return webdriver . WebDriver . acquireSession_ ( executor ,
114
123
new webdriver . Command ( webdriver . CommandName . NEW_SESSION ) .
115
124
setParameter ( 'desiredCapabilities' , desiredCapabilities ) ,
116
- 'WebDriver.createSession()' ) ;
125
+ 'WebDriver.createSession()' ,
126
+ opt_flow ) ;
117
127
} ;
118
128
119
129
@@ -126,19 +136,24 @@ webdriver.WebDriver.createSession = function(executor, desiredCapabilities) {
126
136
* @param {!webdriver.Command } command The command to send to fetch the session
127
137
* details.
128
138
* @param {string } description A descriptive debug label for this action.
139
+ * @param {webdriver.promise.ControlFlow= } opt_flow The control flow all driver
140
+ * commands should execute under. Defaults to the
141
+ * {@link webdriver.promise.controlFlow() currently active} control flow.
129
142
* @return {!webdriver.WebDriver } A new WebDriver client for the session.
130
143
* @private
131
144
*/
132
- webdriver . WebDriver . acquireSession_ = function ( executor , command , description ) {
133
- var session = webdriver . promise . controlFlow ( ) . execute ( function ( ) {
145
+ webdriver . WebDriver . acquireSession_ = function (
146
+ executor , command , description , opt_flow ) {
147
+ var flow = opt_flow || webdriver . promise . controlFlow ( ) ;
148
+ var session = flow . execute ( function ( ) {
134
149
return webdriver . WebDriver . executeCommand_ ( executor , command ) .
135
150
then ( function ( response ) {
136
151
bot . response . checkResponse ( response ) ;
137
152
return new webdriver . Session ( response [ 'sessionId' ] ,
138
153
response [ 'value' ] ) ;
139
154
} ) ;
140
155
} , description ) ;
141
- return new webdriver . WebDriver ( session , executor ) ;
156
+ return new webdriver . WebDriver ( session , executor , flow ) ;
142
157
} ;
143
158
144
159
0 commit comments