This guide provides detailed information on how to use RPALite with Robot Framework. RPALite is an open-source RPA (Robotic Process Automation) library that allows you to automate various tasks through Robot Framework.
RPALite currently supports the following platforms:
RPALite supports two OCR engines:
You can configure the OCR engine when initializing RPALite:
*** Settings ***
Library RPALite
*** Settings ***
Library RPALite ocr_engine=paddleocr # Use PaddleOCR
You can also configure other parameters like debug mode, languages, and step pause interval:
*** Settings ***
Library RPALite debug_mode=${TRUE} languages=["en", "fr"] step_pause_interval=5
To install RPALite, use pip:
pip install RPALite
Here’s a simple example of using RPALite with Robot Framework:
*** Settings ***
Library RPALite
*** Test Cases ***
Test Notepad
Send Keys {VK_LWIN down}D{VK_LWIN up}
Run Command notepad.exe
${app} = Find Application .*Notepad
Maximize Window ${app}
Input Text This is a demo using RPALite.
Close App ${app}
RPALite provides many advanced features including:
If you encounter any issues:
You can use the following code to launch an application:
Run Command notepad.exe
To wait for the application to fully launch before proceeding:
Run Command notepad.exe noblock=${FALSE}
You can find an application with the following code:
${app} = Find Application .*Notepad
The Find Application
keyword supports finding an application through the following parameters:
title
: A string representing the regular expression that the application’s title must match,class_name
: A string representing the class name of the application. To find the class name of an application, you can use the Accessibility Insights for Windows tool to view it.Example with class name:
${app} = Find Application title=${NONE} class_name=Notepad
You can close an application with the following code:
${app} = Find Application .*Notepad
Close App ${app}
You can also force quit an application:
Close App ${app} force_quit=${TRUE}
To maximize a program, you first need to locate the program, then call the Maximize Window
method:
${app} = Find Application .*Notepad
Maximize Window ${app}
You can also specify a window title pattern:
Maximize Window ${app} window_title_pattern=Document - Notepad
${position} = Get Cursor Position
Log Cursor position: ${position}
Mouse Move 100 200 # Move to absolute position (x=100, y=200)
Move Mouse To The Middle Of Text Text to move to
Click By Position 100 200 # Left click at position (100, 200)
You can also specify button and double-click parameters:
# Right click
Click By Position 100 200 button=right
# Double left click
Click By Position 100 200 double_click=${TRUE}
Click By Text Click me # Clicks on text that matches "Click me"
With right-click or double-click:
# Right click on text
Click By Text Click me button=right
# Double left click on text
Click By Text Click me double_click=${TRUE}
Click By Image path/to/image.png # Clicks on the image
With customized clicking:
# Right click on image
Click By Image path/to/image.png button=right
# Double left click on image
Click By Image path/to/image.png double_click=${TRUE}
For drag and drop operations:
Mouse Press button=left
Mouse Move 300 400 # Move while holding button
Mouse Release button=left
# Scroll up 3 times
Scroll 3
# Scroll down 2 times
Scroll -2
# Scroll with custom sleep time after
Scroll 1 sleep=1
Input Text Hello World # Types "Hello World" at current cursor position
You can also specify how long to wait after inputting text:
Input Text Hello World seconds=5
Send Keys {ENTER} # Sends Enter key
Send Keys ^c # Sends Ctrl+C
Send Keys %{F4} # Sends Alt+F4
Send Keys +(abc) # Sends Shift+ABC (uppercase)
Send Keys {VK_LWIN down}D{VK_LWIN up} # Show desktop
Enter In Field Username john.doe
Enter In Field Password secret123
${value} = Get Text Field Value Username
Log The username is: ${value}
Validate Text Exists Welcome to RPALite
You can disable throwing exceptions:
${result} = Validate Text Exists Welcome to RPALite throw_exception_when_failed=${FALSE}
${positions} = Find Text Positions Text to find
Log Text positions: ${positions}
Log First matched text position: ${positions}[0]
With exact matching:
${positions} = Find Text Positions Text to find exact_match=${TRUE}
${position} = Wait Until Text Shown Text to wait for timeout=30
Wait Until Text Disappears Text to wait for disappearing timeout=30
${text} = Get Clipboard Text
Log Clipboard content: ${text}
Copy Text To Clipboard This is a test
${location} = Find Image Location path/to/image.png
Searching within another image:
${location} = Find Image Location path/to/needle.png path/to/haystack.png
${locations} = Find All Image Locations path/to/image.png
FOR ${loc} IN @{locations}
Log Found image at: ${loc}
END
Note: If no matches are found, this function will return an empty list, not None.
${location} = Wait Until Image Shown path/to/image.png timeout=30
${control} = Find Control By Label Label text
Log Control position: ${control}
${control} = Find Control Near Text Text near control
Log Control position: ${control}
Click Control By Label Button label
With right-click or double-click:
Click Control By Label Button label button=right double_click=${TRUE}
For Windows applications:
${app} = Find Application Notepad
${control} = Find Control ${app} class_name=Edit title=Text Editor
Clicking a specific part of the control:
Click Control ${app} class_name=Edit click_position=center
Click position options include ‘center’, ‘center-left’, ‘center-right’, ‘left’, and ‘right’.
${windows} = Find Windows By Title Window Title
${video_path} = Start Screen Recording output.avi
Without specifying a file path:
${video_path} = Start Screen Recording
Log Recording to: ${video_path}
With custom frame rate:
${video_path} = Start Screen Recording fps=30
${final_path} = Stop Screen Recording
Log Recording saved to: ${final_path}
Sleep 5 # Sleep for 5 seconds
Show Desktop
${size} = Get Screen Size
Log Screen size: ${size}
${image} = Take Screenshot
With file saving and multi-monitor options:
# Take screenshot and save to file
Take Screenshot filename=screenshot.png
# Capture all screens
${all_screens_image} = Take Screenshot all_screens=${TRUE}
RPALite provides a generic Locate
function that can find objects in different ways:
# Locate by text
${position} = Locate OK Button
# Locate by image path
${position} = Locate image:path/to/image.png
# Locate by automation ID (Windows only)
${app} = Find Application Notepad
${position} = Locate automateId:EditControl app=${app}
You can also use the general-purpose Click
function that works with these locators:
# Click on text
Click OK Button
# Click on image
Click image:path/to/image.png
# Click by automation ID
${app} = Find Application Notepad
Click automateId:EditControl app=${app}