无法直接将量角器与 chromedriver 和 selenium 服务器一起使用
最近我更新了我的 protractor
、webdriver-manager
、chromedriver
、selenium-server
.
Recently I updated my protractor
, webdriver-manager
, chromedriver
, selenium-server
.
之后我遇到了这个问题:以前我们在 github 中共享了一个量角器应用程序,其中包含 chromedriver
和 selenium-server
.这样我项目中的其他人下载这个git项目后就可以直接使用了.
After that I faced this problem: formerly we shared one protractor application in github with chromedriver
and selenium-server
in it. So others in my project can use it directly after downloaded this git project.
我们的量角器配置文件中没有 seleniumAddress
和 directConnect
.这意味着我们使用本地驱动程序启动了测试.
We don't have seleniumAddress
and directConnect
in our protractor configuration file. It means we launched tests with local driver.
但是现在添加了update-config.json
文件来跟踪chromedriver和selenium-server版本,其中的路径都是绝对路径.下载后需要修改路径.
But now update-config.json
file was added to track chromedriver and selenium-server version and the paths in it were all absolute paths. We need to changed the paths after downloaded it.
那么我们如何在没有 update-config.json
文件的情况下使用本地驱动程序?
So how can we use local driver without update-config.json
file?
在这个 答案.好消息是,如果您愿意,您可以避免使用 update-config.json
.我将提供 local
和 directConnect
的两个示例,因为它们很相似:
There is a long explanation of how Protractor uses the update-config.json
in this answer. The good news is you could avoid the update-config.json
if you want to. I'll provide both examples for the local
and directConnect
since these are similar:
在 lib/driverProviders/local.ts
中,如果您提供 chromeDriver
和 seleniumServerJar
在您的配置文件中.如果 Protractor 找不到它们,它将抛出 BrowserError
.
In lib/driverProviders/local.ts
, the update-config.json
could be avoided if you provide the paths to chromeDriver
and the seleniumServerJar
in your config file. If Protractor cannot find them, it will throw a BrowserError
.
所以你的配置文件看起来像:
So your configuration file would look something like:
exports.config = {
// launch locally when fields directConnect and seleniumAddress are not provided
chromeDriver: '/path/to/chromedriver',
seleniumServerJar: '/path/to/seleniumStandaloneServer.jar',
specs: [ '/some/test.js' ],
capabilities: {
browserName: 'chrome'
}
}
没有 update-config.json 的直接连接
同样,如果您提供chromeDriver
路径,当在你的配置中使用 directConnect
时,你可以避免使用 update-config.json
.配置文件将类似于:
directConnect without update-config.json
Similarly, if you provide the chromeDriver
path when using directConnect
in your config, you could avoid using the update-config.json
. The configuration file will look something like:
exports.config = {
directConnect: true,
chromeDriver: '/path/to/chromedriver',
specs: [ '/some/test.js' ],
capabilities: {
browserName: 'chrome'
}
}