TestProject Forum

SDK error message AgentConnectException

Hi Team, i have recently started looking at Python SDK and selenium python in chrome webdriver work perfectly fine but when i change the configurations to TestProject Python SDK im getting the below error message when running the tests:
C:\bin\python\python.exe C:/bin/My_first_Project_DemoTest1_python/test_demotest1.py
2021-09-03 16:11:27,997 INFO SDK version: 1.2.2
2021-09-03 16:11:27,998 INFO Session request: {‘projectName’: ‘My first Project’, ‘jobName’: ‘uob’, ‘capabilities’: {‘browserName’: ‘chrome’, ‘version’: ‘’, ‘platform’: ‘ANY’, ‘goog:chromeOptions’: {‘extensions’: , ‘args’: }}, ‘sdkVersion’: ‘1.2.2’, ‘language’: ‘Python’, ‘reportType’: ‘CLOUD_AND_LOCAL’, ‘reportName’: None, ‘reportPath’: None}
2021-09-03 16:11:28,160 ERROR Failed to initialize a session with the Agent
Traceback (most recent call last):
File “C:\bin\My_first_Project_DemoTest1_python\test_demotest1.py”, line 58, in
File “C:\bin\My_first_Project_DemoTest1_python\test_demotest1.py”, line 10, in test_main
driver = webdriver.Chrome(token=“otWrvszQQ1UP_JJzfRkNXCenebrXl9t03PYnNfGXlxw1”,
File “C:\bin\python\lib\site-packages\src\testproject\sdk\drivers\webdriver\chrome.py”, line 55, in init
File “C:\bin\python\lib\site-packages\src\testproject\sdk\drivers\webdriver\base\basedriver.py”, line 107, in init
self._agent_client: AgentClient = AgentClient(
File “C:\bin\python\lib\site-packages\src\testproject\sdk\internal\agent\agent_client_singleton.py”, line 31, in call
cls._instances[cls] = super(AgentClientSingleton, cls).call(*args, **kwargs)
File “C:\bin\python\lib\site-packages\src\testproject\sdk\internal\agent\agent_client.py”, line 100, in init
File “C:\bin\python\lib\site-packages\src\testproject\sdk\internal\agent\agent_client.py”, line 143, in __start_session
File “C:\bin\python\lib\site-packages\src\testproject\sdk\internal\agent\agent_client.py”, line 219, in _request_session_from_agent
File “C:\bin\python\lib\site-packages\src\testproject\sdk\internal\agent\agent_client.py”, line 483, in __handle_new_session_error
raise AgentConnectException(
src.testproject.sdk.exceptions.agentconnectexception.AgentConnectException: Agent responded with HTTP status 502: [502 Server Error: cannotconnect for url: http://localhost:8585/api/development/session]

This api give me that same like : http://localhost:8585/api/development/session: {“status”:405,“code”:500,“source”:null,“message”:“Application error occurred during the request processing, please try again”}

Im running on Python 3.9 and pip 21.2.4 With TestProject agent 3.2.0

from selenium.webdriver.common.by import By
from src.testproject.sdk.drivers import webdriver

def test_main():
    # Test Parameters
    # Auto generated application URL parameter
    ApplicationURL = "https://example.testproject.io/web/"

    driver = webdriver.Chrome(token="",
                              project_name="My first Project",
                              job_name="uob", agent_url="http://localhost:8585/")

    # 1. Navigate to '{ApplicationURL}'
    # Navigates the specified URL (Auto-generated)


    # 2. Click 'Watch demos:'
    watch_demos_colon_ = driver.find_element(By.XPATH,
                                             "//span[. = 'Watch demos:']")

    # 3. Click 'FREE SIGN UP'
    free_sign_up = driver.find_element(By.XPATH,
                                       "//div/div/a[. = 'FREE SIGN UP']")

    # 4. Switch to window '1'

    # 5. Close window with index '1'

    # 6. Switch to window '0'

    # 7. Click 'Login1'
    login1 = driver.find_element(By.CSS_SELECTOR,

    # 8. Click 'Enter your full name'
    enter_your_full_name = driver.find_element(By.CSS_SELECTOR,

    # 9. Click 'Enter your password'
    enter_your_password = driver.find_element(By.CSS_SELECTOR,


This is Blocker for us, any help would be really appreciated… are we missing anything? thanks!

Hi @SaiManojKumar.Rudra,

Thank you for your patience.
The team is investigating it and will get back to you ASAP.

1 Like

Hi @SaiManojKumar.Rudra,
We have contacted you via email please let us know if you issue is resolved.

i dnt think i got reply from you yet on the code snippet i sent on Friday, you did reply saying:
Hi Kumar,
Thanks for the snippet we are checking

the issue is resolve got this working for some reason its my proxy that not letting my go through past the agent, we added this code and tests are running fine

We can add in the code or add as Environment variables in run configurations:
os.environ['NO_PROXY'] = ''

Although i have my proxy already setup in my IntelliJ in setting but for some reason python was not accepting that i think so. but the above code worked.