@@ -235,9 +235,44 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
235235 * 'body' but if your ng-app is on a subsection of the page it may be
236236 * a subelement.
237237 *
238+ * This property is deprecated - please use angularAppRoot() instead.
239+ *
240+ * @deprecated
238241 * @type {string }
239242 */
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+ }
241276
242277 /**
243278 * If true, Protractor will not attempt to synchronize with the page before
@@ -255,7 +290,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
255290 this . driver . controlFlow ( ) . execute ( ( ) => {
256291 if ( this . bpClient ) {
257292 logger . debug ( 'Setting waitForAngular' + value ) ;
258- this . bpClient . setSynchronization ( ! value ) ;
293+ return this . bpClient . setWaitEnabled ( ! value ) ;
259294 }
260295 } , `Set proxy synchronization to ${ value } ` ) ;
261296 this . internalIgnoreSynchronization = value ;
@@ -265,7 +300,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
265300 return this . internalIgnoreSynchronization ;
266301 }
267302
268- internalIgnoreSynchronization : boolean ;
303+ private internalIgnoreSynchronization : boolean ;
269304
270305 /**
271306 * Timeout in milliseconds to wait for pages to load when calling `get`.
@@ -570,9 +605,12 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
570605 if ( this . plugins_ . skipAngularStability ( ) || this . bpClient ) {
571606 return wdpromise . fulfilled ( ) ;
572607 } 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+ } ) ;
576614 }
577615 } ;
578616
@@ -794,7 +832,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
794832
795833 if ( this . bpClient ) {
796834 this . driver . controlFlow ( ) . execute ( ( ) => {
797- return this . bpClient . setSynchronization ( false ) ;
835+ return this . bpClient . setWaitEnabled ( false ) ;
798836 } ) ;
799837 }
800838
@@ -902,7 +940,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
902940
903941 if ( this . bpClient ) {
904942 this . driver . controlFlow ( ) . execute ( ( ) => {
905- return this . bpClient . setSynchronization ( ! this . internalIgnoreSynchronization ) ;
943+ return this . bpClient . setWaitEnabled ( ! this . internalIgnoreSynchronization ) ;
906944 } ) ;
907945 }
908946
0 commit comments