Unable to use protractor with chromedriver and selenium server directly

三世轮回 提交于 2020-01-03 05:52:21

问题


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

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.

We don't have seleniumAddress and directConnect in our protractor configuration file. It means we launched tests with local driver.

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.

So how can we use local driver without update-config.json file?


回答1:


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:

local without update-config.json

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'
  }
}

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'
  }
}


来源:https://stackoverflow.com/questions/43581462/unable-to-use-protractor-with-chromedriver-and-selenium-server-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!