无法直接将量角器与 chromedriver 和 selenium 服务器一起使用 [英] Unable to use protractor with chromedriver and selenium server directly

查看:65
本文介绍了无法直接将量角器与 chromedriver 和 selenium 服务器一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我更新了我的 protractorwebdriver-managerchromedriverselenium-server.

Recently I updated my protractor, webdriver-manager, chromedriver, selenium-server.

之后我遇到了这个问题:以前我们在 github 中共享了一个量角器应用程序,其中包含 chromedriverselenium-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.

我们的量角器配置文件中没有 seleniumAddressdirectConnect.这意味着我们使用本地驱动程序启动了测试.

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.我将提供 localdirectConnect 的两个示例,因为它们很相似:

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 中,如果您提供 chromeDriverseleniumServerJar 在您的配置文件中.如果 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'
  }
}

这篇关于无法直接将量角器与 chromedriver 和 selenium 服务器一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆