Boot Time In Seconds From Epoch

Arguments

Get machine boot time

return:boot time in seconds from Epoch

Example:


${epoch}  Boot Time In Seconds From Epoch

Calculate Rectangle Center

Arguments

  • rectangle: typing.Any

Calculate x and y center coordinates from rectangle.

param rectangle:
 element rectangle coordinates
return:x and y coordinates of rectangle center

Example:


Open Using Run Dialog   calc  Calculator
&{rect}=        Get Element Rectangle    CalculatorResults
${x}  ${y}=     Calculate Rectangle Center   ${rect}

Click Type

Arguments

  • x: int = None
  • y: int = None
  • click_type: str = click

Mouse click on coordinates x and y.

Default click type is click meaning left

param x:horizontal coordinate for click, defaults to None
param y:vertical coordinate for click, defaults to None
param click_type:
 "click", "right" or "double", defaults to "click"
raises ValueError:
 if coordinates are not valid

Example:


Click Type  x=450  y=100
Click Type  x=450  y=100  click_type=right
Click Type  x=450  y=100  click_type=double

Close All Applications

Arguments

Close all applications

Example:


Open Application   Excel
Open Application   Word
Open Executable    notepad.exe   Untitled - Notepad
Close All Applications

Connect By Handle

Arguments

  • handle: str
  • windowtitle: str = None
  • existing_app: bool = False

Connect to application by its handle

param handle:handle of the application

Example:


${appid}  Connect By Handle  88112

Connect By Pid

Arguments

  • app_pid: str
  • windowtitle: str = None

Connect to application by its pid

param app_pid:process id of the application

Example:


${appid}  Connect By PID  3231

Drag And Drop

Arguments

  • src: typing.Any
  • target: typing.Any
  • src_locator: str
  • target_locator: str = None
  • handle_ctrl_key: bool = False
  • drop_delay: float = 2.0

Drag elements from source and drop them on target.

Please note that if CTRL is not pressed down during drag and drop then operation is MOVE operation, on CTRL down the operation is COPY operation.

There will be also overwrite notification if dropping over existing files.

param src:application object or instance id
param target:application object or instance id
param src_locator:
 elements to move
param handle_ctrl_key:
 True if keyword should press CTRL down dragging
param drop_delay:
 how many seconds to wait until releasing mouse drop, default 2.0
raises ValueError:
 on validation errors

Example:


${app1}=        Open Using Run Dialog    explorer.exe{VK_SPACE}C:\workfiles\movethese   movethese
${app2}=        Open Using Run Dialog    wordpad.exe   Document - WordPad
Drag And Drop   ${app1}   ${app2}   regexp:testfile_\d.txt  name:Rich Text Window   handle_ctrl_key=${True}
Drag And Drop   ${app1}   ${app1}   regexp:testfile_\d.txt  name:subdir  handle_ctrl_key=${True}

Find Element

Arguments

  • locator: str
  • search_criteria: str = None

Find element from window by locator and criteria.

param locator:name of the locator
param search_criteria:
 criteria by which element is matched
return:list of matching elements and locators that were found on the window

Example:


@{elements}   Find Element   CalculatorResults
Log Many  ${elements[0]}     # list of matching elements
Log Many  ${elements[1]}     # list of all available locators

Get App

Arguments

  • app_id: int = None

Get application object by id

By default returns active_application application object.

param app_id:id of the application to get, defaults to None
return:application object

Example:


${app1}        Open Application   Excel
&{appdetails}  Get App   ${app1}

Get Boot Time

Arguments

  • as_datetime: bool = False
  • datetime_format: str = %Y-%m-%d %H:%M:%S

Get computer boot time in seconds from Epoch or in datetime string.

param as_datetime:
 if True returns datetime string, otherwise seconds, defaults to False
param datetime_format:
 datetime string format, defaults to "%Y-%m-%d %H:%M:%S"
return:seconds from Epoch or datetime string

Example:


${boottime}  Get Boot Time
${boottime}  Get Boot Time   as_datetime=True
${boottime}  Get Boot Time   as_datetime=True  datetime_format=%d.%m.%Y

Get Dialog Rectangle

Arguments

  • ctrl: typing.Any = None
  • as_dict: bool = False

Get dialog rectangle coordinates

If ctrl is None then get coordinates from dialog :param ctrl: name of the window control object, defaults to None :return: coordinates: left, top, right, bottom

Example:


${left}  ${top}  ${right}  ${bottom}=  Get Dialog Rectangle
&{coords}  Get Dialog Rectangle  as_dict=True
Log  top=${coords.top} left=${coords.left}

Get Element

Arguments

  • locator: str
  • screenshot: bool = False

Get element by locator.

param locator:name of the locator
param screenshot:
 takes element screenshot if True, defaults to False
return:element if element was identified, else False

Example:


${element}  Get Element  CalculatorResults
${element}  Get Element  Result      screenshot=True

Get Element Center

Arguments

  • element: dict

Get element center coordinates

param element:dictionary of element items
return:coordinates, x and y

Example:


@{element}   Find Element  CalculatorResults
${x}  ${y}=  Get Element Center  ${elements[0][0]}

Get Element Rectangle

Arguments

  • locator: str
  • as_dict: bool = False

Get value of element rectangle attribute.

param locator:element locator
param as_dict:return values in a dictionary, default False
return:(left, top, right, bottom) values if found, else False

Example:


${left}  ${top}  ${right}  ${bottom}=  Get Element Rectangle  CalculatorResults
&{coords}  Get Element Rectangle  CalculatorResults  as_dict=True
Log  top=${coords.top} left=${coords.left}

Get Element Rich Text

Arguments

  • locator: str

Get value of element rich text attribute.

param locator:element locator
return:rich_text value if found, else False

Example:


${text}  Get Element Rich Text  CalculatorResults

Get Machine Name

Arguments

Get machine name

return:machine name as string

Example:


${machine}  Get Machine Name

Get Memory Stats

Arguments

  • humanized: bool = True

Get computer memory stats and return those in bytes or in humanized memory format.

param humanized:
 if False returns memory information in bytes, defaults to True
return:memory information in dictionary format

Example:


&{mem}     Get Memory Stats
&{mem}     Get Memory Stats   humanized=False

Get Open Applications

Arguments

Get list of all open applications

Returns a dictionary

Example:


${app1}    Open Application   Excel
${app2}    Open Executable    calc.exe  Calculator
${app3}    Open File          /path/to/myfile.txt
&{apps}    Get Open Applications

Get Spaced String

Arguments

  • text

Replace spaces in a text with pywinauto.keyboard space characters {VK_SPACE}

param text:replace spaces in this string

Example:


${txt}    Get Spaced String   My name is Bond
# ${txt} = My{VK_SPACE}name{VK_SPACE}is{VK_SPACE}Bond

Get Text

Arguments

  • locator: str

Get text from element

param locator:element locator

Example:


Open Using Run Dialog  calc     Calculator
Type Into    CalculatorResults   11
Type Into    CalculatorResults   55
&{val}       Get Text   CalculatorResults

Get Username

Arguments

Get username of logged in user

return:username as string

Example:


${user}  Get Username

Get Window Elements

Arguments

  • screenshot: bool = False
  • element_json: bool = False
  • outline: bool = False

Get element information about all window dialog controls and their descendants.

param screenshot:
 save element screenshot if True, defaults to False
param element_json:
 save element json if True, defaults to False
param outline:highlight elements if True, defaults to False
return:all controls and all elements

Example:


@{elements}   Get Window Elements
Log Many      ${elements[0]}     # list of all available locators
Log Many      ${elements[1]}     # list of matching elements
@{elements}   Get Window Elements  screenshot=True  element_json=True  outline=True

Get Window List

Arguments

Get list of open windows

Window dictionaries contain:

  • title
  • pid
  • handle
return:list of window dictionaries

Example:


@{windows}    Get Window List
FOR  ${window}  IN  @{windows}
    Log Many  ${window}
END

Is Element Enabled

Arguments

  • locator: str

Is element enabled.

param locator:element locator
return:True if enabled, else False

Example:


${res}=   Is Element Enabled  CalculatorResults

Is Element Matching

Arguments

  • itemdict: dict
  • locator: str
  • criteria: str
  • wildcard: bool = False

Is element matching. Check if locator is found in any field or criteria field in the window items.

param itemDict:dictionary of element items
param locator:name of the locator
param criteria:criteria on which to match element
param wildcard:whether to do reg exp match or not, default False
return:True if element is matching locator and criteria, False if not

Is Element Visible

Arguments

  • locator: str

Is element visible.

param locator:element locator
return:True if visible, else False

Example:


${res}=   Is Element Visible  CalculatorResults

Kill Process

Arguments

  • process_name: str

Kill process by name

param process_name:
 name of the process
return:True if succeeds False if not

Example:


${process}  Process Exists  calc  strict=False
${status}   Kill Process    ${process.name()}

Kill Process By Pid

Arguments

  • pid: int

Kill process by pid

param pid:process identifier

Example:


${process}  Process Exists  calc  strict=False
${status}   Kill Process    ${process.pid}

Lock Screen

Arguments

Put windows into lock mode

Example:


Lock Screen

Log In

Arguments

  • username: str
  • password: str
  • domain: str = .

Log into Windows domain with username and password.

param username:name of the user
param password:password of the user
param domain:windows domain for the user, defaults to "."
return:handle

Example:


Log In  username=myname  password=mypassword  domain=company

Minimize Dialog

Arguments

  • windowtitle: str = None

Minimize window by its title

param windowtitle:
 name of the window, default None means that active window is going to be minimized

Example:


Open Using Run Dialog  calc     Calculator
Open Using Run Dialog  notepad  Untitled - Notepad
Minimize Dialog    # Current window (Notepad)
Minimize Dialog    Calculator

Mouse Click

Arguments

  • locator: str = None
  • x: int = 0
  • y: int = 0
  • off_x: int = 0
  • off_y: int = 0
  • image: str = None
  • method: str = locator
  • ctype: str = click
  • **kwargs

Mouse click locator, coordinates, or image

When using method locator,image or ocr mouse is clicked by default at center coordinates.

Click types are:

  • click normal left button mouse click
  • double
  • right
param locator:

element locator on active window

param x:

coordinate x on desktop

param y:

coordinate y on desktop

param off_x:

offset x (used for locator and image clicks)

param off_y:

offset y (used for locator and image clicks)

param image:

image to click on desktop

param method:

one of the available methods to mouse click, default "locator"

param ctype:

type of mouse click

param **kwargs:

System Message: WARNING/2 (<string>, line 20); backlink

Inline strong start-string without end-string.

these keyword arguments can be used to pass arguments to underlying Images library to finetune image template matching, for example. tolerance=0.5 would adjust image tolerance for the image matching

Example:


Mouse Click  method=coordinates  100   100
Mouse Click  CalculatorResults
Mouse Click  method=image  image=myimage.png  off_x=10  off_y=10  ctype=right
Mouse Click  method=image  image=myimage.png  tolerance=0.8

Mouse Click Coords

Arguments

  • x: int
  • y: int
  • ctype: str = click
  • delay_time: float = None

Click at coordinates on desktop

param x:horizontal coordinate on the windows to click
param y:vertical coordinate on the windows to click
param ctype:click type "click", "right" or "double", defaults to "click"
param delay:delay in seconds after, default is no delay

Example:


Mouse Click Coords  x=450  y=100
Mouse Click Coords  x=300  y=300  ctype=right
Mouse Click Coords  x=450  y=100  delay=5.0

Mouse Click Image

Arguments

  • template: str
  • off_x: int = 0
  • off_y: int = 0
  • ctype: str = click
  • **kwargs

Click at template image on desktop

param image:

image to click on desktop

param off_x:

horizontal offset from top left corner to click on

param off_y:

vertical offset from top left corner to click on

param ctype:

type of mouse click

param **kwargs:

System Message: WARNING/2 (<string>, line 7); backlink

Inline strong start-string without end-string.

these keyword arguments can be used to pass arguments to underlying Images library to finetune image template matching, for example. tolerance=0.5 would adjust image tolerance for the image matching

Example:


Mouse Click  image=myimage.png  off_x=10  off_y=10  ctype=right
Mouse Click  image=myimage.png  tolerance=0.8

Open Application

Arguments

  • application: str

Open application by dispatch method

This keyword is used to launch Microsoft applications like Excel, Word, Outlook and Powerpoint.

param application:
 name of the application as str
return:application instance id

Example:


${app1}    Open Application   Excel
${app2}    Open Application   Word

Open Dialog

Arguments

  • windowtitle: str = None
  • highlight: bool = False
  • timeout: int = 10
  • existing_app: bool = False

Open window by its title.

param windowtitle:
 name of the window, defaults to active window if None
param highlight:
 draw outline for window if True, defaults to False
param timeout:time to wait for dialog to appear

Example:


Open Dialog       Untitled - Notepad
Open Dialog       Untitled - Notepad   highlight=True   timeout=5

Open Executable

Arguments

  • executable: str
  • windowtitle: str
  • backend: str = None
  • work_dir: str = None

Open Windows executable. Window title name is required to get handle on the application.

param executable:
 name of the executable
param windowtitle:
 name of the window
param backend:set Windows backend, default None means using library default value
param work_dir:path to working directory, default None
return:application instance id

Example:


${app1}    Open Executable   calc.exe  Calculator

Open File

Arguments

  • filename: str

Open associated application when opening file

param filename:path to file
return:True if application is opened, False if not

Example:


${app1}    Open File   /path/to/myfile.txt

Open Using Run Dialog

Arguments

  • executable: str
  • windowtitle: str

Open application using Windows run dialog. Window title name is required to get handle on the application.

param executable:
 name of the executable
param windowtitle:
 name of the window
return:application instance id

Example:


${app1}    Open Using Run Dialog  notepad  Untitled - Notepad

Process Exists

Arguments

  • process_name: str
  • strict: bool = True

Check if process exists by its name

param process_name:
 search for this process
param strict:defines how match is made, default True which means that process name needs to be exact match and False does inclusive matching
return:process instance or False

Example:


${process}  Process Exists  calc
${process}  Process Exists  calc  strict=False

Put System To Sleep

Arguments

Put Windows into sleep mode

Example:


Put System To Sleep

Quit Application

Arguments

  • app_id: str = None
  • send_keys: bool = False

Quit an application by application id or active application if app_id is None.

param app_id:application_id, defaults to None

Example:


${app1}   Open Application   Excel
${app2}   Open Application   Word
Quit Application  ${app1}

Restore Dialog

Arguments

  • windowtitle: str = None

Restore window by its title

param windowtitle:
 name of the window, default None means that active window is going to be restored

Example:


Open Using Run Dialog  notepad  Untitled - Notepad
Minimize Dialog
Sleep             1s
Restore Dialog
Sleep             1s
Restore Dialog    Untitled - Notepad

Screenshot

Arguments

  • filename: str
  • element: dict = None
  • ctrl: typing.Any = None
  • desktop: bool = False
  • overwrite: bool = False

Save screenshot into filename.

param filename:name of the file
param element:take element screenshot, defaults to None
param ctrl:take control screenshot, defaults to None
param desktop:take desktop screenshot if True, defaults to False
param overwrite:
 file is overwritten if True, defaults to False

Example:


@{element}   Find Element  CalculatorResults
Screenshot   element.png   ${elements[0][0]}
Screenshot   desktop.png   desktop=True
Screenshot   desktop.png   desktop=True  overwrite=True

Send Keys

Arguments

  • keys: str

Send keys into active windows.

param keys:list of keys to send

Example:


Open Executable  calc.exe  Calculator
Send Keys        2{+}3=

Send Keys To Input

Arguments

  • keys_to_type: str
  • with_enter: bool = True
  • send_delay: float = 0.5
  • enter_delay: float = 1.5

Send keys to windows and add ENTER if with_enter is True

At the end of send_keys there is by default 0.5 second delay. At the end of ENTER there is by default 1.5 second delay.

param keys_to_type:
 keys to type into Windows
param with_enter:
 send ENTER if with_enter is True
param send_delay:
 delay after send_keys
param enter_delay:
 delay after ENTER

Example:


${txt}    Get Spaced String   My name is Bond, James Bond
Send Keys To Input  ${txt}    with_enter=False
Send Keys To Input  {ENTER}THE   send_delay=5.0  with_enter=False
Send Keys To Input  {VK_SPACE}-{VK_SPACE}END   enter_delay=5.0

Set Windows Backend

Arguments

  • backend: str

Set Windows backend which is used to interact with Windows applications

Allowed values defined by SUPPORTED_BACKENDS

param backend:name of the backend to use

Example:


Set Windows Backend   uia
Open Executable   calc.exe  Calculator
Set Windows Backend   win32
Open Executable   calc.exe  Calculator

Switch To Application

Arguments

  • app_id: int

Switch to application by id.

param app_id:application's id
raises ValueError:
 if application is not found by given id

Example:


${app1}    Open Application   Excel
${app2}    Open Application   Word
Switch To Application   ${app1}

Type Into

Arguments

  • locator: str
  • keys: str
  • empty_field: bool = False

Type keys into element matched by given locator.

param locator:element locator
param keys:list of keys to type

Example:


Open Executable  calc.exe  Calculator
Type Into        CalculatorResults  11
Type Into        CalculatorResults  22  empty_field=True

Type Keys

Arguments

  • keys: str

Type keys into active window element.

param keys:list of keys to type

Example:


Open Executable  notepad.exe  Untitled - Notepad
Type Keys   My text

Wait For Element

Arguments

  • locator: str
  • search_criteria: str = None
  • timeout: float = 30.0
  • interval: float = 2.0

Wait for element to appear into the window.

Can return 1 or more elements matching locator, or raises ElementNotFoundError if element is not found within timeout.

param locator:name of the locator
param search_criteria:
 criteria by which element is matched
param timeout:defines how long to wait for element to appear, defaults to 30.0 seconds
param interval:how often to poll for element, defaults to 2.0 seconds (minimum is 0.5 seconds)

Example:


@{elements}  Wait For Element  CalculatorResults
@{elements}  Wait For Element  Results   timeout=10  interval=1.5