Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 7837aee

Browse files
committed
Make angularAppRoot() return a promise.
1 parent 3e937f2 commit 7837aee

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Diff for: lib/browser.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,13 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
189189
* 'body' but if your ng-app is on a subsection of the page it may be
190190
* a subelement.
191191
*
192-
* This property is deprecated - please use setAngularAppRoot() instead.
192+
* This property is deprecated - please use angularAppRoot() instead.
193193
*
194194
* @deprecated
195195
* @type {string}
196196
*/
197197
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);
204199
}
205200

206201
get rootEl() {
@@ -215,12 +210,22 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
215210
* a subelement.
216211
*
217212
* 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.
219215
*
220216
* @param {string} The new selector.
217+
* @returns A promise that resolves with the value of the selector.
221218
*/
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}`);
224229
}
225230

226231
/**
@@ -239,7 +244,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
239244
this.driver.controlFlow().execute(() => {
240245
if (this.bpClient) {
241246
logger.debug('Setting waitForAngular' + value);
242-
this.bpClient.setWaitEnabled(!value);
247+
return this.bpClient.setWaitEnabled(!value);
243248
}
244249
}, `Set proxy synchronization to ${value}`);
245250
this.internalIgnoreSynchronization = value;
@@ -555,10 +560,10 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
555560
return wdpromise.fulfilled();
556561
} else {
557562
// 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) => {
559564
return this.executeAsyncScript_(
560565
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
561-
this.rootEl);
566+
rootEl);
562567
});
563568
}
564569
};

0 commit comments

Comments
 (0)