DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Trending

  • Manual Investigation: The Hidden Bottleneck in Incident Response
  • Dear Micromanager: Your Distrust Has a Job; It’s Just Not the One You’re Doing
  • AI Agents in Java: Architecting Intelligent Health Data Systems
  • LLM Integration in Enterprise Applications: A Practical Guide

Build Your RPA Using Robin

We will use Robin to extract web data and show how to utilize Robin to build your own automation scripts through a C# console application.

By 
Stelios Manioudakis, PhD user avatar
Stelios Manioudakis, PhD
DZone Core CORE ·
James Papadimitriou user avatar
James Papadimitriou
·
Updated Jan. 17, 20 · Tutorial
Likes (9)
Comment
Save
Tweet
Share
24.0K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

Robotic-process automation (RPA) is a field where mundane and repetitive processes are decomposed into multiple machine-related tasks and executed automatically by RPA products. We propose another alternative, the use of a dedicated scripting language. Robin is a domain-specific language for RPA that offers simplicity and feature richness. No programming language experience is necessary. 

This creates new opportunities and facilitates a dynamic trend in automation programming: RPA developers. Robin gives a plethora of options for automation using multiple modules/actions, data-types, statements, functions, conditions, loops, exception handling, control flow and the appropriate syntax. The interested reader is referred to our official documentation here . 

We will use Robin to extract web data, a popular use-case among the RPA community. We will also show how to utilize Robin to build your own automation scripts through a C# console application.

Web-Data Extraction

A common scenario among RPA developers is web data extraction. We will visit a website that publishes stocks from various stock markets, retrieve some data and store it locally. 

Robin has a simple syntax. By following the best practices below we can make our scripts intelligible, dynamic and maintainable. Robin also provides a tool for UI and Web Automation, UISpy that allows selector creation for web and/or desktop control manipulation. 

A common scenario among RPA developers is web data extraction. We will visit a website that publishes stocks from various stock markets, retrieve some data and store it locally. 

Robin has a simple syntax. By following the best practices below we can make our scripts intelligible, dynamic and maintainable. Robin also provides a tool for UI and Web Automation, 

UISpy that allows selector creation for web and/or desktop control manipulation. 

Let’s follow some steps:

  1. Visit the following website
  2. Launch UISpy
  3. In UISpy click “Add Control”
  4. Position your mouse over an element of the United States table
  5. Hold “Ctrl + Shift” and scroll down until the table element is highlighted
Please note that the Robin version used for the specific example is  0.9.2.5567.
Depending on the Robin version you have installed,
    the script might need some changes in order to function as expected.

6. Hold Ctrl and left click to capture the HTMLTable.
7. Hit “DONE”.

 

Note we renamed the .appmask (the file where the generated selector(s) are stored), the application name, the window name and the selector for clarity.

8. Save the file.

Sidenote 
Click “Edit Selectors."    

Modification of selectors is possible through the selector builder. The default selector is sufficient in most cases. The best approach is to first experiment with the autogenerated selector and then modify it accordingly.

To follow the guide step-by-step, leave the selector as it was generated.

9. Open Robin’s editor.

.appmask files must be imported at the top of the script.

Selectors are now available. The syntax to reference a selector is:

[.appmask file].[application].[screen/window].[control]

10. Selectors should be stored in variables for convenience. 

11. Store the website URL.

Functionality in Robin comes in the form of modules and actions. Modules are essentially groups dedicated to a category (e.g.Excel). Nested in modules are sets of actions. Those actions might be grouped in categories/subcategories etc. By writing Excel.Launch, we utilize Excel’s Launch action.

12. Utilize the WebAutomation.LaunchChrome action and pass the Website variable.

Sidenote

Code formatting of action inputs that are generated:

  • Separate inputs, leaving one per line, using the special character ‘\’ which marks line chang
  • Align them
  • Remove autogenerated inputs, if unmodified

The action should look like this:

13. Now we can use the WebAutomation.DataExtraction.ExtractHtmlTableInExcel action 
to extract and write data to an excel instance.

14. We store the excel instance and close the web browser.


15. Press “Run.”
After the execution finishes, an .xlsx file is available in the declared folder. By opening the file we see its cells populated with the extracted values.

This is how the whole script looks:

 

Utilizing Robin Scripts Using C#

After compiling a C# application (for example a console application), an .exe file or a .dll file is produced. We can then distribute these .exe files to anyone we want (colleagues inside our company for instance). This allows for the standardized execution of scripts. A very simple C# Console application (.net core) is shown below. 

We are launching a CMD and passing Robin commands as arguments. Three methods have been created, one dedicated to the help command and another one that is called for both Check and Run commands: 




The third method retrieves all the .robin files from a designated folder. This way you don’t have to hard-code your scripts each time.

 

These methods are then called by the main method of the program:

Four string variables have been created. Three that hold the commands and one that holds the path to the folder that contains the automation scripts.

An .exe has also been generated. It resides in our Debug or Release folder depending on the state you have marked our project. C# is our language of choice but since we are utilizing the CLI, other languages could also be used.

Complete source:

Java
 




xxxxxxxxxx
1
69


 
1
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics;
4
using System.IO;
5
 
6
namespace RobinScriptUtilization
7
{
8
    class Program
9
    {
10
        static void Main(string[] args)
11
        {
12
            // Robin has three console commands:            
13
            // help
14
            string robinHelp = "Robin -h";            
15
            // check script
16
            string robinCheck = "Robin check";            
17
            // run script
18
            string robinRun = "Robin run";
19
           
20
            // call the help command
21
            ExecuteHelpCommand(robinHelp);
22
 
23
            // set the path to the folder/repo containing the script(s)
24
            string ScriptFolderPath = @"C:\Users\RobinScripts\";
25
            
26
            List<string> Scripts = GetRobinScripts(ScriptFolderPath);
27
            
28
 
29
            foreach (string robinScript in Scripts)
30
            {
31
                // execute the Check command
32
                //ExecuteCommand(robinCheck, robinScript);
33
                
34
                // execute the Run command
35
                ExecuteCommand(robinRun, robinScript);
36
            }                        
37
        }
38
        
39
        // Method that retrieves all the .robin files from a specified directory
40
        public static List<string> GetRobinScripts(string folderPath)
41
        {
42
            DirectoryInfo directory = new DirectoryInfo(folderPath);
43
            FileInfo[] Files = directory.GetFiles("*.robin"); //Getting Robin scripts
44
            List<string> ScriptsList = new List<string>();
45
            string script;
46
            foreach (FileInfo file in Files)
47
            {
48
                script = @$" {folderPath}\{file.Name}";
49
                ScriptsList.Add(script);
50
            }
51
            return ScriptsList;
52
        }
53
 
54
        // Method that executes the help command
55
        public static void ExecuteHelpCommand(string robinCommand)
56
        {
57
            Process process = Process.Start("cmd", "/c " + robinCommand);
58
            process.WaitForExit();
59
        }
60
 
61
        // Method that either runs or checks a command 
62
        public static void ExecuteCommand(string robinCommand, string script)
63
        {
64
            Process process = Process.Start("cmd", "/c " + robinCommand + script);
65
            process.WaitForExit();
66
        }
67
    }    
68
}
69
 
          



The possibilities are endless. We could also automate, for example, our Robin scripts to be executed under regular time-intervals or under the occurrence of specific events. In the case of Windows workstations, a simple way to do this is to utilize the generated executables using the Windows’ Task Scheduler at user-defined intervals or events. 

Conclusion 

Robin is a simple yet effective scripting language for RPA. We’ve created a script that extracts web data and used a C# console application to execute our script(s) automatically. The possibilities are countless and it’s up to you to explore.

Robotic process automation Build (game engine)

Opinions expressed by DZone contributors are their own.

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook