[Test Automation Foundation Certificate in JS] 2.3.3_Unable to verify Login.e2e.js test in Chrome

Hi there,
To get hands-on exercise with the framwork, I was intending to run the login test designed as part of module 2.3.3 (Getting Stuck in With Code - UI Layer). My test failed upon running the following command in the terminal. Could someone able to shed light on this issue and let me know how to resolve this? I suppose its something to do with the Chrome browser config? :thinking:

npx wdio run ./wdio.conf.js --spec login.e2e.js

Error details:

> Execution of 1 workers started at 2024-06-04T15:54:33.904Z
> 
> 2024-06-04T15:54:33.926Z INFO @wdio/cli:launcher: Run onPrepare hook
> 2024-06-04T15:54:33.928Z INFO @wdio/utils: Setting up browser driver for: chrome@stable
> 2024-06-04T15:54:33.929Z INFO @wdio/utils: Setting up browser binaries for: chrome@stable
> 2024-06-04T15:54:34.030Z INFO webdriver: Using Chromedriver v125.0.6422.114 from cache directory /var/folders/yr/8p_sph411xs8308cx5m1_5s00000gn/T
> 2024-06-04T15:54:34.126Z INFO @wdio/cli:launcher: Run onWorkerStart hook
> 2024-06-04T15:54:34.127Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./wdio.conf.js,--spec,login.e2e.js
> [0-0] 2024-06-04T15:54:35.101Z INFO @wdio/local-runner: Run worker command: run
> [0-0] RUNNING in chrome - file:///test/specs/Login.e2e.js
> [0-0] 2024-06-04T15:54:36.651Z INFO webdriver: Initiate new session using the WebDriver protocol
> [0-0] 2024-06-04T15:54:36.928Z INFO webdriver: Using Chromedriver v125.0.6422.114 from cache directory /var/folders/yr/8p_sph411xs8308cx5m1_5s00000gn/T
> [0-0] 2024-06-04T15:54:36.962Z INFO chromedriver: Starting ChromeDriver 125.0.6422.114 (457d70149965cebad452f7e37e8b5ec5b6dde5b4-refs/branch-heads/6422_76@{#5}) on port 56716
> [0-0] 2024-06-04T15:54:36.962Z INFO chromedriver: Remote connections are allowed by an allowlist (0.0.0.0).
> [0-0] 2024-06-04T15:54:36.962Z INFO chromedriver: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
> [0-0] 2024-06-04T15:54:36.974Z INFO chromedriver: ChromeDriver was started successfully.
> [0-0] 2024-06-04T15:54:37.954Z INFO @wdio/utils: Started Chromedriver v125.0.6422.114 with params --port=56716 --allowed-origins=* --allowed-ips=0.0.0.0 in 1125ms on port 56716
> [0-0] 2024-06-04T15:54:38.090Z INFO webdriver: [POST] http://0.0.0.0:56716/session
> [0-0] 2024-06-04T15:54:38.091Z INFO webdriver: DATA {
> [0-0]   capabilities: {
> [0-0]     alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': [Object] },
> [0-0]     firstMatch: [ {} ]
> [0-0]   },
> [0-0]   desiredCapabilities: {
> [0-0]     browserName: 'chrome',
> [0-0]     'goog:chromeOptions': {
> [0-0]       binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
> [0-0]     }
> [0-0]   }
> [0-0] }
> [0-0] 2024-06-04T15:54:39.783Z INFO webdriver: COMMAND navigateTo("http://localhost:3000/#/login")
> [0-0] 2024-06-04T15:54:39.784Z INFO webdriver: [POST] http://0.0.0.0:56716/session/91669df82aca92cd9cd2722fde1d7c66/url
> [0-0] 2024-06-04T15:54:39.784Z INFO webdriver: DATA { url: 'http://localhost:3000/#/login' }
> [0-0] 2024-06-04T15:54:40.846Z WARN webdriver: Request failed with status 500 due to unknown error: net::ERR_CONNECTION_REFUSED
> [0-0]   (Session info: chrome=125.0.6422.114)
> [0-0] 2024-06-04T15:54:40.846Z INFO webdriver: Retrying 1/3
> [0-0] 2024-06-04T15:54:40.846Z INFO webdriver: [POST] http://0.0.0.0:56716/session/91669df82aca92cd9cd2722fde1d7c66/url
> [0-0] 2024-06-04T15:54:40.846Z INFO webdriver: DATA { url: 'http://localhost:3000/#/login' }
> [0-0] 2024-06-04T15:54:41.488Z WARN webdriver: Request failed with status 500 due to unknown error: net::ERR_CONNECTION_REFUSED
> [0-0]   (Session info: chrome=125.0.6422.114)
> [0-0] 2024-06-04T15:54:41.489Z INFO webdriver: Retrying 2/3
> [0-0] 2024-06-04T15:54:41.489Z INFO webdriver: [POST] http://0.0.0.0:56716/session/91669df82aca92cd9cd2722fde1d7c66/url
> [0-0] 2024-06-04T15:54:41.489Z INFO webdriver: DATA { url: 'http://localhost:3000/#/login' }
> [0-0] 2024-06-04T15:54:42.132Z WARN webdriver: Request failed with status 500 due to unknown error: net::ERR_CONNECTION_REFUSED
> [0-0]   (Session info: chrome=125.0.6422.114)
> [0-0] 2024-06-04T15:54:42.133Z INFO webdriver: Retrying 3/3
> [0-0] 2024-06-04T15:54:42.133Z INFO webdriver: [POST] http://0.0.0.0:56716/session/91669df82aca92cd9cd2722fde1d7c66/url
> [0-0] 2024-06-04T15:54:42.133Z INFO webdriver: DATA { url: 'http://localhost:3000/#/login' }
> [0-0] 2024-06-04T15:54:42.769Z ERROR webdriver: Request failed with status 500 due to unknown error: unknown error: net::ERR_CONNECTION_REFUSED
> [0-0]   (Session info: chrome=125.0.6422.114)
> [0-0] unknown error in "My Login application.should login with valid credentials"
> unknown error: unknown error: net::ERR_CONNECTION_REFUSED
>   (Session info: chrome=125.0.6422.114)
>     at Context.<anonymous> (/Users/anbalv01/mot-cert-support-app-js/test/specs/Login.e2e.js:6:5)
> [0-0] 2024-06-04T15:54:42.778Z INFO webdriver: COMMAND deleteSession()
> [0-0] 2024-06-04T15:54:42.778Z INFO webdriver: [DELETE] http://0.0.0.0:56716/session/91669df82aca92cd9cd2722fde1d7c66
> [0-0] 2024-06-04T15:54:42.832Z INFO webdriver: RESULT null
> [0-0] 2024-06-04T15:54:42.832Z INFO webdriver: Kill driver process with PID 18805
> [0-0] FAILED in chrome - file:///test/specs/Login.e2e.js
> 2024-06-04T15:54:42.960Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
> 2024-06-04T15:54:42.960Z INFO @wdio/cli:launcher: Run onComplete hook
> 
>  "spec" Reporter:
> ------------------------------------------------------------------
> [chrome 125.0.6422.114 mac #0-0] Running: chrome (v125.0.6422.114) on mac
> [chrome 125.0.6422.114 mac #0-0] Session ID: 91669df82aca92cd9cd2722fde1d7c66
> [chrome 125.0.6422.114 mac #0-0]
> [chrome 125.0.6422.114 mac #0-0] ยป /test/specs/Login.e2e.js
> [chrome 125.0.6422.114 mac #0-0] My Login application
> [chrome 125.0.6422.114 mac #0-0]    โœ– should login with valid credentials
> [chrome 125.0.6422.114 mac #0-0]
> [chrome 125.0.6422.114 mac #0-0] 1 failing (3s)
> [chrome 125.0.6422.114 mac #0-0]
> [chrome 125.0.6422.114 mac #0-0] 1) My Login application should login with valid credentials
> [chrome 125.0.6422.114 mac #0-0] unknown error: net::ERR_CONNECTION_REFUSED
>   (Session info: chrome=125.0.6422.114)
> [chrome 125.0.6422.114 mac #0-0] unknown error: unknown error: net::ERR_CONNECTION_REFUSED
> [chrome 125.0.6422.114 mac #0-0]   (Session info: chrome=125.0.6422.114)
> [chrome 125.0.6422.114 mac #0-0]     at Context.<anonymous> (/Users/anbalv01/mot-cert-support-app-js/test/specs/Login.e2e.js:6:5)
> 
> 
> Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:09  
> 
> 2024-06-04T15:54:42.962Z INFO @wdio/local-runner: Shutting down spawned worker
> 2024-06-04T15:54:43.214Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
> 2024-06-04T15:54:43.214Z INFO @wdio/local-runner: shutting down
2 Likes

I am seeing net::ERR_CONNECTION_REFUSED, is the app up and running alright? Can you log in OK via Chrome browser โ€œmanuallyโ€?

2 Likes

Did you mean to login to the application manually in the Chrome browser?

2 Likes

Yea just to make sure it is up and running correctly.

2 Likes

No, it didnโ€™t work when launched in Chrome manually. Getting to see โ€œThis site canโ€™t be reached, localhost refused to connectโ€.

1 Like

Have you run npm start yet?

2 Likes

That worked and the login test has passed. Thank you, much appreciated!

2 Likes