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 2 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
49 changes: 41 additions & 8 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,39 @@ 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.
*
* @deprecated
* @type {string}
*/
rootEl: 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}`);
}

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.
*
* @param {string} The new selector.
*/
setAngularAppRoot(value: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably return a promise so that we can use it in the async/await world.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done

this.rootEl = value;
}

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

Expand Down Expand Up @@ -748,7 +781,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 +889,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