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

Replace rootEl with browser.setAngularRoot() #3996

Merged
merged 3 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/bpRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export class BlockingProxyRunner {
this.checkSupportedConfig();

let args = [
'--fork', '--seleniumAddress', this.config.seleniumAddress, '--rootElement',
this.config.rootElement
'--fork',
'--seleniumAddress',
this.config.seleniumAddress,
];
this.bpProcess = fork(BP_PATH, args, {silent: true});
logger.info('Starting BlockingProxy with args: ' + args.toString());
Expand Down
54 changes: 46 additions & 8 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,44 @@ 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 angularAppRoot() instead.
*
* @deprecated
* @type {string}
*/
rootEl: string;
set rootEl(value: string) {
this.angularAppRoot(value);
}

get rootEl() {
return this.internalRootEl;
}

private internalRootEl: string;

/**
* Set the css selector for an element on which to find Angular. This is usually
* 'body' but if your ng-app is on a subsection of the page it may be
* 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. 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.
*/
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}`);
}

/**
* If true, Protractor will not attempt to synchronize with the page before
Expand All @@ -209,7 +244,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
this.driver.controlFlow().execute(() => {
if (this.bpClient) {
logger.debug('Setting waitForAngular' + value);
this.bpClient.setSynchronization(!value);
return this.bpClient.setWaitEnabled(!value);
}
}, `Set proxy synchronization to ${value}`);
this.internalIgnoreSynchronization = value;
Expand All @@ -219,7 +254,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
return this.internalIgnoreSynchronization;
}

internalIgnoreSynchronization: boolean;
private internalIgnoreSynchronization: boolean;

/**
* Timeout in milliseconds to wait for pages to load when calling `get`.
Expand Down Expand Up @@ -524,9 +559,12 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
if (this.plugins_.skipAngularStability() || this.bpClient) {
return wdpromise.fulfilled();
} else {
return this.executeAsyncScript_(
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
this.rootEl);
// Need to wrap this so that we read rootEl in the control flow, not synchronously.
return this.angularAppRoot().then((rootEl: string) => {
return this.executeAsyncScript_(
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
rootEl);
});
}
};

Expand Down Expand Up @@ -748,7 +786,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {

if (this.bpClient) {
this.driver.controlFlow().execute(() => {
return this.bpClient.setSynchronization(false);
return this.bpClient.setWaitEnabled(false);
});
}

Expand Down Expand Up @@ -856,7 +894,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {

if (this.bpClient) {
this.driver.controlFlow().execute(() => {
return this.bpClient.setSynchronization(!this.internalIgnoreSynchronization);
return this.bpClient.setWaitEnabled(!this.internalIgnoreSynchronization);
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/node": "^6.0.46",
"@types/q": "^0.0.32",
"@types/selenium-webdriver": "~2.53.39",
"blocking-proxy": "0.0.2",
"blocking-proxy": "0.0.3",
"chalk": "^1.1.3",
"glob": "^7.0.3",
"jasmine": "2.4.1",
Expand Down