Search code examples
javascripttestingprotractorui-testing

I can't run the test example with protractor-perf


I'm trying to run the example from the readme file:

var ProtractorPerf = require('protractor-perf');
describe('angularjs homepage todo list', function () {
    var perf = new ProtractorPerf(protractor, browser); // Initialize the perf runner
    it('should add a todo', function () {
        browser.get('http://www.angularjs.org');

        perf.start(); // Start measuring the metrics
        element(by.model('todoText')).sendKeys('write a protractor test');
        element(by.css('[value="add"]')).click();
        perf.stop(); // Stop measuring the metrics 

        if (perf.isEnabled) { // Is perf measuring enabled ?
            // Check for perf regressions, just like you check for functional regressions
            expect(perf.getStats('meanFrameTime')).toBeLessThan(60);
        };

        var todoList = element.all(by.repeater('todo in todos'));
        expect(todoList.count()).toEqual(3);
    });
});

I'm using the protractor-pre instead of protractor, and what I see after:

  1) angularjs homepage todo list should add a todo:
     TypeError: undefined is not a function
      at Context.<anonymous> (E:\dashboard-perf.spec.js:41:34
)
      at C:\Users\ky\AppData\Roaming\npm\node_modules\protractor\node_modules\se
lenium-webdriver\testing\index.js:121:22
      at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ 

So it's about line:

41         expect(todoList.count()).toEqual(3);

What is problem with my configuration? or what is that?


Solution

  • The UI in protractor's example has different IDs now. You can run the sample from the test directory here - https://github.com/axemclion/protractor-perf/blob/master/test/example.spec.js.

    I have also updated the README example.