TestProject Forum
Powered by leading experts in the test automation community

WebDriverException: java.net.ConnectException: Connection refused: connect

We’ve started to do regular scheduled test jobs every night on a Windows Server 2019 Edition. These tests run with data sources which create 20 variations of each test, so there’s a lot of testing going on in the night.
However, we regularly (= every night) run into problems. Not because the test runs into testing problems, but because the test itself doesn’t start. It always is the same problem:

WebDriverException: java.net.ConnectException: Connection refused: connect

Usually, this exception kills the test after ~ 5 seconds, and after that happens once, the entire test with all variations as well as the subsequent other tests of the same job fail.

During daytime, we only test with one data source (=one variation of the test) and usually that works just fine. Has anyone run into the same problem and found a solution?

Hi @guntram.goeres . Thanks for reaching out.

Can you please tell me what is the type of this Job (Mobile[Android/iOS]/Web) ?
Also how many test cases inside this Job?
Do you run them on local agent or with virtual?
Do you run this Job on integration with BrowserStack or SacueLabs or on your local computer?

@guntram.goeres also, the logs from the agent which runs on this Windows Server would be very useful to investigate the issue.

Can you please the the content of the following folder and send it to our support email?

%appdata%\testproject\agent\logs

Hi @Vladyslav, thanks for your reply!

Can you please tell me what is the type of this Job (Mobile[Android/iOS]/Web) ?
-> Web only
Also how many test cases inside this Job?
-> The job has 5 tests, with 20 iterations each, 2 browsers, each test has about 10 - 15 steps
Do you run them on local agent or with virtual?
-> On a local agent
Do you run this Job on integration with BrowserStack or SacueLabs or on your local computer?
-> On a local computer

I’ll also send you the log of the most recent test. Thanks!

Thanks for the reply :slight_smile:
We are currently investigating the issue and I will update you as soon as we have more information.

Hi Guntram, regarding the issue you had.

There is not direct solution from our end since this is not related to the agent or our API, its Selenium related.

You can try the following workaround:
Please add a step to Navigate to URL where the URL is ‘about:blank’ BEFORE you navigate to your sites URL.

Furthermore, please let us know if you want us to forward this issue to the Selenium team.

If you have any questions, feel free to ask.

Hi @guntram.goeres, my name is Tzah.

After running some tests and trying to reproduce something similar to what you were running, we found that there is a problem navigating from the websites you are using in your tests.

I was able to reproduce your problem with a simple test using selenium only.

public static void main(String[] args) {

        System.setProperty("webdriver.chrome.logfile", "someLogPath/chromedriver.log");
        System.setProperty("webdriver.chrome.verboseLogging", "true");
        System.setProperty("webdriver.chrome.driver", "chromeDriverPath\\chromedriver.exe");

        WebDriver driver = new ChromeDriver();
        try {
            int i = 0;
            String[] url = {"https://foodlocate.com", "https://speisekarte.menu"};
            String[] food = {"Pizza", "Pasta"};
            while(i < 2) {
                driver.navigate().to(url[i]);
                WebElement searchBox = driver.findElement(By.cssSelector("#company-video"));
                searchBox.click();
                searchBox.sendKeys(food[i]);
                searchBox.sendKeys(Keys.ENTER);
                i++;
            }
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            driver.quit();
        }

        //server.stop();
        System.exit(0);
    }

When running the above code you will see that navigating to the 2nd site never happen.

  1. The 1st site is loading, finding the element and doing w/e its needed.
  2. The 2nd iteration should navigate to the 2nd site, instead it doesn’t but selenium thinks the navigation happened and just moves to the next line of code.
    My guess is that the driver itself is getting stuck at some point and throws the Connection refused eventually because of that issue.
    This is an issue with Selenium and all you can do right now is add a navigation step to about:blank between these sites.

Would you like us to contact Selenium about this issue ?

Hey Ran,

thank you for your response. I added the about:blank step at the start of the test, however it caused an error. I suspect I’m doing something wrong. This is what I did:

image002.png

Thanks!

Regards, Guntram

Hi Guntram, I’ve checked as well and you are correct about:blank does not work.
The simple reason for that is because when we get a URL we check for “://” if it is not there we add “http://”
about:blank is a specific case that doesn’t need this addition.

We will support the about:blank in the next version of the Agent.
For now, you can try to navigate to google or other popular site and that might solve the issue.

Thanks, Tzah.

Hi Tzah,

thank you very much – routing to
https://example.com has solved the issue!

Regards,

Guntram

Hi Tzah,

unfortunately, the issue is back, even worse than before. We updated to the latest version of the test agent (0.61.1). The weird thing is – it’s now happening at a very early stage of
the test if scheduled. If the test is started manually, it’ll work better, but the first failed step will collapse the entire job. Every test / step after that will fail. The first error is

java.net.ConnectException: Connection refused: connect

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

System info: host: ‘WIN-CAVTI1FJ1Q4’, ip: ‘192.168.1.113’, os.name: ‘Windows Server 2019’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘13.0.1’

Driver info: org.openqa.selenium.remote.RemoteWebDriver

Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.149, chrome: {chromedriverVersion: 80.0.3987.16 (320f6526c1632…, userDataDir: C:\Users\ADMINI~1\AppData\L…},
goog:chromeOptions: {debuggerAddress: localhost:61839}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts:
{implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: 8af8e7c9bc27d2b3c3f18d99dc7…}

Session ID: 8af8e7c9bc27d2b3c3f18d99dc7fd40b

Every step after that errors

WebDriverException: java.net.ConnectException: Connection refused: connect

Any chance of help on this?

Thanks!!

Best regards,

Guntram

@guntram.goeres Hi again
I’ll be happy to look at things again and help you out, when are you available for a Zoom meeting?

Anytime, I don’t know what’s your timezone, easiest solution would be you pick a date from
https://calendly.com/vlinde-termin

Thanks!!

1 Like

I’ve sent you a meeting for tomorrow through the link you provided, can you confirm?
EDIT: If the time is good for you ill send the zoom session link here tomorrow.

Can you send me an invite link? Or do we need to access my screen?


This is the invite link, I am there right now