无法使用phantomjs和nightwatch.js从org.openqa.selenium.remote.NewSessionPayload创建会话

时间:2018-07-10 07:25:50

标签: node.js phantomjs nightwatch.js cucumberjs

我正在尝试在Nightwatchjs中通过Phantom JS执行测试  我正在将硒服务器与Nightwatchjs和黄瓜一起使用 我将以下链接作为参考- https://github.com/nightwatchjs/nightwatch/wiki/Running-tests-in-PhantomJS

还有其他答案,但没有一个与我的匹配。这可能是配置问题,但我无法解决。有人可以帮我吗?

错误:

NFO Request: POST /wd/hub/session
 - data:  {"desiredCapabilities":{"browserName":"phantomjs","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","phantomjs.binary.path":"/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs","phantomjs.cli.args":["--ignore-ssl-errors=true"],"silent":false}}
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":270}
ERROR Response 500 POST /wd/hub/session (482ms) { value:
   { message: 'Unable to create session from org.openqa.selenium.remote.NewSessionPayload@5c510db\nBuild info: version: \'3.12.0\', revision: \'7c6e0b3\', time: \'2018-05-08T15:15:08.936Z\'\nSystem info: host: \'Chirags-MacBook-Pro.local\', ip: \'fe80:0:0:0:142a:4efe:d208:27ae%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.5\', java.version: \'1.8.0_171\'\nDriver info: driver.version: unknown',
     error: 'session not created' },
  status: 33 }
{ Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at ClientManager.emit (events.js:171:17)
    at Nightwatch.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/runner/clientmanager.js:68:10)
    at Object.onceWrapper (events.js:273:13)
    at Nightwatch.emit (events.js:182:13)
    at HttpRequest.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/index.js:501:10)
    at HttpRequest.emit (events.js:182:13)
    at IncomingMessage.<anonymous> (/Users/prateik/Codebase/NightCuke/node_modules/nightwatch/lib/http/request.js:172:16)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1086:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  context:
   { message: 'Connection refused! Is selenium server started?\n',
     data: { value: [Object], status: 33 } } }

它说 driver.version:unknown ,这可能是问题吗?

所有组件均为最新版本

"cucumber": "^4.0.0",
"nightwatch": "^0.9.21",
"nightwatch-cucumber": "^9.1.2",
"phantomjs-prebuilt": "^2.1.16",
"selenium-server": "^3.12.0"

nightwatch.conf.js

    //Nightwatch Configuration

const seleniumServer = require('selenium-server')
const phantomjs = require('phantomjs-prebuilt')
const chromedriver = require('chromedriver')
const geckodriver = require('geckodriver')

require('nightwatch-cucumber')({
    cucumberArgs: [
        '--require-module', 'babel-core/register',
        '--format', 'node_modules/cucumber-pretty',
        '--require', 'hooks.js',
        '--require', 'features/step_definitions',
        '--format-options', '{"colorsEnabled":false}',


  '--format', 'json:reports/cucumber.json',
    'features'
],
nightwatchOutput: true
})

module.exports = {
    // src_folders:'features',
    output_folder: 'reports',
    custom_assertions_path: '',
    page_objects_path: 'page_objects/',
    live_output: true,
    disable_colors: false,

selenium: {
    start_process: true,
    server_path: seleniumServer.path,
    log_path: '/reports',
    host: '127.0.0.1',
    port: 4444,
    cli_args: {
        'webdriver.chrome.driver': chromedriver.path,
        'webdriver.gecko.driver' : geckodriver.path,
        "webdriver.edge.driver" : "",

    }
},
test_settings: {
    default: {
        launch_url: 'http://localhost',
        selenium_port: 4444,
        selenium_host: '127.0.0.1',
        desiredCapabilities: {
            browserName: 'chrome',
            javascriptEnabled: true,
            acceptSslCerts: true,
            silent:false
            //chromeOptions:['start-fullscreen']

        },

        selenium: {},
        screenshots: {
            enabled: true,
            on_failure: true,
            path: 'screenshots'
        }

    },
    phantomjs: {
        //launch_url: 'http://localhost/',
        selenium_port: 4444,
        selenium_host: '127.0.0.1',
        desiredCapabilities: {
            browserName: 'phantomjs',
            javascriptEnabled: true,
            acceptSslCerts: true,
            //platform: 'Mac OS X',
            "phantomjs.binary.path": phantomjs.path,
            "phantomjs.cli.args" : ['--ignore-ssl-errors=true']
        },

    },
    firefox: {
        desiredCapabilities: {
            browserName: 'firefox',
            javascriptEnabled: true,
            acceptSslCerts: true
        }
    }
}

}

0 个答案:

没有答案