如何配置量角器 (JS) 以在 Microsoft Edge 中运行测试?

我想将我的 protractor.conf.js 设置为在 Edge 而不是 Chrome 中运行测试.设置这个

I want to set my protractor.conf.js to run tests in Edge instead of in Chrome. Setting this

capabilities: {
    'browserName': 'MicrosoftEdge'
}

导致 SessionNotCreatedError: Unable to create new service: EdgeDriverService 错误代码为 199.我从 Microsoft 的网站,但我不知道如何告诉 Protractor 在哪里可以找到该驱动程序.我尝试将它添加到我的用户路径、系统路径、量角器节点模块文件夹中的 selenium 文件夹,并给出 jvmArgs:seleniumArgs:['-Dwebdriver.edge.driver="<path-to-driver"'],但我仍然得到那个 SessionNotCreatedError.

results in SessionNotCreatedError: Unable to create new service: EdgeDriverService with an error code of 199. I downloaded the MicrosoftWebDriver.exe for the version of Edge that I have from Microsoft's website, but I can't figure out how to tell Protractor where to find that driver. I've tried adding it to my user path, my system path, the selenium folder in protractor's node modules folder, and giving a jvmArgs: or seleniumArgs: of ['-Dwebdriver.edge.driver="<path-to-driver"'], but I still get that SessionNotCreatedError.

我只编写纯 JavaScript,而不是 Java 或 C#,我希望将所有这些设置为 protractor.conf.js 文件中的属性,而不是在实际的测试文件中设置任何内容.我拥有最新版本的 Node,并且确保在运行 ng e2e 时关闭 Edge.我需要更改或添加什么到我的配置文件才能让它运行?

I'm only writing pure JavaScript, no Java or C#, and I want all of this to be set as attributes in the protractor.conf.js file, nothing set in the actual file of tests. I have the most recent version of Node, and I'm making sure to have Edge closed when running ng e2e. What do I need to change or add to my config file to get this to run?

从 这个 github 问题,我添加了 seleniumAddress: http://127.0.01:17556/ 到我的配置文件,但现在我收到 ECONNREFUSED 127.0.0.1:17556 错误,错误代码为 135.我从以下地址之一获得该地址关于该 github 问题的评论,但无论手动启动 Edge 驱动程序还是仅运行 ng e2e --config <path-to-config>,我都会收到相同的错误.

From this github issue, I added seleniumAddress: http://127.0.01:17556/ to my config file, but now I'm getting an ECONNREFUSED 127.0.0.1:17556 error with error code 135. I got that address from one of the comments on that github issue, but I get the same error regardless of starting the Edge driver manually or just running ng e2e --config <path-to-config>.

解决方案
seleniumAddress: 'http://localhost:4444/wd/hub' 添加到配置文件中.使用 webdriver-manager start --edge "MicrosoftWebDriver.exe" 手动运行边缘驱动程序,然后在另一个窗口中运行 ng e2e.非常感谢 HaC 提供的解决方案!

SOLUTION
Add seleniumAddress: 'http://localhost:4444/wd/hub' to the config file. Run the edge driver manually with webdriver-manager start --edge "<path-to-driver>MicrosoftWebDriver.exe", and then run ng e2e in another window. Thank you so much to HaC for this solution!

推荐答案

参考:https://github.com/angular/protractor/issues/2377

  1. 下载并安装 Edge 驱动
  2. 运行 webdriver-manager start --edge "C:path_to_the_driverMicrosoftWebDriver.exe" .默认情况下,这将在端口 4444 上启动您的 selenium 服务器,该端口应该对您开放.
  3. 在量角器配置文件中:添加 seleniumAddress: 'http://localhost:4444/wd/hub'
  1. Download and install Edge driver
  2. Run webdriver-manager start --edge "C:path_to_the_driverMicrosoftWebDriver.exe" . By default this will start your selenium server on port 4444 which should be open to you.
  3. In your protractor config file: add seleniumAddress: 'http://localhost:4444/wd/hub'

相关文章