我正在使用量角器(使用grunt-protractor-runner来运行我的E2E Angular测试),但我不能让PhantomJS自动启动.
我的量角器配置如下所示:
exports.config = { //seleniumAddress: "http://localhost:9515",specs: [ 'static_src/test/spec/*.js' ],capabilities: { 'browserName': 'phantomjs','phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs','phantomjs.cli.args':['--logfile=phantom.log','--loglevel=DEBUG'] } }
我的理解是,使用该配置,量角器将自动启动PhantomJS实例(在phantomjs.binary.path上找到),对其运行测试,使用WebDriver协议直接通信(因此不需要Selenium服务器),然后旋转在PhantomJS实例中.
鉴于,
解决方法
量角器始终需要Selenium独立服务器.您可以使用webdriver-manager启动它并引用protract.conf.js中的地址,或者您可以指定jar的位置,Protractor将为您启动它.
请参考配置中的jar,例如:
seleniumServerJar: 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.38.0.jar'
使用此方法,您不必担心启动selenium服务器,但速度稍慢.因此,如果您需要经常重新运行测试,则可以更快地独立于Protractor启动它.