angular / protractor

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

Impossible to create webdriver session with direct connect on and with parallel test run #4910

Open kekero4ka opened 6 years ago

kekero4ka commented 6 years ago

Steps to reproduce:

gecko-driver: 0.21.0 gulp-protractor: 4.1.0 protractor: 5.4.0 node: 10.5.0

Firefox config:

 baseUrl: config.frontendUrl,
    capabilities: {
        browserName: 'firefox',
        'moz:firefoxOptions': {
            args: [
                '--headless',
                '--single-process'
            ]
        },

        shardTestFiles: true,
        marionette: true,
        maxInstances: 4
    }

But during test run I get:

[11:20:34] I/testLogger - 
[11:20:34] E/launcher - Runner process exited unexpectedly with error code: 1
[11:20:34] I/launcher - 4 instance(s) of WebDriver still running
[11:20:34] I/testLogger - 
------------------------------------
[firefox #01-2] [11:19:34] I/direct - Using FirefoxDriver directly...
[firefox #01-2] 
[firefox #01-2] /opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/lib/error.js:514
[firefox #01-2]     let err = new ctor(data.message);
[firefox #01-2]               ^
[firefox #01-2] WebDriverError: connection refused
[firefox #01-2]     at Object.throwDecodedError (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/lib/error.js:514:15)
[firefox #01-2]     at parseHttpResponse (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/lib/http.js:519:13)
[firefox #01-2]     at doSend.then.response (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/lib/http.js:441:30)
[firefox #01-2]     at process._tickCallback (internal/process/next_tick.js:68:7)
[firefox #01-2] From: Task: WebDriver.createSession()
[firefox #01-2]     at Function.createSession (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
[firefox #01-2]     at Function.createSession (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/selenium-webdriver/firefox/index.js:521:41)
[firefox #01-2]     at Direct.getNewDriver (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/built/driverProviders/direct.js:105:33)
[firefox #01-2]     at Runner.createBrowser (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/built/runner.js:195:43)
[firefox #01-2]     at q.then.then (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/built/runner.js:339:29)
[firefox #01-2]     at _fulfilled (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/node_modules/q/q.js:834:54)
[firefox #01-2]     at /opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/node_modules/q/q.js:863:30
[firefox #01-2]     at Promise.promise.promiseDispatch (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/node_modules/q/q.js:796:13)
[firefox #01-2]     at /opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/node_modules/q/q.js:556:49
[firefox #01-2]     at runSingle (/opt/atlassian/pipelines/agent/build/e2e-tests/frontend/node_modules/protractor/node_modules/q/q.js:137:13)

Protractor config:

const TIMEOUT_INTERVAL = 65 * 1000;
const prettyHTMLReporter = new PrettyReporter({path: config.paths.report, isSharded: true});

const protractorBaseConfig = {
    // Bypass Selenium Server and use Chrome or Firefox driver directly for faster execution
    directConnect: true,

    disableChecks: true,

    framework: 'jasmine',

    suites: {
        all: 'src/specs/**/*-spec.js',
    },

    jasmineNodeOpts: {
        defaultTimeoutInterval: TIMEOUT_INTERVAL,
        print() {
        }
    },

    getPageTimeout: TIMEOUT_INTERVAL,

    // Before performing any action, Protractor waits until there are no pending asynchronous tasks in your Angular application.
    allScriptsTimeout: TIMEOUT_INTERVAL,

    onPrepare() {
        global.forEach = globalForEach;

        jasmine.getEnv().addReporter(prettyHTMLReporter);
        jasmine.getEnv().addReporter(new SpecReporter({
            suite: {
                displayNumber: true
            },
            spec: {
                displayStacktrace: true
            }
        }));

        return Promise.resolve(setWindowSize());
    },

    beforeLaunch() {
        prettyHTMLReporter.startReporter();
    },
    }
};

function setWindowSize() {
    return (browser.params.isCordova || envArgs.params.browser === 'mobile-emulator') ? Promise.resolve() : browser.driver.manage().window().setSize(1680, 1050);
}

exports.config = extendedConfig;
adamtaylor13 commented 3 years ago

Any update here in the future? I'd love to have Protractor running my specs in parallel, but so far I've had no luck. Is it due to the directConnect option here? I'm not getting the error that's displayed above, but I can't for the life of me figure out what else it could be.

StanislavKharchenko commented 3 years ago

I suggest to not use direct connect with parallel runs. Just setup selenium-server and connect to it

adamtaylor13 commented 3 years ago

Very well. Thanks for the direction.