Debugging Protractor tests

Nov 30, 2013 at 7:40 PM
Is it possible to use Node.js Tools for Angular Protractor debugging? I'm not able to get it working, but I may be just doing something wrong. I set node_modules\protractor\lib\cli.js as startup file and my protractorConf.js file as script argument and directory containing protractorConf.js as a working directory. When I hit F5 I can break into protractorConf.js file, the Selenium driver and browser are launched, but my spec files aren't run. When I place a breakpoint into a spec file, the breakpoint isn't active so it looks like the spec files aren't loaded properly.

Is there any option I forgot to set up to get it working?
May 25, 2014 at 1:45 PM
Yes I was able to debug Protractor tests using the Node.JS tools for Visual Studio 1.0 Beta version.
The project "Startup file" needs to be "node_modules\protractor\bin\protractor" and the "Scripts arguments" should be the Protractor configuration file e.g. protractor.conf.js
Jul 7, 2014 at 5:25 PM
How do you change the "Startup file" and the "Scripts arguments"?
Coordinator
Jul 11, 2014 at 9:08 PM
To change the startup file, right-click on the file in solution explorer and Set as Startup file. To change the script arguments, right-click on project node, Properties, and there's a Script arguments text box.
Nov 9, 2014 at 8:22 PM
Edited Nov 9, 2014 at 8:24 PM
q1 - I found I had to open <project>.njsproj in order to set <startupfile> element to C:\Users\<myusername>\AppData\Roaming\npm\node_modules\protractor\bin\protractor in order to get angular protractor selenium end2end test debugging working. Did I overlook some <project>| properties | general field or other way of doing this?

q2 - I landed on this thread, and the node.js tools for visual studio in order to debug an issue I first raised in this angularjs forum thread [ https://groups.google.com/forum/#!topic/angular/8BcnbYqzqdM ] but was getting no answers there. What's happening is the angularjs tutorial step 4 introduces an angular protractor selenium end2end test that isn't working because the "expect(getNames()).toEqual" calls, see attached, are failing because getNames() returns null even though the earlier "phoneList" based test works and it uses same model as getNames() for grabbing list of controller injected set of <li > elements. Using the node.js tools for visual studio I can now debug into this work but it doesn't get me any further since inspecting variables such as [ var phoneNameColumn = element.all(by.repeater('phone in phones').column('phone.name')); ] appears to show only a set of late bound promises based results. Any thoughts on how I diagnose this issue using the tools so I can fix it and get the test working?
describe('PhoneCat App', function () {

    describe('Phone list view', function () {

        beforeEach(function () {
            browser.get('http://localhost:44300/index.html');  // browser object requires selenium "webdriver-manager start"
        });

        it('should be possible to control phone order via the drop down select box', function () {

            var phoneNameColumn = element.all(by.repeater('phone in phones').column('phone.name'));

            var query = element(by.model('query'));

            function getNames() {
                return phoneNameColumn.map(function (elm) {
                    return elm.getText();
                });
            }

            query.sendKeys('tablet');  // let's narrow the dataset to make the test assertions shorter

            expect(getNames()).toEqual([
                "Surface v2",
                "Lumia 2520"
            ]);

            element(by.model('orderProp')).element(by.css('option[value="name"]')).click();

            expect(getNames()).toEqual([
                "Lumia 2520",
                "Surface v2"
            ]);
        });
    });
});
Jan 25, 2015 at 4:06 AM
(Just to help somebody) You can set the startup file like this (using AppData environment variable) to avoid hard-coding the current username in the path:

<StartupFile>$(AppData)\npm\node_modules\protractor\bin\protractor</StartupFile>

This assumes that you have protractor installed globally. I chose to install it globally because otherwise resharper unit test runner finds all protractor tests inside node_modules folder if I installed it locally. The drawback was that I loosed intellisense in my javascript files. To fix this I added some files to my project manually:

http://oi57.tinypic.com/f1hc38.jpg

Does anybody knows how to install protractor locally but without all the unnecessary files? I mean, just the protractor files required to run my tests (and not the protractor folders: docs, example, plugins, testapp, etc).