angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Browser.debug no longer working #907

Closed ericwooley closed 10 years ago

ericwooley commented 10 years ago

I am using mocha

as of 0.23.1, this worked fine

describe('clearing all the descounts', function(){
    it('should clear all inputs in the discounts sections', function () {
        browser.debugger();
        element(by.xpath('/html/body/form/div[3]/div[2]/div')).findElements(by.tagName('input')).then(function(eles){
        //  for (var i = 0; i < eles.length; i++) (function(){
        //      var idx = i;
        //      if(!eles[idx]){
        //          return;
        //      }
        //      eles[idx].isDisplayed().then(function(displayed){
        //          if(displayed){
        //              eles[idx].getAttribute('type').then(function(type){
        //                  if(type === 'text')
        //                      eles[idx].clear();
        //              });
        //          }
        //      });
        //  })();
        });
    });
});

However, with the latest release (0.24), the browser.debugger statement is skipped.

juliemr commented 10 years ago

How are you invoking protractor on the command line? This is working fine for me with protractor debug spec/mochaConf.js.

hankduan commented 10 years ago

@ericwooley do you have any additional information on this? I've played with the debugger quite a bit the past week and never encountered this. Please let me know if you have more details to reproduce, or otherwise I'll close this issue soon.

ericwooley commented 10 years ago

Sorry for the late response, somehow I missed the email for the first reply.

After some experimentation, I suspected that it had to do with my browser synchronization being turned off, however,I had a bit of a deadline so I ended up reverting back to 0.22.

I will play with this later tonight and see if I can reproduce it in a vagrant box.

ericwooley commented 10 years ago

I recreated the issue in a vagrant box here: https://github.com/ericwooley/Vagrant-nodeDev-Protractor-Debug-Error

hankduan commented 10 years ago

Can you try again angularjs.org? www.example.com is not a valid angular-based website and protractor won't work on it.

Also, to save you the trouble of debugging, try changing your findElements statement to:

element(by.xpath('/html/body/form/div[3]/div[2]/div')).
    all(by.tagName('input')).
    then(function(eles){
      //eles.length; eles[4].click(); etc
    });
ericwooley commented 10 years ago

I updated it to use angularjs.org, the problem still persists. However, I am not sure if it is browser synchronization anymore. I tested it on angularjs.org with and without sync and and still had the problem.

elgalu commented 10 years ago

You'll make your life easier by adding an extra it() just for the purposing of the break point, following your example, like this:

describe('clearing all the descounts', function(){
    it('should clear all inputs in the discounts sections', function () {
        browser.driver.get('http://angularjs.org');
    });

    it('helps me debug', function() {
        browser.debugger();
    });

    it('continues your tests', function() {
        element(by.xpath('/html/body/form/div[3]/div[2]/div')).all(by.tagName('input')....
    });
});
ericwooley commented 10 years ago

Thanks for the advice @elgalu and occasionally I do that. However it's not exactly optimal in all cases. This example is pretty contrived, which is why I didn't do it that way. Technically, that may be a valid solution/workaround, but even in the documentation it says you can put a browser.debugger line right above the line that is giving you the error.

I just tested to confirm that your workaround does work.

Also this problem persists into 0.24.2

Edit: I updated the selenium server and the problem went away. I am not sure what exactly what changed, but in any case it's working perfectly now.