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

Commit 0be0d03

Browse files
committed
Wrap reading rootEl in the control flow.
1 parent e68dcf1 commit 0be0d03

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

lib/bpRunner.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export class BlockingProxyRunner {
1919
this.checkSupportedConfig();
2020

2121
let args = [
22-
'--fork', '--seleniumAddress', this.config.seleniumAddress, '--rootElement',
23-
this.config.rootElement
22+
'--fork', '--seleniumAddress', this.config.seleniumAddress,
2423
];
2524
this.bpProcess = fork(BP_PATH, args, {silent: true});
2625
logger.info('Starting BlockingProxy with args: ' + args.toString());

lib/browser.ts

+41-8
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,39 @@ 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.
193+
*
194+
* @deprecated
192195
* @type {string}
193196
*/
194-
rootEl: string;
197+
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}`);
204+
}
205+
206+
get rootEl() {
207+
return this.internalRootEl;
208+
}
209+
210+
private internalRootEl: string;
211+
212+
/**
213+
* Set the css selector for an element on which to find Angular. This is usually
214+
* 'body' but if your ng-app is on a subsection of the page it may be
215+
* a subelement.
216+
*
217+
* The change will be made within WebDriver's control flow, so that commands after
218+
* this method is called use the new app root.
219+
*
220+
* @param {string} The new selector.
221+
*/
222+
setAngularAppRoot(value: string) {
223+
this.rootEl = value;
224+
}
195225

196226
/**
197227
* If true, Protractor will not attempt to synchronize with the page before
@@ -209,7 +239,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
209239
this.driver.controlFlow().execute(() => {
210240
if (this.bpClient) {
211241
logger.debug('Setting waitForAngular' + value);
212-
this.bpClient.setSynchronization(!value);
242+
this.bpClient.setWaitEnabled(!value);
213243
}
214244
}, `Set proxy synchronization to ${value}`);
215245
this.internalIgnoreSynchronization = value;
@@ -219,7 +249,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
219249
return this.internalIgnoreSynchronization;
220250
}
221251

222-
internalIgnoreSynchronization: boolean;
252+
private internalIgnoreSynchronization: boolean;
223253

224254
/**
225255
* Timeout in milliseconds to wait for pages to load when calling `get`.
@@ -524,9 +554,12 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
524554
if (this.plugins_.skipAngularStability() || this.bpClient) {
525555
return wdpromise.fulfilled();
526556
} else {
527-
return this.executeAsyncScript_(
528-
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
529-
this.rootEl);
557+
// Need to wrap this so that we read rootEl in the control flow, not synchronously.
558+
return this.driver.controlFlow().execute(() => {
559+
return this.executeAsyncScript_(
560+
clientSideScripts.waitForAngular, 'Protractor.waitForAngular()' + description,
561+
this.rootEl);
562+
});
530563
}
531564
};
532565

@@ -748,7 +781,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
748781

749782
if (this.bpClient) {
750783
this.driver.controlFlow().execute(() => {
751-
return this.bpClient.setSynchronization(false);
784+
return this.bpClient.setWaitEnabled(false);
752785
});
753786
}
754787

@@ -856,7 +889,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
856889

857890
if (this.bpClient) {
858891
this.driver.controlFlow().execute(() => {
859-
return this.bpClient.setSynchronization(!this.internalIgnoreSynchronization);
892+
return this.bpClient.setWaitEnabled(!this.internalIgnoreSynchronization);
860893
});
861894
}
862895

0 commit comments

Comments
 (0)