Connection reset by peer when doing getText() on ElementArrayFinder when SELENIUM_PROMISE_MANAGER is false
Test execution interrupts on attempt to run .getText() on ElementArrayFinder Following error is displayed on attempt to run test with selenium server option:
✖ Given I execute socketException test # src/asyncAwaitProtractor.js:182 WebDriverError: java.net.SocketException: Connection reset by peer (connect failed)
And this, in case of direct connection:
✖ Given I execute socketException test # src/asyncAwaitProtractor.js:182 Error: EPIPE write EPIPE
The issue is not reproducing on Firefox.
- Node Version:
8.9.4 - Protractor Version:
5.3.0 - Angular Version:
1.5.7 - Browser(s):
chrome - Operating System and Version
Mac OSX
config file
const config = {
SELENIUM_PROMISE_MANAGER: false,
baseUrl: "http://www.protractortest.org/#/",
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
browserName: 'chrome',
shardTestFiles: false,
maxInstances: 1
},
specs: [
'./features/*.feature'
],
ignoreUncaughtExceptions: true,
disableChecks: true,
framework: 'custom',
frameworkPath: './node_modules/protractor-cucumber-framework',
restartBrowserBetweenTests: true,
cucumberOpts: {
require: './src/*.js',
strict: true,
format: 'json:results.json',
defaultTimeoutInterval: 160000,
tags: "@socketException"
},
onPrepare: onPrepare,
onComplete: onComplete
};
async function onPrepare() {
const {Given, Then, When} = require('cucumber');
global.Given = Given;
global.When = When;
global.Then = Then;
}
async function onComplete() {
console.log("suite tests complete --> ");
}
exports.config = Object.assign({}, config);
package.json
{
"name": "socketException",
"version": "1.1.0",
"dependencies": {
"protractor": "5.3.0",
"protractor-cucumber-framework": "4.2.0"
},
"devDependencies": {
"cucumber": "4.0.0"
}
}
test example
Given("I execute socketException test", async function () {
let btnsList = () => {return $$("h2")};
await browser.get(browser.baseUrl);
console.log(await btnsList().getText());
console.log(await btnsList().getText());
console.log(await btnsList().getText());
console.log(await btnsList().getText());
console.log(await btnsList().getText());
});
any intention for this to be fixed soon, guys? seems this error occurs even when more than one element found by $, and first one is used by default. In case like this it's really hard to tell where the error is, which makes migration to async/await more than painful.
Seeing the same error, posted about it here: https://github.com/angular/protractor/issues/4733#issuecomment-394940484
Thanks for any help!
- Could you @pumbox explain for what reason you user arrow function for finding
ElementArrayFinder? You can just writhconst btnsList = $$("h2"); - I really don't understand what do you expect when try to
.getText()fromElementArrayFinder. If you want take text from each element you could:
await btnsList.map(async (button) => {
console.log(await button.getText());
});
@CrispusDH The documentation states that:
You can treat an ElementArrayFinder as an array of WebElements for most purposes, in particular, you may perform actions (i.e. click, getText) on them as you would an array of WebElements. The action will apply to every element identified by the ElementArrayFinder.
And, by the way, your solution also throws the same error.
I just solved my issue not using $$("h2") and using ((element.all(by.css('.h2'))[0]).getText()
Looks like it try to get the text of all occurrences.
Maybe it will help you.
I am also getting the same error selenium standalone version : 3.14.0 protractor version : 5.4.1
Any update on this? I've been having the same error, and I'm not sure at all what's causing it. Do we understand what the actual problem is or do we have a workaround for the time being?