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

Refactor element explorer to work with selenium-webdriver 3 #3828

Merged
merged 1 commit into from
Dec 28, 2016

Conversation

juliemr
Copy link
Member

@juliemr juliemr commented Dec 15, 2016

This implementation now relies mostly on promises explicitly,
so the control flow is only used to add one large task to the queue.
This should pave the way for the eventual removal of the control flow,
as well as getting element explorer to work immediately.

Note that there are several missing items and TODOs at the moment:

  • Needs rebasing on top of current beta branch
  • This is only for elementExplorer, I haven't yet fixed browser.pause()
  • There's some clean-up todos to make the breakpoint more robust
  • Need to ensure that the test suite for interactive tests is still working and can still break
  • Need to ensure that error cases (e.g. bad syntax in a statement) are handled gracefully

@juliemr
Copy link
Member Author

juliemr commented Dec 16, 2016

We can greatly simplify our code by making a change to separate the 'step by execute' and 'enter repl' debuggers more clearly. This would mean that if you do browser.pause you can no longer enter a repl loop - but you can do that by instead placing browser.enterRepl in your code.

I'll go ahead and implement this to show how much easier it is to reason about. I've seen many users not know they can get into a repl from browser.pause anyway, so I think we can use this as an opportunity to improve clarity and docs.

@juliemr
Copy link
Member Author

juliemr commented Dec 16, 2016

One more item to fix - the tab completion for the explorer is currently broken. EDIT: fixed in next commit.

@juliemr juliemr changed the title WIP - Refactor element explorer to work with selenium-webdriver 3 Refactor element explorer to work with selenium-webdriver 3 Dec 18, 2016
@juliemr
Copy link
Member Author

juliemr commented Dec 18, 2016

This is now ready for review!

I'm also considering aliasing browser.enterRepl() as browser.explore(). Thoughts?

Copy link
Contributor

@heathkit heathkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is so much better! Also, I vote yes on browser.explore()

@@ -0,0 +1,3 @@
module.exports = function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to have a comment here explaining why this is awesome. Oh, and maybe it should go under debugger/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done adding a comment. I don't think this belongs under debugger/ because all of the code in there runs in the separate debugger process, whereas this is part of the same process as browser + friends.

* @param {Function} onStartFn Function to call when the debugger starts. The
* function takes a single parameter, which represents whether this is the
* first time that the debugger is called.
* @param {number=} opt_debugPort Optional port to use for the debugging
* @param {number=} opt_debugPort Optional port to u`se for the debugging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tpyo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -910,7 +910,7 @@ export class ProtractorBrowser extends Webdriver {
logger.info(' e.g., list(by.binding(\'\')) gets all bindings.');
logger.info();
};
this.debugHelper.init(debuggerClientPath, onStartFn, opt_debugPort);
this.debugHelper.init(debuggerClientPath, true, onStartFn, opt_debugPort);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you, but it'd be nice if this were an enum, or at least had a comment explaining what this flag does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed into two different functions on the theory that the best documentation is good naming.

this.dbgCodeExecutor = {
execPromise_: pausePromise, // Promise pointing to current stage of flow.
execPromise_: null, // Promise pointing to currently executing command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be null instead of undefined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, changed.

this.dbgRepl = new DebuggerRepl(this.client);
this.currentRepl = this.dbgRepl;

// We want the prompt to show up only after the controlflow text prints.
this.dbgRepl.printControlFlow_(function() {
// Backward compatibility: node version 0.8.14 has a number of built in
Copy link
Contributor

@heathkit heathkit Dec 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just get rid of this node 0.8.14 stuff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for catching that.

@@ -76,19 +84,22 @@ DebuggerRepl.prototype.stepEval = function(cmd, callback) {
* @param {function} callback
*/
DebuggerRepl.prototype.complete = function(line, callback) {
console.log('calling debuggerrepl complete');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, gone.

@juliemr
Copy link
Member Author

juliemr commented Dec 22, 2016

Comments addressed, and rebased on top of beta. PTAL!

@juliemr
Copy link
Member Author

juliemr commented Dec 28, 2016

Rebase successful! Just waiting for CI to be green now.

This implementation now relies mostly on promises explicitly,
so the control flow is only used to add one large task to the queue.
This should pave the way for the eventual removal of the control flow,
as well as getting element explorer to work immediately.

BREAKING CHANGE

You can no longer use the `repl` command from within `browser.pause()`. Instead,
use `broser.explore()` to directly enter the repl.
@juliemr juliemr merged commit 530ca59 into angular:beta Dec 28, 2016
juliemr added a commit that referenced this pull request Dec 29, 2016
This implementation now relies mostly on promises explicitly,
so the control flow is only used to add one large task to the queue.
This should pave the way for the eventual removal of the control flow,
as well as getting element explorer to work immediately.

BREAKING CHANGE

You can no longer use the `repl` command from within `browser.pause()`. Instead,
use `broser.explore()` to directly enter the repl.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants