似乎反应页面没有在phantomjs env中呈现,但它在chrome env中有效。
检查' selenium-debug.log'文件,我发现信息如下:
18:20:27.889 INFO - Done: [new session: Capabilities [{applicationCacheEnabled=true, rotatable=true, phantomjs.page.setting.userAgent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36, phantomjs.cli.args=[--debug=true], databaseEnabled=true, platform=ANY, browserConnectionEnabled=true, nativeEvents=true, acceptSslCerts=true, phantomjs.binary.path=C:\Work\CGC\IAM\source\example-portal\front-end\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe, locationContextEnabled=true, webStorageEnabled=true, name=Components\ Login Component Spec, browserName=phantomjs, javascriptEnabled=true}]]
18:20:27.949 INFO - Executing: [get: http://localhost:8080/])
[ERROR - 2017-02-16T10:20:28.407Z] Session [896dad20-f431-11e6-be45-67612b4b3938] - page.onError - msg: TypeError: undefined is not a constructor (evaluating 'Object.assign({},{userReducer:i.default,routing:n.routerReducer})')
phantomjs://platform/console++.js:263 in error
[ERROR - 2017-02-16T10:20:28.407Z] Session [896dad20-f431-11e6-be45-67612b4b3938] - page.onError - stack:
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:28)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:28)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:28)
r (http://localhost:8080/vendor-c71287b53febd6a0d94c.js:1)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:29)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:29)
r (http://localhost:8080/vendor-c71287b53febd6a0d94c.js:1)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:40)
(anonymous function) (http://localhost:8080/app-c71287b53febd6a0d94c.js:40)
r (http://localhost:8080/vendor-c71287b53febd6a0d94c.js:1)
webpackJsonp (http://localhost:8080/vendor-c71287b53febd6a0d94c.js:1)
phantomjs://platform/console++.js:263 in error
18:20:28.428 INFO - Done: [get: http://localhost:8080/]
my nightwatch.config.js
{
'src_folders': ['test/e2e/specs'],
'output_folder': 'test/e2e/reports',
'custom_commands_path': ['node_modules/nightwatch-helpers/commands'],
'custom_assertions_path': ['node_modules/nightwatch-helpers/assertions'],
'selenium': {
'start_process': true,
'server_path': require('selenium-server').path,
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': require('chromedriver').path,
}
},
'test_settings': {
'default': {
'launch_url' : 'http://localhost:8080',
'selenium_port': 4444,
'selenium_host': 'localhost',
'silent': true,
'screenshots': {
'enabled': true,
'on_failure': true,
'on_error': false,
'path': 'test/e2e/screenshots'
}
},
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
'chromeOptions' : {
'args' : ['--none']
}
}
},
'firefox': {
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true,
'marionette': true
}
},
'phantomjs': {
'desiredCapabilities': {
'browserName': 'phantomjs',
'javascriptEnabled': true,
'acceptSslCerts': true,
'databaseEnabled': true,
'locationContextEnabled': true,
'applicationCacheEnabled': true,
'browserConnectionEnabled': true,
'webStorageEnabled': true,
'rotatable': true,
'nativeEvents': true,
"phantomjs.cli.args" : ['--debug=true'],
'phantomjs.binary.path' : require('phantomjs-prebuilt').path,
'phantomjs.page.setting.userAgent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'
}
}
}
}