This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Failed to establish a new connection with UFT Mobile Server using Appium and python

I use python and appium to connect UFTM server, a error pop up with the message 

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000001A5AED2C648>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

When I use appium inspector to connect the device, it succeed. But using python and appium to connect it, it always failed to connect.

Followings are wo code, which parts I missed?

from appium import webdriver

desired_caps = {
'platformName': 'Android',
'platformVersion': '10',
'deviceName': 'Galaxy S10',
'appPackage': 'com.foreverht.workplus.hcbmpre',
'appActivity': 'com.foreveross.atwork.modules.main.activity.SplashActivity',
'unicodeKeyboard': True,
'resetKeyboard': True,
'noReset': True,
'newCommandTimeout': 6000,
'automationName': 'UiAutomator2',
'oauthClientId': 'oauth2-xxxxxx@microfocus.com',
'oauthClientSecret': 'xxxxxxxx',
'tenantId': '999999999'
}

driver = webdriver.Remote(r'https://xxxx:443/wd/hub', desired_caps)
# xxxx:443 is the UFT Mobile Server URL

print('create driver session successfully')

driver.quit()
Parents
  • Hi there,
    Your UFTM server seems to be configured with SSL (HTTPS). Assuming that you're using a self-signed certificate, you should add strict_ssl=False when instantiating the webdriver. Check https://pypi.org/project/Appium-Python-Client/

    Now, for the UFTM-specific capabilities, you may require using the "uftm:" prefix on recent UFTM versions. For more info: https://admhelp.microfocus.com/uftmobile/en/2021-2021_R2/Content/Appium/Appium_Capabilities.htm

    For example:

    from appium import webdriver
    
    desired_caps = {
        'platformName': 'Android',
        'platformVersion': '10',
        'deviceName': 'Galaxy S10',
        'appPackage': 'com.foreverht.workplus.hcbmpre',
        'appActivity': 'com.foreveross.atwork.modules.main.activity.SplashActivity',
        'unicodeKeyboard': True,
        'resetKeyboard': True,
        'noReset': True,
        'newCommandTimeout': 6000,
        'automationName': 'UiAutomator2',
        'uftm:oauthClientId': 'oauth2-xxxxxx@microfocus.com',
        'uftm:oauthClientSecret': 'xxxxxxxx',
        'uftm:tenantId': '999999999'
    }
    
    driver = webdriver.Remote(r'https://xxxx:443/wd/hub', desired_caps, strict_ssl=False)
    # xxxx:443 is the UFT Mobile Server URL
    
    print('create driver session successfully')
    
    driver.quit()

    I tried this with the demo app and it worked for me. If it still fails for you, what is the Appium-Python-Client version that you're using (pip list)?
    Cheers,
    Alvaro

  • Hi Alvaro,it still doesn't work for me, the appium-python-client version is 2.6.0 and my python version is 3.7. I tried python 3.9 but it also failed.

  • Hi Chen Zhou,
    I am using Python 3.10.2 with the Appium-Python-Client version 2.6.0 and, as you can see below, it works:

    Could you please provide the full output/exception that you get when running the script?
    Also, can you try the demo app that comes with UFTM? This is just to discard this being a situation related to the specific app that you're trying.
    Regards,
    Alvaro

  • Hi ,

    Sorry for late response, after the discussion with my colleagues, we found maybe we should use proxy to access UFTM server, do you know how to set proxy server for appium?

  • Hi Chen Zhou,

    As per the Appium client documentation, you may indicate the proxy when instantiating the webdriver:
    https://appium.github.io/python-client-sphinx/webdriver.html

    Regards,
    Alvaro

Reply Children
No Data