forked from angular/protractor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(elementExplorer): Combine browser.pause with elementExplorer
* reuse logic for browser.pause for elementExplorer * introduce browser.enterRepl * allow customization of driver for elementExplorer * fix bug where repl cannot return an ElementFinder (related angular#1600) Closes angular#1314, angular#1315
- Loading branch information
Showing
8 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
lib/debugger/wddebugger.js → lib/debugger/clients/wddebugger.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
var repl = require('repl'); | ||
var baseDebugger = require('_debugger'); | ||
var CommandRepl = require('../modes/commandRepl'); | ||
|
||
/** | ||
* BETA BETA BETA | ||
* Custom protractor debugger which steps through one control flow task | ||
* at a time. | ||
* | ||
* @constructor | ||
*/ | ||
var WdDebugger = function() { | ||
this.client = new baseDebugger.Client(); | ||
this.replServer; | ||
this.cmdRepl; | ||
}; | ||
|
||
/** | ||
* Initiate debugger client. | ||
* @private | ||
*/ | ||
WdDebugger.prototype.initClient_ = function() { | ||
var client = this.client; | ||
|
||
client.once('ready', function() { | ||
|
||
client.setBreakpoint({ | ||
type: 'scriptRegExp', | ||
target: 'selenium-webdriver/executors.js', | ||
line: 37 | ||
}, function() {}); | ||
}); | ||
|
||
var host = 'localhost'; | ||
var port = process.argv[2] || 5858; | ||
client.connect(port, host); // TODO - might want to add retries here. | ||
}; | ||
|
||
/** | ||
* Eval function for processing a single step in repl. | ||
* @private | ||
* @param {string} cmd | ||
* @param {object} context | ||
* @param {string} filename | ||
* @param {function} callback | ||
*/ | ||
WdDebugger.prototype.stepEval_ = function(cmd, context, filename, callback) { | ||
cmd = cmd.slice(1, cmd.length - 2); | ||
this.cmdRepl.stepEval(cmd, callback); | ||
}; | ||
|
||
/** | ||
* Instantiate all repl objects, and debuggerRepl as current and start repl. | ||
* @private | ||
*/ | ||
WdDebugger.prototype.initRepl_ = function() { | ||
var self = this; | ||
this.cmdRepl = new CommandRepl(this.client); | ||
|
||
self.replServer = repl.start({ | ||
prompt: self.cmdRepl.prompt, | ||
input: process.stdin, | ||
output: process.stdout, | ||
eval: self.stepEval_.bind(self), | ||
useGlobal: false, | ||
ignoreUndefined: true | ||
}); | ||
|
||
self.replServer.complete = self.cmdRepl.complete.bind(self.cmdRepl); | ||
|
||
self.replServer.on('exit', function() { | ||
console.log('Exiting...'); | ||
self.client.req({command: 'disconnect'}, function() { | ||
// Intentionally blank. | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Initiate the debugger. | ||
* @public | ||
*/ | ||
WdDebugger.prototype.init = function() { | ||
console.log('Type <tab> to see a list of locator strategies.'); | ||
console.log('Use the `list` helper function to find elements by strategy:'); | ||
console.log(' e.g., list(by.binding(\'\')) gets all bindings.'); | ||
|
||
this.initClient_(); | ||
this.initRepl_(); | ||
}; | ||
|
||
var wdDebugger = new WdDebugger(); | ||
wdDebugger.init(); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var q = require('q'); | ||
|
||
/** | ||
* A framework which does not actually run any tests. It allows users to drop | ||
* into a repl loop to experiment with protractor commands. | ||
* | ||
* @param {Runner} runner The current Protractor Runner. | ||
* @return {q.Promise} Promise resolved with the test results | ||
*/ | ||
exports.run = function(runner) { | ||
return q.promise(function (resolve) { | ||
if (runner.getConfig().baseUrl) { | ||
browser.get(runner.getConfig().baseUrl); | ||
} | ||
browser.enterRepl(); | ||
browser.executeScript_('', 'empty debugger hook').then(function() { | ||
resolve({ | ||
failedCount: 0 | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters