@@ -104,8 +104,8 @@ function buildElementHelper(browser: ProtractorBrowser): ElementHelper {
104
104
* @extends {webdriver_extensions.ExtendedWebDriver }
105
105
* @param {webdriver.WebDriver } webdriver
106
106
* @param {string= } opt_baseUrl A base URL to run get requests against.
107
- * @param {string= } opt_rootElement Selector element that has an ng-app in
108
- * scope.
107
+ * @param {string|webdriver.promise.Promise<string> = } opt_rootElement Selector element that has an
108
+ * ng-app in scope.
109
109
* @param {boolean= } opt_untrackOutstandingTimeouts Whether Protractor should
110
110
* stop tracking outstanding $timeouts.
111
111
*/
@@ -192,17 +192,19 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
192
192
* this method is called use the new app root. Pass nothing to get a promise that
193
193
* resolves to the value of the selector.
194
194
*
195
- * @param {string } The new selector.
195
+ * @param {string|webdriver.promise.Promise<string> } value The new selector.
196
196
* @returns A promise that resolves with the value of the selector.
197
197
*/
198
- angularAppRoot ( value : string = null ) : wdpromise . Promise < string > {
198
+ angularAppRoot ( value : string | wdpromise . Promise < string > = null ) : wdpromise . Promise < string > {
199
199
return this . driver . controlFlow ( ) . execute ( ( ) => {
200
200
if ( value != null ) {
201
- if ( this . bpClient ) {
202
- return this . bpClient . setWaitParams ( value ) . then ( ( ) => this . internalRootEl ) ;
203
- }
204
- this . internalRootEl = value ;
205
- return this . internalRootEl ;
201
+ return wdpromise . when ( value ) . then ( ( value : string ) => {
202
+ this . internalRootEl = value ;
203
+ if ( this . bpClient ) {
204
+ return this . bpClient . setWaitParams ( value ) . then ( ( ) => this . internalRootEl ) ;
205
+ }
206
+ return this . internalRootEl ;
207
+ } ) ;
206
208
}
207
209
} , `Set angular root selector to ${ value } ` ) ;
208
210
}
@@ -316,8 +318,9 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
316
318
[ key : string ] : any ;
317
319
318
320
constructor (
319
- webdriverInstance : WebDriver , opt_baseUrl ?: string , opt_rootElement ?: string ,
320
- opt_untrackOutstandingTimeouts ?: boolean , opt_blockingProxyUrl ?: string ) {
321
+ webdriverInstance : WebDriver , opt_baseUrl ?: string ,
322
+ opt_rootElement ?: string | wdpromise . Promise < string > , opt_untrackOutstandingTimeouts ?: boolean ,
323
+ opt_blockingProxyUrl ?: string ) {
321
324
super ( ) ;
322
325
// These functions should delegate to the webdriver instance, but should
323
326
// wait for Angular to sync up before performing the action. This does not
@@ -352,7 +355,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
352
355
this . $ = build$ ( this . element , By ) ;
353
356
this . $$ = build$$ ( this . element , By ) ;
354
357
this . baseUrl = opt_baseUrl || '' ;
355
- this . rootEl = opt_rootElement || '' ;
358
+ this . angularAppRoot ( opt_rootElement || '' ) ;
356
359
this . ignoreSynchronization = false ;
357
360
this . getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT ;
358
361
this . params = { } ;
@@ -454,13 +457,14 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
454
457
* var forked = await browser.forkNewDriverInstance().ready;
455
458
* await forked.get('page1'); // 'page1' gotten by forked browser
456
459
*
457
- * @param {boolean } opt_useSameUrl Whether to navigate to current url on
458
- * creation
459
- * @param {boolean } opt_copyMockModules Whether to apply same mock modules on
460
- * creation
461
- * @returns {Browser } A browser instance.
460
+ * @param {boolean= } useSameUrl Whether to navigate to current url on creation
461
+ * @param {boolean= } copyMockModules Whether to apply same mock modules on creation
462
+ * @param {boolean= } copyConfigUpdates Whether to copy over changes to `baseUrl` and similar
463
+ * properties initialized to values in the the config. Defaults to `true`
464
+ *
465
+ * @returns {ProtractorBrowser } A browser instance.
462
466
*/
463
- forkNewDriverInstance ( opt_useSameUrl ?: boolean , opt_copyMockModules ?: boolean ) :
467
+ forkNewDriverInstance ( useSameUrl ?: boolean , copyMockModules ?: boolean , copyConfigUpdates = true ) :
464
468
ProtractorBrowser {
465
469
return null ;
466
470
}
@@ -556,7 +560,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
556
560
useAllAngular2AppRoots ( ) {
557
561
// The empty string is an invalid css selector, so we use it to easily
558
562
// signal to scripts to not find a root element.
559
- this . rootEl = '' ;
563
+ this . angularAppRoot ( '' ) ;
560
564
}
561
565
562
566
/**
@@ -698,7 +702,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
698
702
let pendingHttpsPromise = this . executeScriptWithDescription (
699
703
clientSideScripts . getPendingHttpRequests ,
700
704
'Protractor.waitForAngular() - getting pending https' + description ,
701
- this . rootEl ) ;
705
+ this . internalRootEl ) ;
702
706
703
707
return wdpromise . all ( [ pendingTimeoutsPromise , pendingHttpsPromise ] )
704
708
. then (
@@ -1035,15 +1039,18 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
1035
1039
* page has been changed.
1036
1040
*/
1037
1041
setLocation ( url : string ) : wdpromise . Promise < any > {
1038
- return this . waitForAngular ( ) . then (
1039
- ( ) => this . executeScriptWithDescription (
1040
- clientSideScripts . setLocation , 'Protractor.setLocation()' , this . rootEl , url )
1041
- . then ( ( browserErr : Error ) => {
1042
- if ( browserErr ) {
1043
- throw 'Error while navigating to \'' + url + '\' : ' +
1044
- JSON . stringify ( browserErr ) ;
1045
- }
1046
- } ) ) ;
1042
+ return this . waitForAngular ( )
1043
+ . then ( ( ) => this . angularAppRoot ( ) )
1044
+ . then (
1045
+ ( rootEl ) =>
1046
+ this . executeScriptWithDescription (
1047
+ clientSideScripts . setLocation , 'Protractor.setLocation()' , rootEl , url )
1048
+ . then ( ( browserErr : Error ) => {
1049
+ if ( browserErr ) {
1050
+ throw 'Error while navigating to \'' + url + '\' : ' +
1051
+ JSON . stringify ( browserErr ) ;
1052
+ }
1053
+ } ) ) ;
1047
1054
}
1048
1055
1049
1056
/**
@@ -1064,9 +1071,11 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
1064
1071
getLocationAbsUrl ( ) : wdpromise . Promise < any > {
1065
1072
logger . warn (
1066
1073
'`browser.getLocationAbsUrl()` is deprecated, please use `browser.getCurrentUrl` instead.' ) ;
1067
- return this . waitForAngular ( ) . then (
1068
- ( ) => this . executeScriptWithDescription (
1069
- clientSideScripts . getLocationAbsUrl , 'Protractor.getLocationAbsUrl()' , this . rootEl ) ) ;
1074
+ return this . waitForAngular ( )
1075
+ . then ( ( ) => this . angularAppRoot ( ) )
1076
+ . then (
1077
+ ( rootEl ) => this . executeScriptWithDescription (
1078
+ clientSideScripts . getLocationAbsUrl , 'Protractor.getLocationAbsUrl()' , rootEl ) ) ;
1070
1079
}
1071
1080
1072
1081
/**
0 commit comments