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

chore(debugger): remove debugger and explore methods #5070

Merged
merged 1 commit into from
Dec 1, 2018
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
121 changes: 1 addition & 120 deletions lib/browser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {BPClient} from 'blocking-proxy';
import {ActionSequence, By, Capabilities, Command as WdCommand, FileDetector, ICommandName, Navigation, Options, promise as wdpromise, Session, TargetLocator, TouchSequence, until, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver';
import {By, Command as WdCommand, ICommandName, Navigation, promise as wdpromise, Session, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver';
import * as url from 'url';
import {extend as extendWD, ExtendedWebDriver} from 'webdriver-js-extender';

import {DebugHelper} from './debugger';
import {build$, build$$, ElementArrayFinder, ElementFinder} from './element';
import {IError} from './exitCodes';
import {ProtractorExpectedConditions} from './expectedConditions';
Expand Down Expand Up @@ -309,11 +308,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
*/
ng12Hybrid: boolean;

/**
* A helper that manages debugging tests.
*/
debugHelper: DebugHelper;

// This index type allows looking up methods by name so we can do mixins.
[key: string]: any;

Expand Down Expand Up @@ -358,7 +352,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT;
this.params = {};
this.resetUrl = DEFAULT_RESET_URL;
this.debugHelper = new DebugHelper(this);

let ng12Hybrid_ = false;
Object.defineProperty(this, 'ng12Hybrid', {
Expand Down Expand Up @@ -1038,118 +1031,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
clientSideScripts.getLocationAbsUrl, 'Protractor.getLocationAbsUrl()', rootEl));
}

/**
* Adds a task to the control flow to pause the test and inject helper
* functions
* into the browser, so that debugging may be done in the browser console.
*
* This should be used under node in debug mode, i.e. with
* protractor debug <configuration.js>
*
* @example
* While in the debugger, commands can be scheduled through webdriver by
* entering the repl:
* debug> repl
* > element(by.input('user')).sendKeys('Laura');
* > browser.debugger();
* Press Ctrl + c to leave debug repl
* debug> c
*
* This will run the sendKeys command as the next task, then re-enter the
* debugger.
*/
debugger() {
// jshint debug: true
return this.driver.executeScript(clientSideScripts.installInBrowser)
.then(() => wdpromise.controlFlow().execute(() => {
debugger;
}, 'add breakpoint to control flow'));
}

/**
* See browser.explore().
*/
enterRepl(opt_debugPort?: number) {
return this.explore(opt_debugPort);
}

/**
* Beta (unstable) explore function for entering the repl loop from
* any point in the control flow. Use browser.explore() in your test.
* Does not require changes to the command line (no need to add 'debug').
* Note, if you are wrapping your own instance of Protractor, you must
* expose globals 'browser' and 'protractor' for pause to work.
*
* @example
* element(by.id('foo')).click();
* browser.explore();
* // Execution will stop before the next click action.
* element(by.id('bar')).click();
*
* @param {number=} opt_debugPort Optional port to use for the debugging
* process
*/
explore(opt_debugPort?: number) {
let debuggerClientPath = __dirname + '/debugger/clients/explorer.js';
let onStartFn = (firstTime: boolean) => {
logger.info();
if (firstTime) {
logger.info('------- Element Explorer -------');
logger.info(
'Starting WebDriver debugger in a child process. Element ' +
'Explorer is still beta, please report issues at ' +
'github.com/angular/protractor');
logger.info();
logger.info('Type <tab> to see a list of locator strategies.');
logger.info('Use the `list` helper function to find elements by strategy:');
logger.info(' e.g., list(by.binding(\'\')) gets all bindings.');
logger.info();
}
};
this.debugHelper.initBlocking(debuggerClientPath, onStartFn, opt_debugPort);
}

/**
* Beta (unstable) pause function for debugging webdriver tests. Use
* browser.pause() in your test to enter the protractor debugger from that
* point in the control flow.
* Does not require changes to the command line (no need to add 'debug').
* Note, if you are wrapping your own instance of Protractor, you must
* expose globals 'browser' and 'protractor' for pause to work.
*
* @example
* element(by.id('foo')).click();
* browser.pause();
* // Execution will stop before the next click action.
* element(by.id('bar')).click();
*
* @param {number=} opt_debugPort Optional port to use for the debugging
* process
*/
pause(opt_debugPort?: number): wdpromise.Promise<any> {
if (this.debugHelper.isAttached()) {
logger.info('Encountered browser.pause(), but debugger already attached.');
return wdpromise.when(true);
}
let debuggerClientPath = __dirname + '/debugger/clients/wddebugger.js';
let onStartFn = (firstTime: boolean) => {
logger.info();
logger.info('Encountered browser.pause(). Attaching debugger...');
if (firstTime) {
logger.info();
logger.info('------- WebDriver Debugger -------');
logger.info(
'Starting WebDriver debugger in a child process. Pause is ' +
'still beta, please report issues at github.com/angular/protractor');
logger.info();
logger.info('press c to continue to the next webdriver command');
logger.info('press ^D to detach debugger and resume code execution');
logger.info();
}
};
this.debugHelper.init(debuggerClientPath, onStartFn, opt_debugPort);
}

/**
* Determine if the control flow is enabled.
*
Expand Down
Loading