protractor icon indicating copy to clipboard operation
protractor copied to clipboard

TypeError: Cannot call method 'forEach' of null Error

Open wzup opened this issue 12 years ago • 17 comments

I'm getting this error when call protractor tests\protractor-conf.js. What is this? How to fix it, how to make Protractor to run my tests?

C:\www\app.foo>protractor tests\protractor-conf.js
Using ChromeDriver directly...

C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\net\index.js:48
    interfaces[key].forEach(function(ipAddress) {
                    ^
TypeError: Cannot call method 'forEach' of null
    at getAddress (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\net\index.js:48:21)
    at Object.exports.getLoopbackAddress (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\net\index.js:78:10)
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:186:17
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1
531:20)
    at notify (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:354:12)
    at then (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:406:7)
    at Object.webdriver.promise.when (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:631:18)
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\remote\index.js:172:20
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
==== async task ====
WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js
:131:49)
    at Function.webdriver.WebDriver.createSession (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:1
11:30)
    at Object.createDriver (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:460:30)
    at ChromeDriverProvider.getDriver (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\chrome.js:67:27)
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:207:35
    at _fulfilled (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
    at self.promiseDispatch.done (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
    at Promise.promise.promiseDispatch (C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
    at C:\Users\admin\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:525:49

wzup avatar Jun 05 '14 16:06 wzup

I'm having the same issue with chrome only mode. If I run a standalone selenium server it runs fine. It worked with 0.23.1

Thanks, P

penfold avatar Jun 05 '14 18:06 penfold

How to run a standalone selenium server?

wzup avatar Jun 05 '14 19:06 wzup

The Getting Started instructions page explains - look at the webdriver-manager command in your Node command prompt. Then set the seleniumUrl in your config and set chromeOnly=false.

penfold avatar Jun 05 '14 21:06 penfold

Have you updated Chromedriver to 2.10?

juliemr avatar Jun 05 '14 22:06 juliemr

I doubled checked and I've got Chromedriver 2.10 and Selenium 2.42.0.

penfold avatar Jun 06 '14 07:06 penfold

@juliemr: I have: ChromeDriver 2.10.267521 selenium-server-standalone-2.42.0.jar

wzup avatar Jun 06 '14 08:06 wzup

@penfold: chromeOnly: false did the job. Thank you.

Here is my Protractor config file if someone is interested:

exports.config = {
  allScriptsTimeout: 11000,
  seleniumAddress: 'http://localhost:4444/wd/hub',
  chromeDriver: 'C:\\Users\\admin\\AppData\\Roaming\\npm\\node_modules\\protractor\\selenium',

 chromeOnly: false,  <-- this option was "true"

  specs: [
    'e2e/spec/*Suit.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:3000/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

wzup avatar Jun 06 '14 08:06 wzup

Can you post the config that broke?

hankduan avatar Jun 08 '14 22:06 hankduan

I have the same issue. It works fine in my local mac machine, but this error happen on a windows CI server. Both chromedriver 2.10 and 2.9 have the same issue.

GrapeBaBa avatar Jun 09 '14 13:06 GrapeBaBa

Maybe an issue with selenium-webdriver 2.42.0 on windows?

juliemr avatar Jun 09 '14 22:06 juliemr

Looking at the recent changes to the selenium-webdriver. There looks to be a possible fix that will appear in the next release (after 2.42.2).

See https://code.google.com/p/selenium/source/detail?r=9779366828b293420f1950bf3fd2e768fbb365b5

penfold avatar Jun 13 '14 20:06 penfold

selenium-webdriver is intentionally only looking at darwin and linux systems to find the local loopback address (typically 127.0.0.1). So it's not working on windows. To run the angular-phonecat project, I had to edit angular-phonecat\node_modules\protractor\node_modules\selenium-webdriver\net\index.js to make getAddress(loopback, opt_family) simply return "127.0.0.1" (all other logic removed) to work around this issue.

JeffreyVest avatar Jun 22 '14 06:06 JeffreyVest

@penfold @wzup thank you both of you, the solution is indeed starting a standalone selenium server and configuring the protractor-conf.js file. I managed to run protractor too this way. Thanks again.

avadolas avatar Jun 23 '14 17:06 avadolas

@penfold @JeffreyVest Editing the index.js file as per https://code.google.com/p/selenium/source/detail?r=9779366828b293420f1950bf3fd2e768fbb365b5 was the only thing that worked for me(Win 8.1)

dimumurray avatar Jun 29 '14 14:06 dimumurray

changing chromeOnly from true to false (chromeOnly: false) in protractor config file did it for me (win7 os) thnx @wzup @penfold

nexus6nexus6 avatar Jun 29 '14 15:06 nexus6nexus6

chromeOny didn't work for me, I solved the issue by updating the version of protractor and karma in the package.json to the latest versions and explicitly add karma-jasmine dependancy

I solved the issue by updating the version of protractor and karma in the package.json to the latest versions and explicitly add karma-jasmine dependancy

documented it in the duplicate bug ticket here -> https://github.com/angular/angular-phonecat/issues/176

Anthony-Mckale avatar Jul 02 '14 08:07 Anthony-Mckale

It looks like these are all solved by updating to new version of selenium-webdriver. Closing, please open a new issue if you continue to see errors.

juliemr avatar Jul 22 '14 20:07 juliemr