0

Protractor doesn't start, it doesn't even open chrome. it just gives me this error ENOTFOUND localhost localhost:4444 even though I've started webdriver-manager and I can access localhost:4444 in the browser. I'm not sure what to do with this, I've tried reinstalling Chrome, updating protractor & webdriver-manager, upgrading Node.js, flushed my DNS but I'm still having the error.

Error:

[11:11:21] I/launcher - Running 1 instances of WebDriver
[11:11:21] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:11:26] E/launcher - ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
[11:11:26] E/launcher - Error: ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
  at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:238:15)
  at emitOne (events.js:115:13)
  at ClientRequest.emit (events.js:210:7)
  at Socket.socketErrorListener (_http_client.js:400:9)
  at emitOne (events.js:115:13)
  at Socket.emit (events.js:210:7)
  at emitErrorNT (internal/streams/destroy.js:62:8)
  at _combinedTickCallback (internal/process/next_tick.js:102:11)
  at process._tickCallback (internal/process/next_tick.js:161:9)
From: Task: WebDriver.createSession()
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:709:29)
  at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:167:33)
  at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:623:16)
  at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
  at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
  at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
  at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
  at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
  at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
  at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
  at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
  at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:125:13)
  at _combinedTickCallback (internal/process/next_tick.js:95:7)
  at process._tickCallback (internal/process/next_tick.js:161:9)
  at Function.Module.runMain (module.js:607:11)
  at startup (bootstrap_node.js:158:16)
  at bootstrap_node.js:575:3

This is the log provided by NPM:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.1.3/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'tests' ]
2 info using npm@5.0.4
3 info using node@v8.1.3
4 verbose run-script [ 'pretests', 'tests', 'posttests' ]
5 info lifecycle angular-app@1.0.1~pretests: angular-app@1.0.1
6 silly lifecycle angular-app@1.0.1~pretests: no script for pretests, continuing
7 info lifecycle angular-app@1.0.1~tests: angular-app@1.0.1
8 verbose lifecycle angular-app@1.0.1~tests: unsafe-perm in lifecycle true
9 verbose lifecycle angular-app@1.0.1~tests: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ChrisVillaran/Documents/Projects/angular-app/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tools:/platform-tools:/Users/ChrisVillaran/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/google_appengine/:/usr/local/bin/closure-compiler.jar
10 verbose lifecycle angular-app@1.0.1~tests: CWD: /Users/ChrisVillaran/Documents/Projects/angular-app
11 silly lifecycle angular-app@1.0.1~tests: Args: [ '-c', 'protractor tests/config.js' ]
12 silly lifecycle angular-app@1.0.1~tests: Returned: code: 199  signal: null
13 info lifecycle angular-app@1.0.1~tests: Failed to exec tests script
14 verbose stack Error: angular-app@1.0.1 tests: `protractor tests/config.js`
14 verbose stack Exit status 199
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at EventEmitter.emit (events.js:213:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at ChildProcess.emit (events.js:213:7)
14 verbose stack     at maybeClose (internal/child_process.js:897:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid angular-app@1.0.1
16 verbose cwd /Users/ChrisVillaran/Documents/Projects/angular-app
17 verbose Darwin 14.5.0
18 verbose argv "/usr/local/Cellar/node/8.1.3/bin/node" "/usr/local/bin/npm" "run" "tests"
19 verbose node v8.1.3
20 verbose npm  v5.0.4
21 error code ELIFECYCLE
22 error errno 199
23 error angular-app@1.0.1 tests: `protractor tests/config.js`
23 error Exit status 199
24 error Failed at the angular-app@1.0.1 tests script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 199, true ]

Selenium logs:

[14:57:32] I/start - java -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30 -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.17.0 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar -port 4444
[14:57:32] I/start - seleniumProcess.pid: 10704
14:57:33.378 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
14:57:33.379 INFO - Launching a standalone Selenium Server
2017-07-03 14:57:33.443:INFO::main: Logging initialized @590ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:57:34.065 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
  registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
  registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.065 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
14:57:34.066 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.066 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
2017-07-03 14:57:34.188:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-07-03 14:57:34.256:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@14acaea5{/,null,AVAILABLE}
2017-07-03 14:57:34.321:INFO:osjs.AbstractConnector:main: Started ServerConnector@3bb3f24f{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-07-03 14:57:34.322:INFO:osjs.Server:main: Started @1470ms
14:57:34.322 INFO - Selenium Server is up and running

Additional info:

Machine: OS X 10.10.5
Google Chrome: 59.0.3071.115
Node: 8.1.3
NPM: 5.0.4
Protractor: 5.1.2
Webdriver Manager: 12.0.6

My config:

let SpecReporter = require('jasmine-spec-reporter').SpecReporter;

exports.config = {
  allScriptsTimeout: 1000 * 2500,
  capabilities: {
    'browserName': 'chrome'
  },
  onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter({
      spec: {
        displayStacktrace: true
      }
    }));
  },
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [
    'tests/specs/login-view/login.js'
  ],
  jasmineNodeOpts: {
    defaultTimeoutInterval: 1000 * 2500,
    print: function() {}
  }
};
CRIS
  • 335
  • 3
  • 17

3 Answers3

2

Given that you're using OSX, you may be missing the line

127.0.0.1 localhost 

from /etc/hosts

M. Hudson
  • 889
  • 5
  • 11
  • nice it worked, thanks. can you give me an explanation or a link for it (for educational purposes) – CRIS Jul 03 '17 at 10:21
  • The etc/hosts file associates IP addresses with hostnames - localhost is a hostname which the etc/hosts file redirects to 127.0.0.1 (the loopback address of the local machine). Some applications make the logical deduction that if localhost isn't specified, default to redirecting to 127.0.0.1 but protractor isn't one of them and needs the address to be in the hosts file to work. – M. Hudson Jul 03 '17 at 10:33
0

Try commenting the selenium address, as bellow. It should work.

//seleniumAddress: 'http://localhost:4444/wd/hub',
sdet.ro
  • 317
  • 3
  • 12
0

Comment below lines it works fine

exports.config = {
    // seleniumAddress: 'http://chrome:4444/wd/hub',

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

    specs: ['Protractor/todo-spec.js']
};
juanlumn
  • 6,155
  • 2
  • 30
  • 39