This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 #1600) Closes #1314, #1315
- Loading branch information
Showing
10 changed files
with
240 additions
and
146 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
var repl = require('repl'); | ||
var baseDebugger = require('_debugger'); | ||
var CommandRepl = require('../modes/commandRepl'); | ||
|
||
/** | ||
* BETA BETA BETA | ||
* Custom explorer to test protractor commands. | ||
* | ||
* @constructor | ||
*/ | ||
var WdRepl = function() { | ||
this.client = new baseDebugger.Client(); | ||
this.replServer; | ||
this.cmdRepl; | ||
}; | ||
|
||
/** | ||
* Initiate debugger client. | ||
* @private | ||
*/ | ||
WdRepl.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 | ||
*/ | ||
WdRepl.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 | ||
*/ | ||
WdRepl.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 | ||
*/ | ||
WdRepl.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 wdRepl = new WdRepl(); | ||
wdRepl.init(); |
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
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,23 @@ | ||
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) { | ||
/* globals browser */ | ||
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
Oops, something went wrong.