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: Optional[List[str]] = None, keep_alive: bool = False, page_load_strategy: str = 'normal') aiviro.core.robots.robot_device.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”

Returns

WebRobot

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() aiviro.core.robots.robot_static.StaticRobot

Creates a static noninteractable robot.

Returns

StaticRobot

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) aiviro.core.robots.robot_device.DesktopRobot

Creates a robot for desktop applications.

Parameters

display_id – Identifier to which display to connect

Returns

DesktopRobot

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: Optional[int] = None, auto_reconnect: bool = False, shared_folder: Optional[Union[str, bytes, os.PathLike, Tuple[Union[str, bytes, os.PathLike], str]]] = None) aiviro.core.robots.robot_device.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+

Returns

RDPRobot

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') Union[aiviro.core.robots.robot_device.DesktopRobot, aiviro.core.robots.robot_device.WebRobot, aiviro.core.robots.robot_device.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 or RDPRobot

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: Union[PathType, List[PathType]] = None, pdf_convert_timeout: int = 30, dpi: int = 200, poppler_path: PathType = None, only_digital: bool = False) Union[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
  • IOError – 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

PDFRobot or MultiPDFRobot

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