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

Commit

Permalink
Make angularAppRoot() return a promise.
Browse files Browse the repository at this point in the history
  • Loading branch information
heathkit committed Jan 26, 2017
1 parent 3e937f2 commit ca19059
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,13 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* 'body' but if your ng-app is on a subsection of the page it may be
* a subelement.
*
* This property is deprecated - please use setAngularAppRoot() instead.
* This property is deprecated - please use angularAppRoot() instead.
*
* @deprecated
* @type {string}
*/
set rootEl(value: string) {
this.driver.controlFlow().execute(() => {
if (this.bpClient) {
this.bpClient.setWaitParams(value);
}
this.internalRootEl = value;
}, `Set angular root selector to ${value}`);
this.angularAppRoot(value);
}

get rootEl() {
Expand All @@ -215,12 +210,22 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* a subelement.
*
* The change will be made within WebDriver's control flow, so that commands after
* this method is called use the new app root.
* this method is called use the new app root. Pass nothing to get a promise that
* resolves to the value of the selector.
*
* @param {string} The new selector.
* @returns A promise that resolves with the value of the selector.
*/
setAngularAppRoot(value: string) {
this.rootEl = value;
angularAppRoot(value: string = null): wdpromise.Promise<string> {
return this.driver.controlFlow().execute(() => {
if (value != null) {
if (this.bpClient) {
return this.bpClient.setWaitParams(value).then(() => this.internalRootEl);
}
this.internalRootEl = value;
return this.internalRootEl
}
}, `Set angular root selector to ${value}`);
}

/**
Expand All @@ -239,7 +244,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
this.driver.controlFlow().execute(() => {
if (this.bpClient) {
logger.debug('Setting waitForAngular' + value);
this.bpClient.setWaitEnabled(!value);
return this.bpClient.setWaitEnabled(!value);
}
}, `Set proxy synchronization to ${value}`);
this.internalIgnoreSynchronization = value;
Expand Down Expand Up @@ -555,10 +560,10 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
return wdpromise.fulfilled();
} else {
// Need to wrap this so that we read rootEl in the control flow, not synchronously.
return this.driver.controlFlow().execute(() => {
return this.angularAppRoot().then((rootEl: string) => {
return this.executeAsyncScript_(
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
this.rootEl);
rootEl);
});
}
};
Expand Down

0 comments on commit ca19059

Please sign in to comment.