Boot Time In Seconds From Epoch

Get machine boot time

return:boot time in seconds from Epoch

Examples

${epoch}  Boot Time In Seconds From Epoch

Calculate Rectangle Center

Calculate x and y center coordinates from rectangle.

Arguments

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

Examples

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, NoneNonehorizontal coordinate for click, defaults to None
yint, NoneNonevertical coordinate for click, defaults to None
click_typestrclick"click", "right" or "double", defaults to "click"

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

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

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
handleintnullhandle of the application
windowtitlestr, NoneNonename of the window, defaults to active window if None
existing_appboolFalseset True if selecting window which library has already accessed, default False
parse_elementsboolTrueset False to not to parse elements of the window, default True
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
param parse_elements:
 set False to not to parse elements of the window, default True

Examples

${appid}  Connect By Handle  88112

Connect By Pid

Connect to application by its pid

Arguments

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

Examples

${appid}  Connect By PID  3231

Drag And Drop

Drag elements from source and drop them on target.

Arguments

Argument Type Default value Description
srcAnynullapplication object or instance id
targetAnynullapplication object or instance id
src_locatorstrnullelements to move
target_locatorstr, NoneNone
handle_ctrl_keyboolFalseTrue if keyword should press CTRL down dragging
drop_delayfloat2.0how many seconds to wait until releasing mouse drop, default 2.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

${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
locatorstrnullname of the locator
search_criteriastr, NoneNonecriteria by which element is matched
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

@{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, NoneNoneid of the application to get, defaults to None

By default returns active_application application object.

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

Examples

${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_datetimeboolFalseif True returns datetime string, otherwise seconds, defaults to False
datetime_formatstr%Y-%m-%d %H:%M:%Sdatetime string format, defaults to "%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

${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, NoneNonename of the window control object, defaults to None
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

${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
locatorstrnullname of the locator
screenshotboolFalsetakes element screenshot if True, defaults to False
open_dialogboolTrueTrue if dialog should be reopened, default to True
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

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

Get Element Center

Get element center coordinates

Arguments

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

Examples

@{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
locatorstrnullelement locator
as_dictboolFalsereturn values in a dictionary, default False
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

${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
locatorstrnullelement locator
param locator:element locator
return:rich_text value if found, else False

Examples

${text}  Get Element Rich Text  CalculatorResults

Get Machine Name

Get machine name

return:machine name as string

Examples

${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
humanizedboolTrueif False returns memory information in bytes, defaults to True
param humanized:
 if False returns memory information in bytes, defaults to True
return:memory information in dictionary format

Examples

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

Get Open Applications

Get list of all open applications

Returns a dictionary

Examples

${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
textnullreplace spaces in this string
param text:replace spaces in this string

Examples

${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
locatorstrnullelement locator
param locator:element locator

Examples

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

${user}  Get Username

Get Window Elements

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

Arguments

Argument Type Default value Description
screenshotboolFalsesave element screenshot if True, defaults to False
element_jsonboolFalsesave element json if True, defaults to False
outlineboolFalsehighlight elements if True, defaults to False
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

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

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

Is Element Enabled

Is element enabled.

Arguments

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

Examples

${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
locatorstrnullname of the locator
criteriastrnullcriteria on which to match element
wildcardboolFalsewhether to do reg exp match or not, default False
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
locatorstrnullelement locator
param locator:element locator
return:True if visible, else False

Examples

${res}=   Is Element Visible  CalculatorResults

Kill Process

Kill process by name

Arguments

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

Examples

${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
pidintnullprocess identifier
param pid:process identifier

Examples

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

Lock Screen

Put windows into lock mode

Examples

Lock Screen

Log In

Log into Windows domain with username and password.

Arguments

Argument Type Default value Description
usernamestrnullname of the user
passwordstrnullpassword of the user
domainstr.windows domain for the user, defaults to "."
param username:name of the user
param password:password of the user
param domain:windows domain for the user, defaults to "."
return:handle

Examples

Log In  username=myname  password=mypassword  domain=company

Minimize Dialog

Minimize window by its title

Arguments

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

Examples

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, NoneNoneelement locator on active window
xint0coordinate x on desktop
yint0coordinate y on desktop
off_xint0offset x (used for locator and image clicks)
off_yint0offset y (used for locator and image clicks)
imagestr, NoneNoneimage to click on desktop
methodstrlocatorone of the available methods to mouse click, default "locator"
ctypestrclicktype of mouse click
focusstrcenterdefault point for element click is 'center', can be set to 'topleft' to click top left corner of the element
toleranceint, NoneNoneimage matching tolerance between 0 and 1

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

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
xintnullhorizontal coordinate on the windows to click
yintnullvertical coordinate on the windows to click
ctypestrclickclick type "click", "right" or "double", defaults to "click"
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

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_xint0horizontal offset from top left corner to click on
off_yint0vertical offset from top left corner to click on
ctypestrclicktype of mouse click
tolerancefloat, NoneNonematching tolerance between 0 and 1
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

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
applicationstrnullname of the application as str

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

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

Open Dialog

Open window by its title.

Arguments

Argument Type Default value Description
windowtitlestr, NoneNonename of the window, defaults to active window if None
highlightboolFalsedraw outline for window if True, default False
timeoutint10time to wait for dialog to appear
existing_appboolFalseset True if selecting window which library has already accessed, default False
wildcardboolFalseset True for inclusive window title search, default False
parse_elementsboolTrueset False to not to parse elements of the window, default True
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
param parse_elements:
 set False to not to parse elements of the window, default True

Examples

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
executablestrnullname of the executable
windowtitlestrnullname of the window
backendstr, NoneNoneset Windows backend, default None means using library default value
work_dirstr, NoneNonepath to working directory, default None
wildcardboolFalseset True for inclusive window title search, default False
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

${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
filenamestrnullpath to file
windowtitlestr, NoneNonename of the window
wildcardboolFalseset True for inclusive window title search, default False
timeoutint10time to wait for dialog to appear

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

${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
executablestrnullname of the executable
windowtitlestrnullname of the window
timeoutint10time to wait for dialog to appear
wildcardboolFalseset True for inclusive window title search, default False
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

${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_namestrnullsearch for this process
strictboolTruedefines how match is made, default True which means that process name needs to be exact match and False does inclusive matching
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

${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
pidintnullprocess identifier
param pid:process identifier
return:process instance or False

Examples

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

Put System To Sleep

Put Windows into sleep mode

Examples

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_idint, NoneNoneapplication_id, defaults to None
send_keysboolFalseif ALT+F4 should be used to quit, default False
param app_id:application_id, defaults to None
param send_keys:
 if ALT+F4 should be used to quit, default False

Examples

${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, NoneNonename of the window, default None means that active window is going to be restored
param windowtitle:
 name of the window, default None means that active window is going to be restored

Examples

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
filenamestrnullname of the file
elementdict, NoneNonetake element screenshot, defaults to None
ctrlAny, NoneNonetake control screenshot, defaults to None
desktopboolFalsetake desktop screenshot if True, defaults to False
overwriteboolTrueoverwrite existing image (deprecated, always True)
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

@{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
keysstrnulllist of keys to send
param keys:list of keys to send

Examples

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_typestrnullkeys to type into Windows
with_enterboolTruesend ENTER if with_enter is True
send_delayfloat0.5delay after send_keys
enter_delayfloat1.5delay after ENTER

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

${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
speedSpeedDEFAULTpossible values 'default', 'fast' or 'slow'
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
backendstrnullname of the backend to use

Allowed values defined by SUPPORTED_BACKENDS

param backend:name of the backend to use

Examples

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_idintnullapplication's id
param app_id:application's id
raises ValueError:
 if application is not found by given id

Examples

${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
locatorstrnullelement locator
keysstrnulllist of keys to type
empty_fieldboolFalseif field should be emptied before typing, default False
param locator:element locator
param keys:list of keys to type
param empty_field:
 if field should be emptied before typing, default False

Examples

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
keysstrnulllist of keys to type
param keys:list of keys to type

Examples

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
locatorstrnullname of the locator
use_refreshingboolFalsewait for element(s) which are not there yet e.g. listbox item or popups, default False
search_criteriastr, NoneNonecriteria by which element is matched
timeoutfloat30.0defines how long to wait for element to appear, defaults to 30.0 seconds
intervalfloat2.0how often to poll for element, defaults to 2.0 seconds (minimum is 0.5 seconds)

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 use_refreshing:
 wait for element(s) which are not there yet e.g. listbox item or popups, default False
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

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