1

I use terminal for execution & debugging scripts; Actually I am unable to debug through browser.debugger(); but the same is achieved through browser.pause();

I entered below cmd for execution followed by 'repl' and then tried to enter protractor cmds but it fail to work :(

protractor debug protractor-config.js;

Note: the execution actually pause on breakpoint but unable to debug it like what we do on browser.pause()

Is there a better approach to debug using browser.debugger(); ?

enter image description here

5
  • What do you mean by failed to work? What is happening? Thanks. Commented Jul 31, 2016 at 21:30
  • when I enter some protractor functions; eg., element(by.model('todoList.todoText')).clear(); it is not clearing the text field in the running page. Commented Jul 31, 2016 at 21:32
  • @alecxe but the same function works when I debug using browser.pause() Commented Jul 31, 2016 at 21:33
  • @PrashanthSams I do not think, debugger is there for same purpose. You can't perform actions on element using debugger it is only to locate the elements or test your algorithm. Commented Aug 1, 2016 at 11:15
  • @PriyanshuShekhar can you please post how to locate elements through debugger(); as 'repl' cmd is not letting me locate elements. Commented Aug 1, 2016 at 19:13

1 Answer 1

2

Protractor's debugger() method works by scheduling a node debug breakpoint on the control flow.

This is the line you are looking for. what this means is when you are entering into repl mode from browser.debugger() and trying to locate/perform actions on elements, it queues up in the control flow! that is the reason it just shows the queued up tasks.You could check yours if you look closely!

Now if you come out of repl mode (ctrl+c) and press c the execution resumes and it executes your action which was queued up first you can check it

I agree the documentation is not full proof and clear but you can get an idea by reading it first - http://www.protractortest.org/#/debugging

Protactor's debugger uses node's debugger so you should also read about that - https://nodejs.org/api/debugger.html

If you want to debug your scripts with repl mode I would suggest use

Note: You could also change the ports by just passing the argument

browser.pause(6767); --> would start in port 6767

brower.enterRepl(4545); --> would start in port 4545

Sign up to request clarification or add additional context in comments.

6 Comments

nice answer; but what i really consider about is the real benefit of browser.debugger() in protractor and I am not getting the source anywhere :(
like, how to debug using browser.debugger(); truth is we don't need the node way of checking algorithm in protractor as that are UI based tests; I have already used pause() feature and it is pretty good. Is there any specific good features in browser.debugger() ?
I have posted the answer in Gitter, pls do check!
really thank you for the quick reply; as said in gitter, "debug their scripts by putting breakpoints to know where the issue exists" - to be clear, I'm able to put breakpoints and on execution, the script also stops at specific scheduled point but how to proceed debugging to see where issue exists ? and tats my overall question
secondly, what kind of debugging we can do through node way in protractor?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.