protractor: Moving to async/await while keeping filter raises 'Connection refused: connect' and 'ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444'
Bug report
- Node Version:
v8.5.0
- Protractor Version:
5.1.0
- Angular Version:
1.6.7
- Browser(s):
Chrome 64.0.3282.140
- Operating System and Version
Windows 7
While trying to move away from the promise manager of Selenium, I encountered new random failures which were not occurring before. After analyze it appeared that it might be linked to the filter
function offered by Protractor.
Here is an extract of the configuration and scripts I am using. All the code is available on https://github.com/dubzzz/protractor-move-async-await. The localhost:3000 exposes the todolist example of AngularJS official website with a list of a thousand entries.
Using the promise manager:
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js'],
SELENIUM_PROMISE_MANAGER: 1
};
todo-spec.js
browser.get('http://localhost:3000/index.html');
element.all(by.repeater('todo in todoList.todos'))
.filter(todo => todo.getText().then(label => label.indexOf('#10') !== -1))
.each(todo => todo.element(by.css('input')).click());
Using async/await:
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js'],
SELENIUM_PROMISE_MANAGER: 0
};
todo-spec.js
await browser.get('http://localhost:3000/index.html');
await element(by.model('todoList.todoText')).sendKeys('write first protractor test');
await element(by.css('[value="add"]')).click();
await element.all(by.repeater('todo in todoList.todos'))
.filter(todo => todo.getText().then(label => label.indexOf('#10') !== -1))
.each(todo => todo.element(by.css('input')).click());
The asynchronous version failed with the following error:
1) [async] angularjs homepage todo list should add a todo
Message:
Failed: java.net.ConnectException: Connection refused: connect
The full proof off concept is available on my personal Github at https://github.com/dubzzz/protractor-move-async-await
Is the bug coming from an issue in my configuration or is there a real issue?
Thanks in advance
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 7
- Comments: 20 (3 by maintainers)
Also you can try my another patch for chromeDriver persistence connection issue. I don’t have problem for a while after apply both patch
You could override
filter
function to force send requests sequential.use this method to wrap
filterFn
.Second option is to run your tests directly on chrome (add to config
directConnect: true
). In that way selenium server will not use at all, so any java errors 😃That is an issue in selenium-webdriver. Here is my patch to resolve it (only work in protractor/selenium-webdriver 3.6.0)
Hi, @dubzzz ! I investigated this issue. Please take a look at my pull request https://github.com/dubzzz/protractor-move-async-await/pull/1/files. On my mind, tests became more stable. I’ll investigate this deeper and then give you one more callback. Now for me it looks that problems are with usage of filter function.
@andredesousa no update and protractor is dying. My two patches worked very well in last few years.
You can copy my patches into a js file, for example,
scripts/postinstall.js
, then add following code block to yourpackage.json
@disophisis the 2nd patch just got merged few days ago. Don’t know when it will be released. No update for the first patch.