protractor: Protractor synchronization fails if multiple versions of selenium-webdriver are in node_modules

Bug report

Setup

  • Node Version: 6.3.1
  • npm Version: 3.10.3
  • Protractor Version: 4.0.4 & 4.0.3
  • Browser(s): Chrome (52.0.2743.116 (Official Build) (64-bit))
  • Operating System and Version Ubuntu 16.04
  • Protractor configuration file
var SpecReporter = require('jasmine-spec-reporter');

exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        '../e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
        'browserName': 'chrome'
    },
    directConnect: true,
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
    },
    useAllAngular2AppRoots: true,
    beforeLaunch: function() {
        require('ts-node').register({
            project: 'e2e'
        });
    },
    onPrepare: function() {
        jasmine.getEnv().addReporter(new SpecReporter());
    }
};

Bug description

Whenever I run my e2e tests, my browser opens and immediately closes. Protractor will then claim, that all tests have passed, which just can’t be. I implemented a test like this to test this:

    it('should fail', () => {
        let ec = protractor.ExpectedConditions;
        let e = element(by.css('some-html-tag-which-definetly-doesnt-exist-in-my-app'));

        browser.wait(ec.presenceOf(e));
    });

Although this test should typically timeout, it will pass just fine in a split second.

If I add a spec like expect(true).toBe(false), the test will fail by the way.

I also had a beforeEach set up, with browser.ignoreSynchronization = true. After removing this line, all tests will pass like before, but protractor will fail anyway with this error:

/home/chris/workspace/mem-webclient/node_modules/protractor/built/exitCodes.js:87
if (e.message.indexOf(errMsg) !== -1) {                                                                                                         
              ^                                                                                                                                  

TypeError: Cannot read property 'indexOf' of undefined
    at Function.ErrorHandler.isError (/home/chris/workspace/mem-webclient/node_modules/protractor/built/exitCodes.js:87:30)
    at Function.ErrorHandler.parseError (/home/chris/workspace/mem-webclient/node_modules/protractor/built/exitCodes.js:98:26)
    at process.<anonymous> (/home/chris/workspace/mem-webclient/node_modules/protractor/built/launcher.js:169:54)
    at emitOne (events.js:96:13)
    at process.emit (events.js:188:7)
    at process.emit (/home/chris/workspace/mem-webclient/node_modules/ts-node/node_modules/source-map-support/source-map-support.js:419:21)
    at process.emit (/home/chris/workspace/mem-webclient/node_modules/protractor/node_modules/source-map-support/source-map-support.js:419:21)
    at process._fatalException (bootstrap_node.js:254:26)
/home/chris/workspace/my-webclient/node_modules/protractor/built/exitCodes.js:87
if (e.message.indexOf(errMsg) !== -1) {                                                                                                         
              ^                                                                                                                                  

TypeError: Cannot read property 'indexOf' of undefined
    at Function.ErrorHandler.isError (/home/chris/workspace/my-webclient/node_modules/protractor/built/exitCodes.js:87:30)
    at Function.ErrorHandler.parseError (/home/chris/workspace/my-webclient/node_modules/protractor/built/exitCodes.js:98:26)
    at process.<anonymous> (/home/chris/workspace/my-webclient/node_modules/protractor/built/launcher.js:169:54)
    at emitOne (events.js:96:13)
    at process.emit (events.js:188:7)
    at process.emit (/home/chris/workspace/my-webclient/node_modules/ts-node/node_modules/source-map-support/source-map-support.js:419:21)
    at process.emit (/home/chris/workspace/my-webclient/node_modules/protractor/node_modules/source-map-support/source-map-support.js:419:21)
    at process._fatalException (bootstrap_node.js:254:26)

(The error message above this sentence is copied from below referenced issue, since I currently can’t access my own logs. I will insert my actual error message above this one as soon as I have time)

This also seems to be highly relevant, since it describes the very same behaviour: https://github.com/mgechev/angular2-seed/issues/1185
Sadly, this issue was closed without further investigation.

Since this issue seems to be quite rare, I assume that it is caused by some faulty dependency or so. Therefore I thought that maybe also my package.json file could help:

"dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular2-material/button": "2.0.0-alpha.7-4",
    "@angular2-material/card": "2.0.0-alpha.7-4",
    "@angular2-material/core": "2.0.0-alpha.7-4",
    "@angular2-material/grid-list": "2.0.0-alpha.7-4",
    "@angular2-material/list": "2.0.0-alpha.7-4",
    "@angular2-material/menu": "2.0.0-alpha.7-4",
    "@angular2-material/toolbar": "2.0.0-alpha.7-4",
    "angular2-moment": "1.0.0-beta.1",
    "core-js": "2.4.1",
    "moment": "2.14.1",
    "rxjs": "5.0.0-beta.11",
    "ts-helpers": "1.1.1",
    "zone.js": "0.6.12"
},
"devDependencies": {
    "@types/hammerjs": "2.0.32",
    "@types/jasmine": "2.2.33",
    "@types/protractor": "1.5.18",
    "angular-cli": "1.0.0-beta.11-webpack.8",
    "concurrently": "2.2.0",
    "codelyzer": "0.0.28",
    "jasmine-core": "2.5.0",
    "jasmine-spec-reporter": "2.7.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-jasmine": "1.0.2",
    "karma-remap-istanbul": "0.2.1",
    "protractor": "4.0.4",
    "ts-node": "1.3.0",
    "tslint": "3.15.1",
    "typescript": "2.0.0"
}

Reproduction

See https://github.com/angular/protractor/issues/3505#issuecomment-244010430

If you need more information, please let me know. I will try to get you everything you need to reproduce and hopefully eventually fix this

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

When you turn ignoreSynchronization to false, ExpectedConditions will not work.

It did work once with ignoreSynchronization = true. I think that false is the default. This did not work due to strange timeouts I could not fix in 3 days of work. I opened a StackOverflow question for this, but did not get any response so far.

Having an unhelpful stacktrace because the error.message does not exist appears to not be correct. This should be investigated.

While I agree with that statement, this is not the core problem. Like I wrote in the bug report, protractor will just pass all tests. By the way, this will also happen if I don’t even have the application running. I can literally see that a browser window opens with the chrome error page - still the tests pass.

Please let me know what I can do for you to help your investigation