运行 量角器 conf.js 时出现 ETIMEDOUT 错误
Getting ETIMEDOUT error when running protractor conf.js
我是量角器的初学者。我完成了 运行 量角器所需的安装。当尝试 运行 量角器文档中提到的示例脚本时,出现 ETIMEDOUT 错误。 url 指向 127.0.0.1:4444。同样的 url 也无法手动访问。但是当尝试 http://localhost:4444/wd/hub, page opens properly. I am not sure why the conf.js trying to access the 127.0.0.1:4444, even if i give the 'seleniumAddress' parameter to 'http://localhost:4444/wd/hub' 时。请帮我解决这个问题
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js']
};
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
为此您需要 2 个终端。
在第一个终端,运行下面的命令:
webdriver-manager 启动
这将为 node/client 创建一个服务器以访问(您在 seleniumAddress 中添加的)
在第二个终端中,运行 下面的命令:
量角器conf.js
这将使用在 http://localhost:4444/wd/hub.
创建的服务器启动您的脚本
本地主机与 127.0.0.1 相同。
我同意其他回复。 http://localhost:4444/wd/hub is the same as http://127.0.0.1:4444/wd/hub。通常这是在您的 /etc/hosts
文件中定义的。
因为我想你只是想 运行 你的 Protractor 测试,只要你用 webdriver-manager update
下载了二进制文件,你就可以选择以下两个选项之一:
- 设置
directConnect: true
(并删除 seleniumAddress
。这适用于没有 selenium 独立服务器的 chrome 或 firefox(版本 47*)。
- 一起删除
seleniumAddress
。 Protractor 将在测试前为您启动 selenium 独立服务器,然后在测试结束时将其拆除。
注意:为了使上述工作正常,webdriver-manager update
应该从项目目录 运行 将二进制文件下载到正确的目录。 node node_modules/.bin/webdriver-manager update
或 ./node_modules/.bin/webdriver-manager update
之类的东西应该将驱动程序二进制文件下载到 node_modules/protractor/node_modules/webdriver-manager/selenium
.
- 所以为什么Firefox 47,目前不支持较新的版本。我们目前正在测试 Firefox 48+,但仍有一些未解决的问题。
如果 localhost 与 127.0.0.1 不同,则听起来您的主机文件已被使用或出现了一些更邪恶的网络问题。我认为我们没有足够的信息来正确调试您遇到此问题的原因,但我想提出一个解决方法。为什么不使用您实际的本地内部 IPv4 地址?
要获取 Windows 中的 IPv4 地址列表,请输入
ipconfig | findstr /R /C:"IPv4 Address"
要获取 Linux 中的 IPv4 地址列表,请输入
hostname -i
获取 Mac 类型的 IPv4 地址
ifconfig |grep inet
mac 上的地址应位于 inet 和网络掩码之间的最后一行
你的配置文件在
之后应该看起来像这样
exports.config = {
seleniumAddress: 'http://192.138.0.100:4444/wd/hub',
specs: ['todo-spec.js']
};
我是量角器的初学者。我完成了 运行 量角器所需的安装。当尝试 运行 量角器文档中提到的示例脚本时,出现 ETIMEDOUT 错误。 url 指向 127.0.0.1:4444。同样的 url 也无法手动访问。但是当尝试 http://localhost:4444/wd/hub, page opens properly. I am not sure why the conf.js trying to access the 127.0.0.1:4444, even if i give the 'seleniumAddress' parameter to 'http://localhost:4444/wd/hub' 时。请帮我解决这个问题
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js']
};
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
为此您需要 2 个终端。
在第一个终端,运行下面的命令: webdriver-manager 启动 这将为 node/client 创建一个服务器以访问(您在 seleniumAddress 中添加的)
在第二个终端中,运行 下面的命令: 量角器conf.js 这将使用在 http://localhost:4444/wd/hub.
创建的服务器启动您的脚本
本地主机与 127.0.0.1 相同。
我同意其他回复。 http://localhost:4444/wd/hub is the same as http://127.0.0.1:4444/wd/hub。通常这是在您的 /etc/hosts
文件中定义的。
因为我想你只是想 运行 你的 Protractor 测试,只要你用 webdriver-manager update
下载了二进制文件,你就可以选择以下两个选项之一:
- 设置
directConnect: true
(并删除seleniumAddress
。这适用于没有 selenium 独立服务器的 chrome 或 firefox(版本 47*)。 - 一起删除
seleniumAddress
。 Protractor 将在测试前为您启动 selenium 独立服务器,然后在测试结束时将其拆除。
注意:为了使上述工作正常,webdriver-manager update
应该从项目目录 运行 将二进制文件下载到正确的目录。 node node_modules/.bin/webdriver-manager update
或 ./node_modules/.bin/webdriver-manager update
之类的东西应该将驱动程序二进制文件下载到 node_modules/protractor/node_modules/webdriver-manager/selenium
.
- 所以为什么Firefox 47,目前不支持较新的版本。我们目前正在测试 Firefox 48+,但仍有一些未解决的问题。
如果 localhost 与 127.0.0.1 不同,则听起来您的主机文件已被使用或出现了一些更邪恶的网络问题。我认为我们没有足够的信息来正确调试您遇到此问题的原因,但我想提出一个解决方法。为什么不使用您实际的本地内部 IPv4 地址?
要获取 Windows 中的 IPv4 地址列表,请输入
ipconfig | findstr /R /C:"IPv4 Address"
要获取 Linux 中的 IPv4 地址列表,请输入
hostname -i
获取 Mac 类型的 IPv4 地址
ifconfig |grep inet
mac 上的地址应位于 inet 和网络掩码之间的最后一行
你的配置文件在
之后应该看起来像这样exports.config = {
seleniumAddress: 'http://192.138.0.100:4444/wd/hub',
specs: ['todo-spec.js']
};