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

Commit

Permalink
refactor: remove debugger and explore methods
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Debugger and explore methods are not compatable with Node 8+. Use `debugger` keyword instead. See: https://goo.gl/MvWqFh
  • Loading branch information
alan-agius4 authored and Keen Yee Liau committed May 8, 2020
1 parent 7cdb978 commit c281157
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 1,237 deletions.
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 @@ -315,11 +314,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 @@ -364,7 +358,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 @@ -1078,118 +1071,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

0 comments on commit c281157

Please sign in to comment.