You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RoboCorp is a Python or YAML based programming platform using which we can automate many things like Web Automation and Desktop Automation
Unlike other platforms like UiPath and Automation Anywhere, it is coding based but do provides an feature to select and locate the element attributes from application
The RoboCorp follows a certain structure:
Every Robot is created inside an virtual environment
It consists of 3 files by default robot.yaml, tasks.robot, conda.yaml
robot.yaml -> This file defines the settings of the bot like python-path or basic python command to run the files
conda.yaml -> It is used to define the dependencies need to be present while running the program
tasks.robot -> This is the main file in which we write the code to execute bot
To Download files from web we can use RPA.HTTP
To Use Excel without installing excel in system we can use RPA.Excel.Files
To Automate on web we use RPA.Browser.Selenium
To print anything for testing purpose we can use Log keyword as Log ${variable_name}
In keywords if we have multiple arguments then we can pass them on multiple lines by using ... in beginning of each line
Keyword Argument1="Some Value"
... Argument2="Some Value 2"
... Argument3="Some Value 3"
To use space in paths use \ , like /Users/piyus/Desktop/JOB/Piyush\ Agarwal\ _10.jpg
Tasks
The Tasks file structure consists of 3 major parts
Settings -> define the Documentation and Library required for the bot
Keywords -> One can understand keywords as a block of code resembling an function definition
Tasks -> This is the section which runs the bot and we call the keywords inside it
The idea of tasks.robot is to separate all the functions of bot into multiple keywords and call each keyword based on required sequence in the Tasks context
Keywords
keywords are to be understand as functions
They can be with or without arguments
An Keyword Example without argument is
*** Keywords ***
Open The Website For Me
Open Avaialble Browser https://www.google.com
An Keyword Example with argument is
*** Keywords ***
Iterate Using Arguments
[Arguments] ${variable_name}
...more keywords
locator
It is an argument for web keywords which are used to detect the element on which some action is to be performed over browser
There can be multiple ways to detect elements such as using name, id, css, XPath, FullXPath
RPA.Browser.Selenium
This is a library used for web automation and includes various keywords that can be used for the same
Example is Open Available Browser https://www.google.com
${CURDIR} -> represents the current directory where our task file resides
${/} -> represents the path separator for the current operating system
[Teardown] -> ensures that the keyword is executed for sure even if other keyword faces some error. It can be understood as the finally block of try-catch
[Return] -> To Return any value from a Keyword which is basically a function we use this in-built variable
[Arguments] -> To send arguments to the keyword while calling we use this in-built variable
Vault
Credentials in RoboCorp are stored in vault
Locally we can access credentials through Json file and over cloud we use Vault of RoboCorp
To Access Credentials, we need to configure few things:
Create a directory named devdata in main folder
Create a devdata/env.json file in devdata
Add the following content inside the env.json file
Get Messages Where Subject Contains[Arguments] ${subject}@{emails} List Messages SUBJECT "${subject}"FOR ${email} IN @{emails}Log ${email}Log ${email}[Subject]Log ${email}[From]Log ${email}[Date]Log ${email}[Received]Log ${email}[Has-Attachments]END[Return] @{emails}
Example to download the attachments
Download Attachments[Arguments] @{emails}FOR ${email} IN @{emails}Run Keyword If ${email}[Has-Attachments] == True... Save Attachment ${email} target_folder=${CURDIR}${/}output overwrite=TrueEND
File System
For file system operations we use RPA.FileSystem
Keywords for Directories are:
${dir_exists}= Does Directory Exist ${CURDIR}${dir_does_not_exist}= Does Directory Not Exist ${CURDIR}${dir_tree}= Log Directory Tree ${CURDIR}${dir_is_empty}= Is Directory Empty ${CURDIR}${dir_is_not_empty}= Is Directory Not Empty ${CURDIR}Create File ${TEXT_FILE} Hello overwrite=TrueWait Until Created ${TEXT_FILE}Touch File ${TEXT_FILE}${file_exists}= Does File Exist ${TEXT_FILE}${file_does_not_exist}= Does File Not Exist ${TEXT_FILE}${file_is_empty}= Is File Empty ${TEXT_FILE}${file_is_not_empty}= Is File Not Empty ${TEXT_FILE}${found_files}= Find Files \*.txtAppend To File ${TEXT_FILE} World!${text_content}= Read File ${TEXT_FILE}${absolute_path}= Absolute Path ${TEXT_FILE}${created}= Get File Creation Date ${TEXT_FILE}${extension}= Get File Extension ${TEXT_FILE}${modified}= Get File Modified Date ${TEXT_FILE}${name}= Get File Name ${TEXT_FILE}${size}= Get File Size ${TEXT_FILE}Copy File ${TEXT_FILE} ${TEXT_FILE_COPY}${files}= List Files In Directory ${CURDIR}${directories}= List Directories In Directory ${CURDIR}Create Directory ${NEW_DIR_1}${files_to_move}= Create List ${TEXT_FILE} ${TEXT_FILE_COPY}Move Files ${files_to_move} ${NEW_DIR_1} overwrite=TrueRun Keyword If File Exists... ${NEW_DIR_2}/${TEXT_FILE}... Remove Directory ${NEW_DIR_2} recursive=TrueMove Directory ${NEW_DIR_1} ${NEW_DIR_2} overwrite=TrueRun Keyword And Ignore Error... Copy Directory ${NEW_DIR_2} ${NEW_DIR_2_COPY}Run Keyword And Ignore Error... Change File Extension... ${NEW_DIR_2}/${TEXT_FILE_COPY}... .mdEmpty Directory ${NEW_DIR_2_COPY}
Access Windows Credential Manager
By Default RoboCorp does not provide this feature
We can use keyring module for the same using its function get_credential(Address_Name,None)