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

2023-06-15前端开发问题
14

本文介绍了如何配置量角器 (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'

这篇关于如何配置量角器 (JS) 以在 Microsoft Edge 中运行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

JavaScript小数运算出现多位的解决办法
在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会...
2024-10-18 前端开发问题
301

JavaScript(js)文件字符串中丢失"\"斜线的解决方法
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转...
2024-10-17 前端开发问题
437

layui中table列表 增加属性 edit="date",不生效怎么办?
如果你想在 layui 的 table 列表中增加 edit=date 属性但不生效,可能是以下问题导致的: 1. 缺少日期组件的初始化 如果想在表格中使用日期组件,需要在页面中引入 layui 的日期组件,并初始化: script type="text/javascript" src="/layui/layui.js"/scrip...
2024-06-11 前端开发问题
455

Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)...
2024-04-20 前端开发问题
5

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13