This is UltimateRPA Documentation
Advanced lessons

In the previous lessons, we looked at the basic features of UltimateRPA. Before proceeding to more advanced tutorials, we need to lay down a few ground rules.

Main function

In each robotic script, you need to define a function called "main". The main function is the entry point of a script and is invoked by Robot.exe when you run the robotic script. The main function's body therefore contains all the actions of the process you wish to robotize. If, in Robot.exe, you run a script in which the main function is not defined, the following error appears: ‘AttributeError: 'module’ object has no attribute 'main'`.

Working directory

It is very important to know where your current working directory is, for example, if you want to refer files via a relative path in your scripts. When a robotic script is run, the working directory will be set to the directory from which the script is run. To know the current working directory run the following script, which lists the current working directory.

import os
def main():
print(os.getcwd())

Log

If you run a robotic script from the IDE PyScripter, you can find a log at the bottom window under the Output tab. Another place where you can find logs is the log directory next to the script. Here, logs are sorted by the name of the robotic script and run date. Older logs are compressed into a zip file in the log directory.

RobotInteraction_pyscripter_output.png
Figure 1 Output window

The log contains a lot of useful information about how the robotization took place. For example, you can find out when a particular GUI element was found. All of your print commands from the robotic script are also printed in the log, so you can add information to the log that is useful to you.

How it all works

A robotic script in Python, written in any editor, is fed to Robot.exe when run. Robot.exe runs Python 3.7 (until version 4.5 it was Python 2.7), which is part of the UltimateRPA toolkit (this means that, for robotics with UltimateRPA, there is no need to have Python installed on the workstation). The robotic script is imported and the main function is invoked.