Webinar

November 3rd, 2021 12:00 PM EDT
Automation for Field Services & DistributionNovember 3rd, 2021 12:00 PM EDT
Learn how creating a digital workforce can improve your supply chain processes!

Boot Time In Seconds From Epoch

Get machine boot time

return:boot time in seconds from Epoch

Examples

*** Tasks ***
${epoch}  Boot Time In Seconds From Epoch

Calculate Rectangle Center

Calculate x and y center coordinates from rectangle.

Arguments

Argument Type Default value Description
rectangleAnynull
param rectangle:
 element rectangle coordinates
return:x and y coordinates of rectangle center

Examples

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

Click Type

Mouse click on coordinates x and y.

Arguments

Argument Type Default value Description
xint, NoneNone
yint, NoneNone
click_typestrclick

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

Examples

*** Tasks ***
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

Close all applications

Examples

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

Connect By Handle

Connect to application by its handle

Arguments

Argument Type Default value Description
handleintnull
windowtitlestr, NoneNone
existing_appboolFalse
param handle:handle of the application
param windowtitle:
 name of the window, defaults to active window if None
param existing_app:
 set True if selecting window which library has already accessed, default False

Examples

*** Tasks ***
${appid}  Connect By Handle  88112

Connect By Pid

Connect to application by its pid

Arguments

Argument Type Default value Description
app_pidstrnull
windowtitlestr, NoneNone
param app_pid:process id of the application
param windowtitle:
 name of the window, defaults to active window if None

Examples

*** Tasks ***
${appid}  Connect By PID  3231

Drag And Drop

Drag elements from source and drop them on target.

Arguments

Argument Type Default value Description
srcAnynull
targetAnynull
src_locatorstrnull
target_locatorstr, NoneNone
handle_ctrl_keyboolFalse
drop_delayfloat2.0
originstrmiddle

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

Examples

*** Tasks ***
${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

Find element from window by locator and criteria.

Arguments

Argument Type Default value Description
locatorstrnull
search_criteriastr, NoneNone
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

Examples

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

Get App

Get application object by id

Arguments

Argument Type Default value Description
app_idint, NoneNone

By default returns active_application application object.

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

Examples

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

Get Boot Time

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

Arguments

Argument Type Default value Description
as_datetimeboolFalse
datetime_formatstr%Y-%m-%d %H:%M:%S
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

Examples

*** Tasks ***
${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

Get dialog rectangle coordinates

Arguments

Argument Type Default value Description
ctrlAny, NoneNone
as_dictboolFalse

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

Examples

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

Get Element

Get element by locator.

Arguments

Argument Type Default value Description
locatorstrnull
screenshotboolFalse
open_dialogboolTrue
param locator:name of the locator
param screenshot:
 takes element screenshot if True, defaults to False
param open_dialog:
 True if dialog should be reopened, default to True
return:element if element was identified, else False

Examples

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

Get Element Center

Get element center coordinates

Arguments

Argument Type Default value Description
elementdictnull
param element:dictionary of element items
return:coordinates, x and y

Examples

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

Get Element Rectangle

Get value of element `rectangle` attribute.

Arguments

Argument Type Default value Description
locatorstrnull
as_dictboolFalse

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

Examples

*** Tasks ***
${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

Get value of element `rich text` attribute.

Arguments

Argument Type Default value Description
locatorstrnull

Get value of element rich text attribute.

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

Examples

*** Tasks ***
${text}  Get Element Rich Text  CalculatorResults

Get Machine Name

Get machine name

return:machine name as string

Examples

*** Tasks ***
${machine}  Get Machine Name

Get Memory Stats

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

Arguments

Argument Type Default value Description
humanizedboolTrue

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

Examples

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

Get Open Applications

Get list of all open applications

Returns a dictionary

Examples

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

Get Spaced String

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

Arguments

Argument Type Default value Description
textnull

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

param text:replace spaces in this string

Examples

*** Tasks ***
${txt}    Get Spaced String   My name is Bond
# ${txt} = My{VK_SPACE}name{VK_SPACE}is{VK_SPACE}Bond
Send Keys To Input  ${txt}

Get Text

Get text from element

Arguments

Argument Type Default value Description
locatorstrnull
param locator:element locator

Examples

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

Get Username

Get username of logged in user

return:username as string

Examples

*** Tasks ***
${user}  Get Username

Get Window Elements

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

Arguments

Argument Type Default value Description
screenshotboolFalse
element_jsonboolFalse
outlineboolFalse

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

Examples

*** Tasks ***
@{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

Get list of open windows

Window dictionaries contain:

  • automation_id
  • control_id
  • title
  • pid
  • handle
  • is_active
  • keyboard_focus
  • rectangle
return:list of window dictionaries

Examples

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

Is Element Enabled

Is element enabled.

Arguments

Argument Type Default value Description
locatorstrnull
param locator:element locator
return:True if enabled, else False

Examples

*** Tasks ***
${res}=   Is Element Enabled  CalculatorResults

Is Element Matching

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

Arguments

Argument Type Default value Description
itemdictdictnull
locatorstrnull
criteriastrnull
wildcardboolFalse

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

Is element visible.

Arguments

Argument Type Default value Description
locatorstrnull
param locator:element locator
return:True if visible, else False

Examples

*** Tasks ***
${res}=   Is Element Visible  CalculatorResults

Kill Process

Kill process by name

Arguments

Argument Type Default value Description
process_namestrnull
param process_name:
 name of the process
return:True if succeeds False if not

Examples

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

Kill Process By Pid

Kill process by pid

Arguments

Argument Type Default value Description
pidintnull
param pid:process identifier

Examples

*** Tasks ***
${process}  Process Exists  calc  strict=False
${status}   Kill Process By PID   ${process.pid}

Lock Screen

Put windows into lock mode

Examples

*** Tasks ***
Lock Screen

Log In

Log into Windows `domain` with `username` and `password`.

Arguments

Argument Type Default value Description
usernamestrnull
passwordstrnull
domainstr.

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

Examples

*** Tasks ***
Log In  username=myname  password=mypassword  domain=company

Minimize Dialog

Minimize window by its title

Arguments

Argument Type Default value Description
windowtitlestr, NoneNone
param windowtitle:
 name of the window, default None means that active window is going to be minimized

Examples

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

Mouse Click

Mouse click `locator`, `coordinates`, or `image`

Arguments

Argument Type Default value Description
locatorstr, NoneNone
xint0
yint0
off_xint0
off_yint0
imagestr, NoneNone
methodstrlocator
ctypestrclick
focusstrcenter
toleranceint, NoneNone

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 focus:default point for element click is 'center', can be set to 'topleft' to click top left corner of the element
param tolerance:
 image matching tolerance between 0 and 1

Examples

*** Tasks ***
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
${elements}  ${other}=     Find Element  class:Button
FOR  ${element}  IN  @{elements}
    Run Keyword If   ${element}[visible]   Mouse Click  ${element}
END
Mouse Click  id:TrickyCheckbox  focus=topleft

Mouse Click Coords

Click at coordinates on desktop

Arguments

Argument Type Default value Description
xintnull
yintnull
ctypestrclick
delay_timefloat, NoneNone
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

Examples

*** Tasks ***
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

Click at template image on desktop

Arguments

Argument Type Default value Description
templatestrnull
off_xint0
off_yint0
ctypestrclick
tolerancefloat, NoneNone
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 tolerance:
 matching tolerance between 0 and 1

Examples

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

Open Application

Open application by dispatch method

Arguments

Argument Type Default value Description
applicationstrnull

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

Examples

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

Open Dialog

Open window by its title.

Arguments

Argument Type Default value Description
windowtitlestr, NoneNone
highlightboolFalse
timeoutint10
existing_appboolFalse
wildcardboolFalse
param windowtitle:
 name of the window, defaults to active window if None
param highlight:
 draw outline for window if True, default False
param timeout:time to wait for dialog to appear
param existing_app:
 set True if selecting window which library has already accessed, default False
param wildcard:set True for inclusive window title search, default False

Examples

*** Tasks ***
Open Dialog       Untitled - Notepad
Open Dialog       Untitled - Notepad   highlight=True   timeout=5
Open Dialog       Notepad   wildcard=True

Open Executable

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

Arguments

Argument Type Default value Description
executablestrnull
windowtitlestrnull
backendstr, NoneNone
work_dirstr, NoneNone
wildcardboolFalse

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
param wildcard:set True for inclusive window title search, default False
return:application instance id

Examples

*** Tasks ***
${app1}    Open Executable   calc.exe  Calculator
${app2}    Open Executable   notepad.exe  Notepad   wildcard=True

Open File

Open associated application when opening file

Arguments

Argument Type Default value Description
filenamestrnull
windowtitlestr, NoneNone
wildcardboolFalse
timeoutint10

Keyword Open Dialog is used if windowtitle is given.

param filename:path to file
param windowtitle:
 name of the window
param wildcard:set True for inclusive window title search, default False
param timeout:time to wait for dialog to appear
return:application id or None

Examples

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

Open Using Run Dialog

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

Arguments

Argument Type Default value Description
executablestrnull
windowtitlestrnull
timeoutint10
wildcardboolFalse

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
param timeout:time to wait for dialog to appear
param wildcard:set True for inclusive window title search, default False
return:application instance id

Examples

*** Tasks ***
${app1}    Open Using Run Dialog  notepad  Untitled - Notepad
${app2}    Open Using Run Dialog  notepad  Notepad    wildcard=True

Process Exists

Check if process exists by its name

Arguments

Argument Type Default value Description
process_namestrnull
strictboolTrue
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

Examples

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

Process Id Exists

Check if process exists by its id

Arguments

Argument Type Default value Description
pidintnull
param pid:process identifier
return:process instance or False

Examples

*** Tasks ***
${process}  Process ID Exists  4567
Run Keyword If   ${process}  Log  Process exists

Put System To Sleep

Put Windows into sleep mode

Examples

*** Tasks ***
Put System To Sleep

Quit Application

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

Arguments

Argument Type Default value Description
app_idstr, NoneNone
send_keysboolFalse

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

param app_id:application_id, defaults to None
param send_keys:
 if ALT+F4 should be used to quit, default False

Examples

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

Refresh Window

Get controls and elements for current windows.

Should be called always when window content changes on Windows desktop.

return:controls (list) and elements (list)

Restore Dialog

Restore window by its title

Arguments

Argument Type Default value Description
windowtitlestr, NoneNone
param windowtitle:
 name of the window, default None means that active window is going to be restored

Examples

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

Screenshot

Save screenshot into filename.

Arguments

Argument Type Default value Description
filenamestrnull
elementdict, NoneNone
ctrlAny, NoneNone
desktopboolFalse
overwriteboolTrue
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:
 overwrite existing image (deprecated, always True)

Examples

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

Send Keys

Send keys into active windows.

Arguments

Argument Type Default value Description
keysstrnull
param keys:list of keys to send

Examples

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

Send Keys To Input

Send keys to windows and add ENTER if `with_enter` is True

Arguments

Argument Type Default value Description
keys_to_typestrnull
with_enterboolTrue
send_delayfloat0.5
enter_delayfloat1.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

Examples

*** Tasks ***
${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 Automation Speed

Set global automation timings

Arguments

Argument Type Default value Description
speedSpeedDEFAULT
param speed:possible values 'default', 'fast' or 'slow'

Set Windows Backend

Set Windows backend which is used to interact with Windows applications

Arguments

Argument Type Default value Description
backendstrnull

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

Examples

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

Switch To Application

Switch to application by id.

Arguments

Argument Type Default value Description
app_idintnull
param app_id:application's id
raises ValueError:
 if application is not found by given id

Examples

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

Type Into

Type keys into element matched by given locator.

Arguments

Argument Type Default value Description
locatorstrnull
keysstrnull
empty_fieldboolFalse
param locator:element locator
param keys:list of keys to type
param empty_field:
 if field should be emptied before typing, default False

Examples

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

Type Keys

Type keys into active window element.

Arguments

Argument Type Default value Description
keysstrnull
param keys:list of keys to type

Examples

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

Wait For Element

Wait for element to appear into the window.

Arguments

Argument Type Default value Description
locatorstrnull
search_criteriastr, NoneNone
timeoutfloat30.0
intervalfloat2.0

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)

Examples

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