使用量角器设置PhantomJs不起作用
我从量角器、茉莉花和幻影开始我的冒险。我想要实现的是使用PhantomJS从GragratorDemo运行测试。但我失败了,我不知道为什么。具体步骤如下: 我已经安装了量角器演示() 然后我安装了phantomjs:使用量角器设置PhantomJs不起作用,phantomjs,protractor,Phantomjs,Protractor,我从量角器、茉莉花和幻影开始我的冒险。我想要实现的是使用PhantomJS从GragratorDemo运行测试。但我失败了,我不知道为什么。具体步骤如下: 我已经安装了量角器演示() 然后我安装了phantomjs: npm install --save-dev phantomjs 然后我更新了配置(基于): 完整配置文件如下所示: // Tests for the calculator. exports.config = { seleniumAddress: 'http://localh
npm install --save-dev phantomjs
然后我更新了配置(基于):
完整配置文件如下所示:
// Tests for the calculator. exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'spec.js' ],
capabilities: {
'browserName': 'phantomjs',
/*
* Can be used to specify the phantomjs binary path.
* This can generally be ommitted if you installed phantomjs globally.
*/
'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',
/*
* Command line arugments to pass to phantomjs.
* Can be ommitted if no arguments need to be passed.
* Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
*/
'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG'] } };
然后我执行了教程中的命令:
.\node_modules\.bin\webdriver-manager update
我已启动WebDriver和web服务器:
.\node_modules\.bin\webdriver-manager start
npm start
此命令的输出为:
Using the selenium server at http://127.0.0.1:4444/wd/hub
Server running at http://localhost:3456
最后一步:
node_modules\.bin\protractor test\conf.js
其他webdriver管理器控制台窗口的输出为:
15:23:10.181 INFO - Executing: [new session: Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}]])
15:23:10.192 INFO - Creating a new session for Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}]
15:23:10.203 INFO - executable: d:\dev\protractor-demo\.\node_modules\phantomjs\bin\phantomjs
15:23:10.203 INFO - port: 44410
15:23:10.203 INFO - arguments: [--logfile=PATH, --loglevel=DEBUG, --webdriver=44410, --webdriver-logfile=d:\dev\protractor-demo\phantomjsdriver.log]
15:23:10.204 INFO - environment: {}
但什么也没发生。我看不到执行测试的结果。有什么我遗漏的吗?当我将浏览器从phantomjs更改为chrome时,我会看到测试结果。事实上,您不需要运行:
.\node_modules\.bin\webdriver-manager update
也不是:
相反,您可以通过运行以下命令(9515将是驱动程序运行的端口)来启动ghost驱动程序:
phantomjs --webdriver=9515
node_modules\.bin\protractor test\conf.js
除此之外,您还应该修改配置文件,以便让量角器知道驱动程序将在哪里找到。对于您的情况,您的配置文件应该如下所示:
exports.config = {
seleniumAddress: 'http://localhost:9515',
specs: ['spec.js'],
capabilities: {
'browserName': 'phantomjs',
/*
* Can be used to specify the phantomjs binary path.
* This can generally be ommitted if you installed phantomjs globally.
*/
'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',
/*
* Command line arugments to pass to phantomjs.
* Can be ommitted if no arguments need to be passed.
* Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
*/
'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG']
}
};
然后,您可以通过运行以下命令来运行测试:
phantomjs --webdriver=9515
node_modules\.bin\protractor test\conf.js
看起来相关:谢谢。不管怎样,我的步骤正确吗?因为,后来我发现了一个示例,您可以简单地将PhantomJS作为远程WebDriver启动,当我使用seleniumAddress连接到这个驱动程序时,它是否正常工作。我很困惑。我不知道,从来没有做过。我们发现phantomjs比其他浏览器更脆弱。因此,我们转而使用chrome和firefox进行测试(甚至在我们的服务器上)。稍微慢一点,但更稳定。这个博客展示了解决方案
node_modules\.bin\protractor test\conf.js