Thank you John!
Actually I am using the object repository. This is what I meant with my first sentence of my initial post, and this works fine.
So far I was able to do the following tasks in C#:
- Use object repository to reference screens and elements
- Click on those elements with mouse and type in keyboard strokes
- Use classic C# libraries for handling data (like Excel parsing, File downloads, API calls, …)
But I am struggling with combining my C# code with the visual activities… Here is an example:
public void Execute(string in_connection_name, string in_client, string in_user_name, string in_transaction)
{
var sapLogon = new UiPath.Core.Activities.SAP.Logon();
sapLogon.ConnectionName = in_connection_name;
sapLogon.SAPLogonPath = "C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPGUI\\saplogon.exe";
var invoker = new WorkflowInvoker(sapLogon);
invoker.Invoke();
var userSelectionScreen = uiAutomation.Open(Descriptors.SAP.User_Selection);
userSelectionScreen.TypeInto(Descriptors.SAP.User_Selection.TextField_Client, in_client);
userSelectionScreen.TypeInto(Descriptors.SAP.User_Selection.TextField_User_Name, in_user_name + "[k(Enter)]");
var callTransaction = new UiPath.Core.Activities.SAP.CallTransaction
{
Transaction = in_transaction
};
callTransaction.Target = ???
invoker = new WorkflowInvoker(callTransaction);
invoker.Invoke(); // Crash: UiPath.Core.Activities.ElementNotSetException: 'The target Element was not specified for this activity. You should set its Target property or use this activity inside of a scope activity (Attach Browser, Open Browser, Open Application, Attach Window, Get Active Window, Element Scope activities).
}
The problem is, that the CallTransaction visual activity requires objects, that are very hard to compose in C# without any code examples. Target should be set to an instance of something which I do not have. In this case it requires stuff like TargetApplication, NApplicationCard, ActionActivity<object>, …
A side note: the CallTransaction activity can be custom implemented with C# like this and this works. So to emphasize again the goal of my post - I am trying to understand the concepts, rather then a solution for a particular problem.
var sapEasyAccessScreen = uiAutomation.Open(Descriptors.SAP.SAP_Easy_Access);
sapEasyAccessScreen.TypeInto(Descriptors.SAP.SAP_Easy_Access.TextField_Transaction, in_transaction + "[k(Enter)]");