2017-03-17 57 views
0

MEAN JSスタックアプリでgruntテストを実行していますが、その原因を解決できないという問題が見つかりました。UnknownError:接続が拒否されました(接続が拒否されました)

webdriver-managerを単独で実行しています(webdriver-manager start)。うまくいきますが、grunt testタスクを実行しているとエラーが発生しているようです。

また、ポートが異なっていることに気付きました(4444ではありません)。これを変更する方法もわかりません。

Running "protractor:e2e" (protractor) task 
webdriver-manager path: /Users/valdy/Development/MeanJSApp/node_modules/protractor/bin/webdriver-manager 
selenium standalone is up to date. 
chromedriver is up to date. 
Starting selenium standalone server... 
[launcher] Running 1 instances of WebDriver 
Selenium standalone server started at http://192.168.0.115:64594/wd/hub 

/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108 
    var template = new Error(this.message); 
       ^
UnknownError: Connection refused (Connection refused) 
    at new bot.Error (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/error.js:108:18) 
    at Object.bot.response.checkResponse (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/atoms/response.js:109:9) 
    at /Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24 
    at promise.ControlFlow.runInFrame_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20) 
    at wrappedCtr.notify (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25) 
    at promise.Promise.notify_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12) 
    at Array.forEach (native) 
    at promise.Promise.notifyAll_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15) 
    at goog.async.run.processWorkQueue (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15) 
    at process._tickCallback (internal/process/next_tick.js:103:7) 
From: Task: WebDriver.createSession() 
    at Function.webdriver.WebDriver.acquireSession_ (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22) 
    at Function.webdriver.WebDriver.createSession (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30) 
    at Builder.build (/Users/valdy/Development/MeanJSApp/node_modules/selenium-webdriver/builder.js:445:22) 
    at LocalDriverProvider.DriverProvider.getNewDriver (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7) 
    at Runner.createBrowser (/Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:182:37) 
    at /Users/valdy/Development/MeanJSApp/node_modules/protractor/lib/runner.js:263:21 
    at _fulfilled (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:797:54) 
    at self.promiseDispatch.done (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:826:30) 
    at Promise.promise.promiseDispatch (/Users/valdy/Development/MeanJSApp/node_modules/q/q.js:759:13) 
    at /Users/valdy/Development/MeanJSApp/node_modules/q/q.js:573:44 
[launcher] Process exited with error code 1 
>> 
Warning: Tests failed, protractor exited with code: 1 Use --force to continue. 

Aborted due to warnings. 

これはtests.jsための設定(/config/assets/tests.js)されています

'use strict'; 

module.exports = { 
    tests: { 
    // client: ['modules/*/tests/client/**/*.js'], 
    client: ['modules/forum/tests/client/**/*.js'], 


    // server: ['modules/*/tests/server/**/*.js'], 
    server: ['modules/forum/tests/server/**/*.js'], 

    e2e: ['modules/*/tests/e2e/**/*.js'] 
    // e2e: ['modules/forum/tests/e2e/**/*.js'] 

    } 
}; 

私も/node_module/protractor/config.jsonの下で、その分度器のconfig.jsonを見つけましたが、この構成を有している:

{ 
    "webdriverVersions": { 
     "selenium": "2.47.1", 
     "chromedriver": "2.19", 
     "iedriver": "2.47.0" 
    } 
} 

そして、これウェブアプリケーションのルートにある自分のprotractor.config.jsです:

'use strict'; 

// Protractor configuration 
var config = { 
    specs: ['modules/*/tests/e2e/*.js'] 
}; 

if (process.env.TRAVIS) { 
    config.capabilities = { 
     browserName: 'firefox' 
    }; 
} 

exports.config = config; 

そしてここで分度器のNPM記述子(/node_module/protractor/package.json)である:ここでは

{ 
    "_args": [ 
     [ 
      { 
       "raw": "[email protected]", 
       "scope": null, 
       "escapedName": "Protractor", 
       "name": "Protractor", 
       "rawSpec": "2.5.1", 
       "spec": "2.5.1", 
       "type": "version" 
      }, 
      "/Users/valdy/Development/MeanJSApp" 
     ] 
    ], 
    "_from": "[email protected]", 
    "_id": "[email protected]", 
    "_inCache": true, 
    "_location": "/protractor", 
    "_nodeVersion": "0.12.7", 
    "_npmUser": { 
     "name": "angularcore", 
     "email": "[email protected]" 
    }, 
    "_npmVersion": "2.11.3", 
    "_phantomChildren": { 
     "boom": "2.10.1", 
     "chalk": "1.1.3", 
     "combined-stream": "1.0.5", 
     "core-util-is": "1.0.2", 
     "cryptiles": "2.0.5", 
     "ctype": "0.5.3", 
     "forever-agent": "0.6.1", 
     "graceful-readlink": "1.0.1", 
     "hoek": "2.16.3", 
     "inherits": "2.0.3", 
     "is-my-json-valid": "2.16.0", 
     "isstream": "0.1.2", 
     "json-stringify-safe": "5.0.1", 
     "lru-cache": "2.7.3", 
     "oauth-sign": "0.8.2", 
     "sigmund": "1.0.1", 
     "sntp": "1.0.9", 
     "string_decoder": "0.10.31", 
     "stringstream": "0.0.5", 
     "tough-cookie": "2.3.2" 
    }, 
    "_requested": { 
     "raw": "[email protected]", 
     "scope": null, 
     "escapedName": "Protractor", 
     "name": "Protractor", 
     "rawSpec": "2.5.1", 
     "spec": "2.5.1", 
     "type": "version" 
    }, 
    "_requiredBy": [ 
     "#USER", 
     "/grunt-protractor-runner", 
     "/gulp-protractor" 
    ], 
    "_resolved": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz", 
    "_shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd", 
    "_shrinkwrap": null, 
    "_spec": "[email protected]", 
    "_where": "/Users/valdy/Development/MeanJSApp", 
    "author": { 
     "name": "Julie Ralph", 
     "email": "[email protected]" 
    }, 
    "bin": { 
     "protractor": "bin/protractor", 
     "webdriver-manager": "bin/webdriver-manager" 
    }, 
    "bugs": { 
     "url": "https://github.com/angular/protractor/issues" 
    }, 
    "dependencies": { 
     "accessibility-developer-tools": "~2.6.0", 
     "adm-zip": "0.4.4", 
     "glob": "~3.2", 
     "html-entities": "~1.1.1", 
     "jasmine": "2.3.2", 
     "jasminewd": "1.1.0", 
     "jasminewd2": "0.0.6", 
     "lodash": "~2.4.1", 
     "minijasminenode": "1.1.1", 
     "optimist": "~0.6.0", 
     "q": "1.0.0", 
     "request": "~2.57.0", 
     "saucelabs": "~1.0.1", 
     "selenium-webdriver": "2.47.0", 
     "source-map-support": "~0.2.6" 
    }, 
    "description": "Webdriver E2E test wrapper for Angular.", 
    "devDependencies": { 
     "chai": "~3.3.0", 
     "chai-as-promised": "~5.1.0", 
     "cucumber": "~0.6.0", 
     "expect.js": "~0.2.0", 
     "express": "~3.3.4", 
     "jshint": "2.5.0", 
     "mocha": "2.3.3", 
     "rimraf": "~2.2.6" 
    }, 
    "directories": {}, 
    "dist": { 
     "shasum": "03d6c93cd7c268f4250177d55a2fec8a198372cd", 
     "tarball": "https://registry.npmjs.org/protractor/-/protractor-2.5.1.tgz" 
    }, 
    "gitHead": "645133d557f1059d9e885f2566fc4c29ce7c19cc", 
    "homepage": "https://github.com/angular/protractor", 
    "keywords": [ 
     "angular", 
     "test", 
     "testing", 
     "webdriver", 
     "webdriverjs", 
     "selenium" 
    ], 
    "license": "MIT", 
    "main": "lib/protractor.js", 
    "maintainers": [ 
     { 
      "name": "juliemr", 
      "email": "[email protected]" 
     }, 
     { 
      "name": "angularcore", 
      "email": "[email protected]" 
     } 
    ], 
    "name": "protractor", 
    "optionalDependencies": {}, 
    "readme": "ERROR: No README data found!", 
    "repository": { 
     "type": "git", 
     "url": "git://github.com/angular/protractor.git" 
    }, 
    "scripts": { 
     "pretest": "jshint lib spec scripts", 
     "start": "node testapp/scripts/web-server.js", 
     "test": "node scripts/test.js" 
    }, 
    "version": "2.5.1" 
} 
+0

設定ファイルを追加してください。 – cnishina

+0

@cnishina - 私はテスト設定のスニペットを追加しました。それはあなたが必要とする設定ですか? – dcpartners

+0

私は混乱しています。分度器の設定ファイルではありません。分度器5を使っていますか?分度器を包んでいるものを使用していますか? – cnishina

答えて

1

は何が起こっているの私の最高の推測です:

  1. あなたのIPアドレスを使用してセレンスタンドアロンサーバlocallyで起動していますこれは、seleniumAddress: "http://localhost:4444/wd/hub"またはdirectConnect: trueを選択しなかったことを意味します。私はこのように見えるコードスニペットを以下に示します。

  2. トラベラーではなくローカルで起動している場合、投機器はChrome browser by defaultで起動します。これは、ChromeDriverをダウンロードしたはずであることを意味します。

  3. 分度器2.5から最新のものにアップグレードする必要があります。分度器は、セレン - ウェブドライバ、スタンドアロンサーバー、ブラウザドライバ、ブラウザなど、スタック全体と強く結びついています。最新のブラウザと分度器2.5を使用している場合、おそらくwebdriver-managerがあなたのブラウザと互換性のない古いバイナリをダウンロードしたでしょう。ここで


コードスニペットです:

exports.config = { 
    // option 1. launches a selenium standalone server. this is helpful if 
    // you launch it with "webdriver-manager start" 
    // seleniumAddress: "http://localhost:4444/wd/hub", 
    // 
    // option 2. launch browser directly using browser binaries 
    // directConnect: true, 
    // 
    // option 3. do not include either seleniumAddress or directConnect 
    // and this option will launch the selenium standalone server using 
    // your ip address. 
    // 
    // option 4: launch with saucelabs or browserstack options 
} 

このファイルは、あなたが、あなたの設定を定義するだけでトラヴィスのための機能を設定し、設定をエクスポートし、この1つに関する。

'use strict'; 

// Protractor configuration 
var config = { 
    specs: ['modules/*/tests/e2e/*.js'] 
}; 

if (process.env.TRAVIS) { 
    config.capabilities = { 
    browserName: 'firefox' 
    }; 
} 

exports.config = config; 
+1

protractor.config.jsを編集し、別のコンソールで 'webdriver-manager start'を実行します。それはうまく動作します! var config = { seleniumAddress: 'http:// localhost:4444/wd/hub'、 仕様:['modules/*/tests/e2e/* .js'] }; – dcpartners

+0

Huzzah!良い点は、 'webdriver-manager start'を別のコンソールで実行する必要があることです。 – cnishina

関連する問題