binarygiant
binarygiant

Reputation: 6422

Protractor seleniumServerJar sets selenium address to http://192.168.0.20:<random-port>

I'm trying to have Protractor start the standalone Selenium Server by setting the seleniumServerJar path according to this github issue, but it starts the selenium server on a different address and port than if you start it with java -jar or with ./node_modules/protractor/bin/webdrivermanager start.

Starting with java -jar /path/to/jar output:

$ java -jar selenium-server-standalone-2.42.2.jar Jun 23, 2014 10:28:25 PM org.openqa.grid.selenium.GridLauncher main INFO: Launching a standalone server 22:28:25.082 INFO - Java: Apple Inc. 20.65-b04-462 22:28:25.082 INFO - OS: Mac OS X 10.9.3 x86_64 22:28:25.092 INFO - v2.42.2, with Core v2.42.2. Built from revision 6a6995d 22:28:25.146 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC 22:28:25.197 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 22:28:25.198 INFO - Version Jetty/5.1.x 22:28:25.199 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 22:28:25.199 INFO - Started HttpContext[/selenium-server,/selenium-server] 22:28:25.199 INFO - Started HttpContext[/,/] 22:28:25.235 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@7786df0f 22:28:25.235 INFO - Started HttpContext[/wd,/wd] 22:28:25.240 INFO - Started SocketListener on 0.0.0.0:4444 22:28:25.240 INFO - Started org.openqa.jetty.jetty.Server@42698403

Starting it with Protractor by specifying seleniumServerJar:

$ ./node_modules/protractor/bin/protractor protractor_conf.js Starting selenium standalone server... Selenium standalone server started at http://192.168.0.20:59959/wd/hub

And then it hangs and times out.

How does one properly start the standalone selenium server when specifying seleniumServerJar?

Side note: I have put the selenium-server.jar file in my project to make it easy to use relative paths according to aformentioned github issue.

My protractor_conf.js:

    exports.config = {
    // Do not start a Selenium Standalone sever - only run this using chrome.
    //chromeOnly: true,
    //chromeDriver: '../node_modules/protractor/selenium/chromedriver',

    //we are using a standalone selenium server so give it the local address
    //seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
    seleniumServerJar: './selenium-server-standalone-2.42.2.jar',

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'phantomjs'
    },

    baseUrl: 'http://localhost:8000',

    onPrepare: function () {
        require('jasmine-reporters');
        var capsPromise = browser.getCapabilities();
        capsPromise.then(function (caps) {
            var browserName = caps.caps_.browserName.toUpperCase();
            var browserVersion = caps.caps_.version;
            var prePendStr = browserName + '-' + browserVersion + '-';
            jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('test-results/protractor/', true, true, prePendStr));
        });
    },

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['test/protractor/**/*_spec.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        isVerbose: true,
        defaultTimeoutInterval: 30000
    },

    params: {
        env: 'test'
    }
};

Upvotes: 1

Views: 4991

Answers (1)

Lusk116
Lusk116

Reputation: 1050

192.168.0.20 is your local ip address and the port should be 4444 by default, you can change the port with

    seleniumPort: 1234

inside your protractor_conf.js (btw: protractor.conf.js is the default config file name for protractor)

Upvotes: 2

Related Questions