How to solve Connection refused error with Plotly- Dash Testing and Remote Selenium Grid/GitLabSelenium Standalone

Hi Dash community.

I had a problem running an integration test for a dash app I created. I am trying to run an integration test with selenium remotely.

I was able to make it work locally using the selenium chrome webdriver, with the solution shown by @takaakifuruse.

However, it does not work remotely. I created a selenium grid on Google Cloud Platform and can run a simple integration test to see if Google.com loads.

test_google.py

def test_query_window_is_visible(browser):
    browser.get('https://google.com')
    query_window = browser.find_element_by_name('q')
    assert query_window.is_displayed()

I can also run the simple integration test using the selenium standalone service in Gitlab with the template produced by Aleksandr Kotlyar (Files · 1.0.0 · Aleksandr Kotlyar / python-gitlabci-selenium · GitLab).

However, when I switch to test the dash app, my integration test to see if the h1 tag loads, passes when run locally, but when run on Gitlab or by connecting to a remote selenium grid with --remote-url, I get the following errors:

FAILED test_functional.py::test_one - selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_REFUSED
E       selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_REFUSED
E         (Session info: chrome=90.0.4430.85)

Any advice would be helpful.

The code was run as follows:

pytest test_functional.py --log-cli-level DEBUG --webdriver Chrome --remote-url http://*selenium grid endpoint ip address hidden*/wd/hub 

test_functional.py:

import pytest
from selenium import webdriver
from selenium.webdriver import Remote

from selenium.webdriver.chrome.options import Options

from dash.testing.application_runners import import_app


def test_one(dash_duo):
    app = import_app("app")

    dash_duo.start_server(app)

    dash_duo.wait_for_text_to_equal(
        "h1", "Competitor Analysis", timeout=4)

    assert dash_duo.find_element(
        "h1").text == "Competitor Analysis"

conftest.py

import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.remote.webdriver import WebDriver


@pytest.fixture(scope='function')
def browser() -> WebDriver:
    driver = webdriver.Remote(
        command_executor='http://*selenium grid endpoint ip address hidden*/wd/hub',
        options=Options())
    return driver