@@ -235,9 +235,44 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
235
235
* 'body' but if your ng-app is on a subsection of the page it may be
236
236
* a subelement.
237
237
*
238
+ * This property is deprecated - please use angularAppRoot() instead.
239
+ *
240
+ * @deprecated
238
241
* @type {string }
239
242
*/
240
- rootEl : string ;
243
+ set rootEl ( value : string ) {
244
+ this . angularAppRoot ( value ) ;
245
+ }
246
+
247
+ get rootEl ( ) {
248
+ return this . internalRootEl ;
249
+ }
250
+
251
+ private internalRootEl : string ;
252
+
253
+ /**
254
+ * Set the css selector for an element on which to find Angular. This is usually
255
+ * 'body' but if your ng-app is on a subsection of the page it may be
256
+ * a subelement.
257
+ *
258
+ * The change will be made within WebDriver's control flow, so that commands after
259
+ * this method is called use the new app root. Pass nothing to get a promise that
260
+ * resolves to the value of the selector.
261
+ *
262
+ * @param {string } The new selector.
263
+ * @returns A promise that resolves with the value of the selector.
264
+ */
265
+ angularAppRoot ( value : string = null ) : wdpromise . Promise < string > {
266
+ return this . driver . controlFlow ( ) . execute ( ( ) => {
267
+ if ( value != null ) {
268
+ if ( this . bpClient ) {
269
+ return this . bpClient . setWaitParams ( value ) . then ( ( ) => this . internalRootEl ) ;
270
+ }
271
+ this . internalRootEl = value ;
272
+ return this . internalRootEl ;
273
+ }
274
+ } , `Set angular root selector to ${ value } ` ) ;
275
+ }
241
276
242
277
/**
243
278
* If true, Protractor will not attempt to synchronize with the page before
@@ -255,7 +290,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
255
290
this . driver . controlFlow ( ) . execute ( ( ) => {
256
291
if ( this . bpClient ) {
257
292
logger . debug ( 'Setting waitForAngular' + value ) ;
258
- this . bpClient . setSynchronization ( ! value ) ;
293
+ return this . bpClient . setWaitEnabled ( ! value ) ;
259
294
}
260
295
} , `Set proxy synchronization to ${ value } ` ) ;
261
296
this . internalIgnoreSynchronization = value ;
@@ -265,7 +300,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
265
300
return this . internalIgnoreSynchronization ;
266
301
}
267
302
268
- internalIgnoreSynchronization : boolean ;
303
+ private internalIgnoreSynchronization : boolean ;
269
304
270
305
/**
271
306
* Timeout in milliseconds to wait for pages to load when calling `get`.
@@ -570,9 +605,12 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
570
605
if ( this . plugins_ . skipAngularStability ( ) || this . bpClient ) {
571
606
return wdpromise . fulfilled ( ) ;
572
607
} else {
573
- return this . executeAsyncScript_ (
574
- clientSideScripts . waitForAngular , 'Protractor.waitForAngular()' + description ,
575
- this . rootEl ) ;
608
+ // Need to wrap this so that we read rootEl in the control flow, not synchronously.
609
+ return this . angularAppRoot ( ) . then ( ( rootEl : string ) => {
610
+ return this . executeAsyncScript_ (
611
+ clientSideScripts . waitForAngular , 'Protractor.waitForAngular()' + description ,
612
+ rootEl ) ;
613
+ } ) ;
576
614
}
577
615
} ;
578
616
@@ -794,7 +832,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
794
832
795
833
if ( this . bpClient ) {
796
834
this . driver . controlFlow ( ) . execute ( ( ) => {
797
- return this . bpClient . setSynchronization ( false ) ;
835
+ return this . bpClient . setWaitEnabled ( false ) ;
798
836
} ) ;
799
837
}
800
838
@@ -902,7 +940,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
902
940
903
941
if ( this . bpClient ) {
904
942
this . driver . controlFlow ( ) . execute ( ( ) => {
905
- return this . bpClient . setSynchronization ( ! this . internalIgnoreSynchronization ) ;
943
+ return this . bpClient . setWaitEnabled ( ! this . internalIgnoreSynchronization ) ;
906
944
} ) ;
907
945
}
908
946
0 commit comments