TestProject Forum

Error while running in TestProject SDK

Here I am running testcases on docker with the help of testproject SDK. I am getting below error : Agent on docker is in ready state .

self = <src.testproject.sdk.internal.agent.agent_client.AgentClient object at 0x7fc1a1497970>

def _request_session_from_agent(self):
    """Creates and sends a session request object

    Sets the SessionResponse: object containing the response to the session request
    session_request = SessionRequest(self._capabilities, self._report_settings)

    logging.info(f"Session request: {session_request.to_json()}")

        response = self.send_request(
            urljoin(self._remote_address, Endpoint.DevelopmentSession.value),
    except requests.exceptions.ConnectionError:
        logging.error(f"Could not start new session on {self._remote_address}. Is your Agent running?")
        logging.error("You can download the TestProject Agent from https://app.testproject.io/#/agents")
      raise AgentConnectException(f"Connection error trying to connect to Agent on {self._remote_address}")

E src.testproject.sdk.exceptions.agentconnectexception.AgentConnectException: Connection error trying to connect to Agent on

testproject/sdk/internal/agent/agent_client.py:209: AgentConnectException
------------------------------------------------------ Captured log setup -------------------------------------------------------
ERROR root:agent_client.py:207 Could not start new session on Is your Agent running?
ERROR root:agent_client.py:208 You can download the TestProject Agent from TestProject
==================================================== short test summary info ====================================================
ERROR Portal_TEST/test_test.py::test_main - src.testproject.sdk.exceptions.agentconnectexception.AgentConnectException: Connec…
======================================================= 1 error in 0.75s ========================================================


How are you starting the Docker? SDK fails to communicate with the Agent in the Docker.
You should either start the Agent with docker run and forwarding the port:

docker run --name testproject-agent -p 8585:8585 testproject/agent:latest

Or use docker-compose and specify the port forwarding there:

# NOTE: Make sure to update the 'testproject-agent' container volume with a valid local path.
# To execute this docker-compose, store it in a file (e.g. testproject-agent.yaml) an run:
# docker-compose -f <file_name> up -d

version: "3.1"
    image: testproject/agent:latest
    container_name: testproject-agent
      - chrome
      - firefox
      TP_SDK_PORT: "8686"             # Agent will listen on port 8686 for SDK connections
      CHROME: "chrome:4444"           # Address for Agent to communicate with Chrome browser
      CHROME_EXT: "localhost:5555"    # Address for accessing the Chrome Selenium server
      FIREFOX: "firefox:4444"         # Address for Agent to communicate with Firefox browser
      FIREFOX_EXT: "localhost:5556"   # Address for accessing the Firefox Selenium server
    - "8585:8585"
    - "8686:8686"                     # Expose port for SDK<->Agent communication
    image: selenium/standalone-chrome
    shm_size: '1gb'
    - "5555:4444"                     # Expose Selenium on port 5555
    image: selenium/standalone-firefox
    shm_size: '1gb'
    - "5556:4444"                     # Expose Selenium on port 5556

There is more information at Docker Hub

1 Like

Hey !!
Thanks for the information !!