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

Protractor 0.24.0 fails even after successful tests #902

Closed
mgol opened this issue Jun 5, 2014 · 7 comments
Closed

Protractor 0.24.0 fails even after successful tests #902

mgol opened this issue Jun 5, 2014 · 7 comments
Assignees
Milestone

Comments

@mgol
Copy link
Member

mgol commented Jun 5, 2014

I get the following output after updating Protractor to 0.24.0:

$ protractor          
[launcher] Running 2 instances of WebDriver
..------------------------------------
PID: 90418 (capability: chrome #1)
Specs: /Users/mgol/Documents/projects/bn/cbn/repo/polona-gui/test/e2e/spec/item-panel.defs.js
Starting selenium standalone server...
Selenium standalone server started at http://192.168.1.53:57090/wd/hub
..

Finished in 1.138 seconds
2 tests, 0 assertions, 0 failures

[launcher] Runner Process Exited With Error Code: 1
[launcher] 1 instance(s) of WebDriver still running
..------------------------------------
PID: 90419 (capability: firefox #2)
Specs: /Users/mgol/Documents/projects/bn/cbn/repo/polona-gui/test/e2e/spec/item-panel.defs.js
Starting selenium standalone server...
Selenium standalone server started at http://192.168.1.53:57337/wd/hub
..

Finished in 1.258 seconds
2 tests, 0 assertions, 0 failures

[launcher] Runner Process Exited With Error Code: 1
[launcher] 0 instance(s) of WebDriver still running
[launcher] Process exited with error code 1

Chromedriver is left unkilled, browsers are still running and the process errors for some reason, without any trace.

This is a reduced test case, originally (on a larger test file) I get even smaller output:

$ protractor
[launcher] Running 2 instances of WebDriver
........[launcher] Runner Process Exited With Error Code: 1
[launcher] 2 instance(s) of WebDriver still running
..[launcher] Runner Process Exited With Error Code: 1
[launcher] 2 instance(s) of WebDriver still running
[launcher] Process exited with error code 1

My Protractor 0.24.0 config:

'use strict';

exports.config = {
    multiCapabilities: [
        {browserName: 'chrome'},
        {browserName: 'firefox'},
    ],
    specs: ['test/e2e/spec/**/item*.defs.js'],
    allScriptsTimeout: 60000,
    jasmineNodeOpts: {
        defaultTimeoutInterval: 60000,
    },
    baseUrl: 'http://localhost:8500',
    rootElement: 'html',

    onPrepare: function onPrepare() {
        var disableNgAnimate = function () {
            angular.module('disableNgAnimate', []).run(function ($animate) {
                $animate.enabled(false);
            });
        };
        browser.addMockModule('disableNgAnimate', disableNgAnimate);
        browser.driver.manage().window().setSize(1024, 768);
    },
};

My test file (under test/e2e/spec/item-panel.defs.js):

'use strict';

describe('test', function () {
    it('test1', function () {
        browser.get('/item/874072/');
        browser.executeScript('' +
            'var style = document.createElement("style");' +
            'style.innerHTML = "* {' +
            '    transition: none !important;' +
            '    -webkit-animation: none !important;' +
            '    animation: none !important;' +
            '}";' +
            'document.head.appendChild(style);');
    });

    it('test2', function () {
        $('cbn-slider.thumbnails').element(by.repeater('page in item.pages'))
            .then(function (data) {
                expect(data[1].element(by.css('a')).getAttribute('class')).not.toMatch(
                    new RegExp('(^|\\s)active($|\\s)'));
            }
        );
    });
});
@juliemr
Copy link
Member

juliemr commented Jun 5, 2014

Huh, same thing seems to work for me. Have you updated selenium standalone and chromedriver?

@mgol
Copy link
Member Author

mgol commented Jun 6, 2014

Yes, they're up to date. In my grunt test task I have the command:

./node_modules/protractor/bin/webdriver-manager update

invoked always before running e2e tests so they should always be up to date.

@mgol
Copy link
Member Author

mgol commented Jun 6, 2014

The first commit where I get this failure is 3c0e727 which is the commit with re-organization. If I checkout to the previous one and change the test code to:

'use strict';

describe('test', function () {
    it('test1', function () {
        browser.get('/item/874072/');
        browser.executeScript('' +
            'var style = document.createElement("style");' +
            'style.innerHTML = "* {' +
            '    transition: none !important;' +
            '    -webkit-animation: none !important;' +
            '    animation: none !important;' +
            '}";' +
            'document.head.appendChild(style);');
    });

    it('test2', function () {
        $('cbn-slider.thumbnails').findElements(by.repeater('page in item.pages'))
            .then(function (data) {
                expect(data[1].$('a').getAttribute('class')).not.toMatch(
                    new RegExp('(^|\\s)active($|\\s)'));
            }
        );
    });
});

i.e. change $('cbn-slider.thumbnails').element to $('cbn-slider.thumbnails').findElements and data[1].element(by.css('a')) to data[1].$('a'), everything works fine.

@juliemr
Copy link
Member

juliemr commented Jun 6, 2014

Got it, able to repro - thanks for more info. Investigating.

@juliemr juliemr self-assigned this Jun 6, 2014
juliemr added a commit to juliemr/protractor that referenced this issue Jun 9, 2014
…rror

Version 0.24.0 introduced a bug where child processes would error without outputting
the error message. Fix. See angular#902.
@juliemr
Copy link
Member

juliemr commented Jun 9, 2014

OK - fixed the error with the runner/launcher which was allowing your test to exit without printing the error message.

As for the change causing that error, this is due to the breaking changes to ElementFinder. We're rethinking that element(...).then(...) resolves to null, but in the meantime you can fix with:

    it('test2', function () {
        $('cbn-slider.thumbnails').all(by.repeater('page in item.pages')).first().element(by.css('a')).getAttribute('class')
            .then(function (class) {
                expect(class).not.toMatch(
                    new RegExp('(^|\\s)active($|\\s)'));
            }
        );
    });

@juliemr juliemr added this to the 0.25.0 milestone Jun 9, 2014
@juliemr
Copy link
Member

juliemr commented Jun 9, 2014

Fixed in 0.24.1.

@juliemr juliemr closed this as completed Jun 9, 2014
@mgol
Copy link
Member Author

mgol commented Jun 10, 2014

Thanks! The error is now shown but the protractor process itself is not killed and neither are the browsers. Perhaps it should all be cleaned up?

EDIT: corrected a typo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants