gpt4 book ai didi

javascript - 如何配置 Protractor (JS) 以在 Microsoft Edge 中运行测试?

转载 作者:行者123 更新时间:2023-12-04 01:16:06 27 4
gpt4 key购买 nike

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

capabilities: {
'browserName': 'MicrosoftEdge'
}

结果 SessionNotCreatedError: Unable to create new service: EdgeDriverService错误代码为 199。我从 Microsoft's website 下载了适用于我拥有的 Edge 版本的 MicrosoftWebDriver.exe ,但我不知道如何告诉 Protractor 在哪里可以找到该驱动程序。我尝试将它添加到我的用户路径、系统路径、 Protractor 节点模块文件夹中的 selenium 文件夹中,并给出 jvmArgs:seleniumArgs:['-Dwebdriver.edge.driver="<path-to-driver"'] ,但我仍然得到那个 SessionNotCreatedError。

我只编写纯 JavaScript,没有 Java 或 C#,我希望所有这些都设置为 protractor.conf.js 文件中的属性,在实际的测试文件中没有设置。我有最新版本的 Node,我确保在运行 ng e2e 时关闭 Edge .我需要更改或添加到我的配置文件以使其运行?

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

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

最佳答案

引用:https://github.com/angular/protractor/issues/2377

  • 下载并安装 Edge 驱动程序
  • 运行webdriver-manager start --edge "C:\path_to_the_driver\MicrosoftWebDriver.exe" .默认情况下,这将在端口 4444 上启动您的 selenium 服务器,该端口应该对您开放。
  • 在 Protractor 配置文件中:添加 seleniumAddress: 'http://localhost:4444/wd/hub'
  • 关于javascript - 如何配置 Protractor (JS) 以在 Microsoft Edge 中运行测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47891742/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com