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

Commit c281157

Browse files
alan-agius4Keen Yee Liau
authored andcommitted
refactor: remove debugger and explore methods
BREAKING CHANGE: Debugger and explore methods are not compatable with Node 8+. Use `debugger` keyword instead. See: https://goo.gl/MvWqFh
1 parent 7cdb978 commit c281157

File tree

11 files changed

+1
-1237
lines changed

11 files changed

+1
-1237
lines changed

lib/browser.ts

Lines changed: 1 addition & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {BPClient} from 'blocking-proxy';
2-
import {ActionSequence, By, Capabilities, Command as WdCommand, FileDetector, ICommandName, Navigation, Options, promise as wdpromise, Session, TargetLocator, TouchSequence, until, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver';
2+
import {By, Command as WdCommand, ICommandName, Navigation, promise as wdpromise, Session, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver';
33
import * as url from 'url';
44
import {extend as extendWD, ExtendedWebDriver} from 'webdriver-js-extender';
55

6-
import {DebugHelper} from './debugger';
76
import {build$, build$$, ElementArrayFinder, ElementFinder} from './element';
87
import {IError} from './exitCodes';
98
import {ProtractorExpectedConditions} from './expectedConditions';
@@ -315,11 +314,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
315314
*/
316315
ng12Hybrid: boolean;
317316

318-
/**
319-
* A helper that manages debugging tests.
320-
*/
321-
debugHelper: DebugHelper;
322-
323317
// This index type allows looking up methods by name so we can do mixins.
324318
[key: string]: any;
325319

@@ -364,7 +358,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
364358
this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;
365359
this.params = {};
366360
this.resetUrl = DEFAULT_RESET_URL;
367-
this.debugHelper = new DebugHelper(this);
368361

369362
let ng12Hybrid_ = false;
370363
Object.defineProperty(this, 'ng12Hybrid', {
@@ -1078,118 +1071,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
10781071
clientSideScripts.getLocationAbsUrl, 'Protractor.getLocationAbsUrl()', rootEl));
10791072
}
10801073

1081-
/**
1082-
* Adds a task to the control flow to pause the test and inject helper
1083-
* functions
1084-
* into the browser, so that debugging may be done in the browser console.
1085-
*
1086-
* This should be used under node in debug mode, i.e. with
1087-
* protractor debug <configuration.js>
1088-
*
1089-
* @example
1090-
* While in the debugger, commands can be scheduled through webdriver by
1091-
* entering the repl:
1092-
* debug> repl
1093-
* > element(by.input('user')).sendKeys('Laura');
1094-
* > browser.debugger();
1095-
* Press Ctrl + c to leave debug repl
1096-
* debug> c
1097-
*
1098-
* This will run the sendKeys command as the next task, then re-enter the
1099-
* debugger.
1100-
*/
1101-
debugger() {
1102-
// jshint debug: true
1103-
return this.driver.executeScript(clientSideScripts.installInBrowser)
1104-
.then(() => wdpromise.controlFlow().execute(() => {
1105-
debugger;
1106-
}, 'add breakpoint to control flow'));
1107-
}
1108-
1109-
/**
1110-
* See browser.explore().
1111-
*/
1112-
enterRepl(opt_debugPort?: number) {
1113-
return this.explore(opt_debugPort);
1114-
}
1115-
1116-
/**
1117-
* Beta (unstable) explore function for entering the repl loop from
1118-
* any point in the control flow. Use browser.explore() in your test.
1119-
* Does not require changes to the command line (no need to add 'debug').
1120-
* Note, if you are wrapping your own instance of Protractor, you must
1121-
* expose globals 'browser' and 'protractor' for pause to work.
1122-
*
1123-
* @example
1124-
* element(by.id('foo')).click();
1125-
* browser.explore();
1126-
* // Execution will stop before the next click action.
1127-
* element(by.id('bar')).click();
1128-
*
1129-
* @param {number=} opt_debugPort Optional port to use for the debugging
1130-
* process
1131-
*/
1132-
explore(opt_debugPort?: number) {
1133-
let debuggerClientPath = __dirname + '/debugger/clients/explorer.js';
1134-
let onStartFn = (firstTime: boolean) => {
1135-
logger.info();
1136-
if (firstTime) {
1137-
logger.info('------- Element Explorer -------');
1138-
logger.info(
1139-
'Starting WebDriver debugger in a child process. Element ' +
1140-
'Explorer is still beta, please report issues at ' +
1141-
'github.com/angular/protractor');
1142-
logger.info();
1143-
logger.info('Type <tab> to see a list of locator strategies.');
1144-
logger.info('Use the `list` helper function to find elements by strategy:');
1145-
logger.info(' e.g., list(by.binding(\'\')) gets all bindings.');
1146-
logger.info();
1147-
}
1148-
};
1149-
this.debugHelper.initBlocking(debuggerClientPath, onStartFn, opt_debugPort);
1150-
}
1151-
1152-
/**
1153-
* Beta (unstable) pause function for debugging webdriver tests. Use
1154-
* browser.pause() in your test to enter the protractor debugger from that
1155-
* point in the control flow.
1156-
* Does not require changes to the command line (no need to add 'debug').
1157-
* Note, if you are wrapping your own instance of Protractor, you must
1158-
* expose globals 'browser' and 'protractor' for pause to work.
1159-
*
1160-
* @example
1161-
* element(by.id('foo')).click();
1162-
* browser.pause();
1163-
* // Execution will stop before the next click action.
1164-
* element(by.id('bar')).click();
1165-
*
1166-
* @param {number=} opt_debugPort Optional port to use for the debugging
1167-
* process
1168-
*/
1169-
pause(opt_debugPort?: number): wdpromise.Promise<any> {
1170-
if (this.debugHelper.isAttached()) {
1171-
logger.info('Encountered browser.pause(), but debugger already attached.');
1172-
return wdpromise.when(true);
1173-
}
1174-
let debuggerClientPath = __dirname + '/debugger/clients/wddebugger.js';
1175-
let onStartFn = (firstTime: boolean) => {
1176-
logger.info();
1177-
logger.info('Encountered browser.pause(). Attaching debugger...');
1178-
if (firstTime) {
1179-
logger.info();
1180-
logger.info('------- WebDriver Debugger -------');
1181-
logger.info(
1182-
'Starting WebDriver debugger in a child process. Pause is ' +
1183-
'still beta, please report issues at github.com/angular/protractor');
1184-
logger.info();
1185-
logger.info('press c to continue to the next webdriver command');
1186-
logger.info('press ^D to detach debugger and resume code execution');
1187-
logger.info();
1188-
}
1189-
};
1190-
this.debugHelper.init(debuggerClientPath, onStartFn, opt_debugPort);
1191-
}
1192-
11931074
/**
11941075
* Determine if the control flow is enabled.
11951076
*

0 commit comments

Comments
 (0)