Create Robot
A robot is a basic unit that allows us to create automation. We provide several types of robots that can automate different applications.
- aiviro.core.robots.robot_factory.create_web_robot(headless: bool = False, resolution: Tuple[int, int] = (1920, 1080), scale_factor: float = 1.0, additional_args: List[str] | None = None, keep_alive: bool = False, page_load_strategy: str = 'normal', pause: bool = False, webdriver_path: str | Path | None = None, webdriver_type: Literal['chrome', 'firefox', 'edge', 'safari'] = 'chrome') WebRobot
Creates a robot for web applications.
- Parameters:
headless – If it’s True, web-driver runs in headless mode
resolution – Only used for headless mode, set the resolution of the web-driver window
scale_factor – Scale factor of display
additional_args – Additional argument for web-driver
keep_alive – Don’t close the web-driver window after the script ends. Useful when chaining Aiviro with Selenium.
page_load_strategy – Web-driver page load strategy, supported values are “normal”, “eager”, “none”
pause – If True, robot will be paused, to use it you’ll have to call unpause method
webdriver_path – Path to the web-driver executable, it overrides the setting from the global configuration
webdriver_type – Type of the web-driver to use, supported values are “chrome”, “firefox”, “edge”, “safari”
- Returns:
- Example:
>>> import aiviro >>> r = aiviro.create_web_robot() ... # creates headless web-robot >>> r_headless = aiviro.create_web_robot(headless=True)
- aiviro.core.robots.robot_factory.create_static_robot() StaticRobot
Creates a static noninteractable robot.
- Returns:
- Example:
>>> import aiviro >>> from aiviro.core.utils import file_utils >>> img = file_utils.load_image("path/to/image.png") >>> r = aiviro.create_static_robot() >>> box = r.get(aiviro.Text("some-text"), screen=img)
- aiviro.core.robots.robot_factory.create_desktop_robot(display_id: int = 1, pause: bool = False) DesktopRobot
Creates a robot for desktop applications.
- Parameters:
display_id – Identifier to which display to connect
pause – If True, robot will be paused, to use it you’ll have to call unpause method
- Returns:
- Example:
>>> import aiviro >>> r = aiviro.create_desktop_robot()
- aiviro.core.robots.robot_factory.create_rdp_robot(remote_address: str, username: str, password: str, domain: str, port: int | None = None, auto_reconnect: bool = False, shared_folder: PathVar | Tuple[PathVar, str] | None = None, pause: bool = False) RDPRobot
Creates a robot for desktop applications connected remotely via RDP protocol.
Note
It’s required to install
rdp
from Optional dependencies section.- Parameters:
remote_address – Address of the remote computer you want to connect to
username – Username of the computer
password – Password of the computer
domain – Domain name of which the username is part of. Use “.” for local users
port – Optional port to RDP server.
auto_reconnect – Enables robot to auto-reconnect to the remote PC when a network issue occurs. pyfreerdp 3+
shared_folder – Maps local folder to the remote machine. pyfreerdp 3+. Folder can be renamed on the remote machine by passing a tuple of (path, name). If the folder doesn’t exist, it will be created, but not its parents.
pause – If True, robot will be paused, to use it you’ll have to call unpause method
- Returns:
- Example:
>>> import aiviro >>> r1 = aiviro.create_rdp_robot( ... "<ip-address>", ... "<username>", ... "<password>", ... "<domain>" ... )
>>> # Using robot with shared folder: >>> r2 = aiviro.create_rdp_robot( ... "<ip-address>", ... "<username>", ... "<password>", ... "<domain>", ... shared_folder=r"c:\path o\dir" ... ) >>> # The above folder appears on the RDP machine as "\\tsclient\dir"
>>> # Using robot with shared, renamed folder: >>> r3 = aiviro.create_rdp_robot( ... "<ip-address>", ... "<username>", ... "<password>", ... "<domain>", ... shared_folder=(r"c:\path", "newname") ... ) >>> # The above folder appears on the RDP machine as "\\tsclient\newname"
- aiviro.core.robots.robot_factory.create_env_robot(env_variable_name: str = 'AIVIRO_ROBOT_ENV') DesktopRobot | WebRobot | RDPRobot
Creates a robot using data from environment variable.
- Parameters:
env_variable_name – Name of the environment variable to use
- Returns:
The instance of
DesktopRobot
,WebRobot
orRDPRobot
- Example:
{ "robot_type": "rdp", "remote_address": "192.169.10.22", "username": "username", "password": "password", "domain": ".", }
>>> # set-up value of the environment variable 'AIVIRO_ROBOT_ENV' based on the json-example above >>> import aiviro ... # it creates rdo-robot >>> r = aiviro.create_env_robot()
- aiviro.modules.pdf.create_pdf_robot(pdf_path: PathType | List[PathType] | None = None, pdf_convert_timeout: int = 30, dpi: int = 200, poppler_path: PathType | None = None, only_digital: bool = False) PDFRobot | MultiPDFRobot
Create a noninteractable robot, which is primarily used for reading and parsing PDF files.
Note
It’s required to install
pdf
from Optional dependencies section.- Parameters:
pdf_path – Path or list of paths to a PDF file(s) this robot should read
pdf_convert_timeout – Timeout for reading PDF file. For more complex PDF files higher timeout should be used
dpi – Display resolution of pages from PDF
poppler_path – Path to poppler application. Can be ommited if poppler is included in PATH system variable
only_digital – If True, only PDF files which can be read digitally are processed. Files where OCR would have to be used are skipped
- Raises:
FileNotFoundError – If the path doesn’t exist or points to a directory
TypeError – If the PDF file cannot be read successfully. In most cases non PDF file is in path
- Returns:
- Example:
>>> from aiviro.modules.pdf import create_pdf_robot >>> # returns PDFRobot, loads only one file >>> r = create_pdf_robot().parse("path/to/file.pdf", skip_chars=["_"])
>>> # returns MultiPDFRobot, loads several files at once >>> r = create_pdf_robot( ... [ ... "path/to/pdf_1.pdf" ... "path/to/pdf_2.pdf" ... "path/to/pdf_3.pdf" ... "path/to/pdf_4.pdf" ... ] ... ) >>> r.add_file("path/to/pdf_5.pdf", skip_chars=["_"]) # parse additional file