我跟着这个SO post
设置我的Gruntfile
。如果我手动下载Selenium standalone并在文件中指定了它的位置,我的测试运行成功。由于我想自动执行此过程,我尝试了以下配置:
protractor_webdriver: {
start: {
options: {
path: 'node_modules/grunt-protractor-runner/node_modules/protractor/bin/',
command: 'webdriver-manager start'
}
}
};
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('test', ['protractor_webdriver:start','protractor:run'])
有没有办法避免手动下载?我试过上面但是当我跑了它时,我得到了警告:
Running "protractor_webdriver:start" (protractor_webdriver) task
Verifying property protractor_webdriver.start exists in config...OK
File: [no files]
Options: path="node_modules/grunt-protractor-runner/node_modules/protractor/bin/", command="webdriver-manager start", keepAlive=false
Starting Selenium server
>> Selenium Standalone is not present. Install with webdriver-manager update --standalone
所以我还需要手动下载selenium独立服务器吗? 或许我错过了一些配置?
答案 0 :(得分:1)
Protractor是WebDriverJS的包装器。
这是一个nodejs
程序,可与Selenium Server和特定浏览器驱动程序(例如ChromeDriver
,IEDriver
)进行交互。
因此,如果不使用selenium服务器(至少对于IE),则无法运行使用量角器编写的测试。测试脚本将命令发送到Selenium Server,然后Selenium Server与浏览器驱动程序进行通信。有关体系结构的说明,请参阅this。
简而言之,如果事先未启动Selenium服务器实例,则不会发生任何事情。
答案 1 :(得分:1)
您可以通过指定
来运行没有Selenium的ProtractordirectConnect: true
在各自的量角器配置文件中(例如protractor.conf.js
)。