How To Get Appium Session ID Or Job Id From Sauce Labs?

How to get the Appium Session ID or Job Id from Sauce Labs to update/modify the results in Sauce Labs?

In a Mobile device connection, there is no capability of getting Session ID/Job Id created by Appium in Sauce Labs for further modifying/updating the test results in Sauce Labs using API Key.

  1. Use the below C# code in the invoke code activity

var scopeDict = scope as Dictionary<string, object>;

var service = scopeDict["MobileDeviceSessionData"];

FieldInfo fiApiumSession = service.GetType().GetField("_appiumSession", BindingFlags.NonPublic | BindingFlags.Instance);

var appiumSession = fiApiumSession.GetValue(service);

PropertyInfo piSessionId = appiumSession.GetType().GetProperty("SessionId");

sessionId = piSessionId.GetValue(appiumSession).ToString();

  1. Create the arguments as mentioned in the below screenshot

Note: In Create _sessionId local variable there is no need of creating the UiPathScopeContext variable explicitly. It will be taken care of by the Mobile device connection scope just give the name in the value field.

Getting the session ID automatically by mobile device connection scope automatically is in the UiPath product road map which might be released in the upcoming releases.