@@ -189,18 +189,13 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
189
189
* 'body' but if your ng-app is on a subsection of the page it may be
190
190
* a subelement.
191
191
*
192
- * This property is deprecated - please use setAngularAppRoot () instead.
192
+ * This property is deprecated - please use angularAppRoot () instead.
193
193
*
194
194
* @deprecated
195
195
* @type {string }
196
196
*/
197
197
set rootEl ( value : string ) {
198
- this . driver . controlFlow ( ) . execute ( ( ) => {
199
- if ( this . bpClient ) {
200
- this . bpClient . setWaitParams ( value ) ;
201
- }
202
- this . internalRootEl = value ;
203
- } , `Set angular root selector to ${ value } ` ) ;
198
+ this . angularAppRoot ( value ) ;
204
199
}
205
200
206
201
get rootEl ( ) {
@@ -215,12 +210,22 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
215
210
* a subelement.
216
211
*
217
212
* The change will be made within WebDriver's control flow, so that commands after
218
- * this method is called use the new app root.
213
+ * this method is called use the new app root. Pass nothing to get a promise that
214
+ * resolves to the value of the selector.
219
215
*
220
216
* @param {string } The new selector.
217
+ * @returns A promise that resolves with the value of the selector.
221
218
*/
222
- setAngularAppRoot ( value : string ) {
223
- this . rootEl = value ;
219
+ angularAppRoot ( value : string = null ) : wdpromise . Promise < string > {
220
+ return this . driver . controlFlow ( ) . execute ( ( ) => {
221
+ if ( value != null ) {
222
+ if ( this . bpClient ) {
223
+ return this . bpClient . setWaitParams ( value ) . then ( ( ) => this . internalRootEl ) ;
224
+ }
225
+ this . internalRootEl = value ;
226
+ return this . internalRootEl ;
227
+ }
228
+ } , `Set angular root selector to ${ value } ` ) ;
224
229
}
225
230
226
231
/**
@@ -239,7 +244,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
239
244
this . driver . controlFlow ( ) . execute ( ( ) => {
240
245
if ( this . bpClient ) {
241
246
logger . debug ( 'Setting waitForAngular' + value ) ;
242
- this . bpClient . setWaitEnabled ( ! value ) ;
247
+ return this . bpClient . setWaitEnabled ( ! value ) ;
243
248
}
244
249
} , `Set proxy synchronization to ${ value } ` ) ;
245
250
this . internalIgnoreSynchronization = value ;
@@ -555,10 +560,10 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
555
560
return wdpromise . fulfilled ( ) ;
556
561
} else {
557
562
// Need to wrap this so that we read rootEl in the control flow, not synchronously.
558
- return this . driver . controlFlow ( ) . execute ( ( ) => {
563
+ return this . angularAppRoot ( ) . then ( ( rootEl : string ) => {
559
564
return this . executeAsyncScript_ (
560
565
clientSideScripts . waitForAngular , 'Protractor.waitForAngular()' + description ,
561
- this . rootEl ) ;
566
+ rootEl ) ;
562
567
} ) ;
563
568
}
564
569
} ;
0 commit comments