Tuesday, 19 March 2019

Selenium webdriver Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:9515

I'm using NodeJS selenium within my electron desktop application.

"electron-chromedriver": "^4.0.0-beta.1",
"selenium-webdriver": "^4.0.0-alpha.1",

I followed electron documentation about using selenium inside electron app and I have code like this:

let chromeCapabilities = webdriver.Capabilities.chrome();
let chromeOptions = { 'args': ['--disable-infobars'] };
chromeCapabilities.set('chromeOptions', chromeOptions);
capabilities.setPageLoadStrategy('eager');

this.driver = new webdriver.Builder()
    .withCapabilities(chromeCapabilities)
    .usingServer('http://localhost:9515')
    .forBrowser('chrome')
    .build();

after above code there is chain of promises which are doing many different things.

Except that I'm runing chromedriver command in terminal within ./node_modules/.bin/ directory.

Starting ChromeDriver 69.0.3497.106 (857b284701ddf7bef0f14fa76416cf7ca786b411) on port 9515
Only local connections are allowed.

Now when I run entire code it sometimes works correctly but occasionally it print error in terminal in which I npm run dev electron app:

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:9515

I read several similiar SO questions but none of them was helpful. I don't really understand how it's possible that some piece of code is sometimes working and sometimes causing error.

I also checked ports 9515 (chromedriver) and 9080 (electron nodeJS) after getting error and everything looks fine:

alt



from Selenium webdriver Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:9515

No comments:

Post a Comment