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

Unable to Connect to HP UFT server from appium

Unable to connect with UFT server with appium with 401 error, kindly advise!

Tags:

Parents
  • 0  

    Hi Srinivas,
    The 401 HTTP code indicates that you're lacking valid authentication credentials. When you connect to the UFT DL embedded Appium server, you need to authenticate. For more info, refer to the Appium capabilities page below:
    https://admhelp.microfocus.com/digitallab/en/2023/Content/Appium/Appium_Capabilities.htm

    Here is a capabilities example using an execution access key:

    {
      "appium:appPackage": "com.Advantage.aShopping",
      "appium:appActivity": "com.Advantage.aShopping.SplashActivity",
      "uftm:oauthClientId": "oauth2-BCGiOu7x9ZwX43MVnhv4@microfocus.com",
      "uftm:oauthClientSecret": "rBQS2AyGCjUoq5Jd75Hb",
      "uftm:tenantId": "999999999",
      "appium:udid": "712KPBF1100565",
      "automationName": "UiAutomator2",
      "platformName": "Android"
    }

    Here is an example using username and password:

    {
      "appium:bundleId": "com.mf.iShopping",
      "uftm:userName": "admin@default.com",
      "uftm:password": "myPassword",
      "uftm:tenantId": "999999999",
      "appium:udid": "3ecdf8889a8b18cb3658410d1540f3e6b22a2cb1",
      "appium:automationName": "XCUITest",
      "platformName": "iOS"
    }

    Regards,
    Alvaro

  • 0 in reply to   

    Alvaro, I have defined as below but still getting 401 error, 

    caps.setCapability("uftm:serverAddress", "https://UFT Server Address:Port/ wd/hub");

    // User credentials for HPMC

    caps.setCapability("uftm:oauthClientId", oauthClientId);

    caps.setCapability("uftm:oauthClientSecret", oauthClientSecret);

    caps.setCapability("uftm:tenantId", tenantId);

    caps.setCapability("newSessionWaitTimeout", 1000);

    caps.setCapability("appium:appPackage", props.getDeviceProperty("androidAppPackage"));

    caps.setCapability("appium:AppActivity", props.getDeviceProperty("androidAppActivity"));

    In my DriverManager class,

    AndroidDriver<RemoteWebElement> driver = null;

    driver = new AndroidDriver<>(new URL(cloudUrl+"/wd/hub"), dc.getCaps()); - Connection Refused-org.openqa.selenium.SessionNotCreatedException: 

  • 0   in reply to 


    Hi,
    The capability "uftm:serverAddress" doesn't exist. Please check the capabilities link provided in my last message.
    Since you're using an access key, ensure that it is an execution access key; not a connector key.
    Here you can find some sample tests:
    https://github.com/uftm-cfrd/appium-samples

    Regards,
    Alvaro

  • 0 in reply to   

    I checked with few changes in capabilities, now i get 500 error

    FATAL com.common.CapabilitiesManager - Failed to load capabilities. ABORT!!org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check t
    he server log for more details. Original error: Unable to parse remote response: <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Error 500 Server Error</title>
    </head>
    <body><h2>HTTP ERROR 500</h2>
    <p>Problem accessing /wd/hub/session. Reason:
    <pre> Server Error</pre></p><hr><i><small>Powered by UFT Mobile://</small></i><hr/>

    </body>
    </html>

  • Verified Answer

    +1   in reply to 

    What are the capabilities being used?

  • 0 in reply to   

    caps.setCapability(MobileCapabilityType.PLATFORM_NAME, Android);

    caps.setCapability(MobileCapabilityType.UDID, udid);

    caps.setCapability("appium:appPackage", props.getDeviceProperty("androidAppPackage"));

    caps.setCapability("appium:appActivity", props.getDeviceProperty("androidAppActivity"));

    caps.setCapability("userName", mcUserId);

    caps.setCapability("password", mcPwd);....i also tried with oAuth

  • 0   in reply to 

    Please refer to the samples I have provided in the previous comments. You need to add the "uftm:" prefix to the UFTM capabilities.
    For more info, check the documentation:
    https://admhelp.microfocus.com/digitallab/en/2023/Content/Appium/Appium_Capabilities.htm
    In the below link, you may find several code samples as well:
    https://github.com/uftm-cfrd/appium-samples

  • 0 in reply to   

    still getting same 500 error

  • 0 in reply to 

    caps.setCapability(MobileCapabilityType.PLATFORM_NAME, platformName);

    caps.setCapability(MobileCapabilityType.UDID, udid);

    caps.setCapability("uftm:userName", mcUserId);

    caps.setCapability("uftm:password", mcPwd);

    caps.setCapability("appium:appPackage", props.getDeviceProperty("androidAppPackage"));

    caps.setCapability("appium:appActivity", props.getDeviceProperty("androidAppActivity"));

  • Verified Answer

    +1   in reply to 

    If you can send your entire test, I can have a look.
    Other than that, you may also open a Support case to have the logs reviewed.

    Did you try any of the sample tests provided in GitHub? If so, how it went?

Reply
  • Verified Answer

    +1   in reply to 

    If you can send your entire test, I can have a look.
    Other than that, you may also open a Support case to have the logs reviewed.

    Did you try any of the sample tests provided in GitHub? If so, how it went?

Children
  • 0 in reply to   

    Hi Alvaro, Thank you, Yes I did try but no luck, do we need to run appium server on local system ?

  • 0   in reply to 

    UFT Digital Lab connectors include two embedded Appium servers (1.x and 2.x), so no need to run Appium server separately.
    I think it would be of help to open a Support case, so you can get assistance through a virtual meeting.

    What is the version of UFT Digital Lab that you're using? Can you send your test?