• Neo

Scripting in Auteros

Updated: Sep 4, 2020

In Auteros, we have CSharpScript activity that you can write code in C# and execute it directly in the workflow.

There are two use cases when you want to use this activity:

Use case 1: When you see some functionalities not available with Auteros built-in activities, and these functionalities just need some segments of code to implement, you can use CSharpScript activity to add this code. For bigger implementation, we recommend you write your own custom activities. Auteros has the built-in mechanism to load your custom activities.

Use case 2: Although we have tried to remove the nested scope of Windows Workflow Foundation technology to make the workflow designer easier to see and follow, but for complex scenarios with many steps in the UI, it's still hard. It's very easy to happen since the UI of many business applications contains forms with a lot of fields and also all kinds of tabs, tables, grids inside a single screen.

We already abstracted our automation platform so it will expose an easy to use API for external entities like the workflow activities. And for this use case, we can make a shorter version and easier to understand and follow (for developer) by using CSharpScript activity and call the Automation API.

In this tutorial, we will show you how to using Scripting to automate the flow of login into the sample WpfApp. It was done before by using workflow designer, and you can see it again in this video:

Follow the steps below:

  1. Create a new flowchart workflow named LoginWpfApp, and drag the CSharpScript activity to the workflow designer.

  2. Add UI Automation API namespaces to the workflow as below:

3. Click Edit Code button to open the code editor, and type in the code below:

(1): Add some using namespaces statement for the UI Automation API

(2): You need to declare a public class named 'Program' and a method named 'Main' of this class. This is convention and required by Auteros

(3): Use the static method Launch of UiApplication class to launch a new app. You need to pass in the executable path.

Then sleep a little bit for the app to be seen in the screen. This is for demo purpose only, you can use WaitElementAppear activity for this case.

(4) Get the global UiEngine instance. UiEngine is an abstraction for automation with different technologies: .NET, Java, Web, SAP.

(5) Use the UiEngine to find the Username textbox. You will pass in the Selector for the UI Element and the WaitUpToMs time (30s in this case), so UiEngine will wait and retry in this time period to search. The engine type is WindowsUIA3 for .NET desktop applications.

For the Selector, you will use the Ui Inspector tool to inspect and get it.

Then call the SetText API to write text to the Username textbox.

(6) Do the same for Password textbox.

(7) Do the same for Login button, but use the Click API to click this button.

You can see how Intellisense in the code editor works and how to use the Ui Inspector tool to get the Selector in the following video:

208 views0 comments

Recent Posts

See All