pywinauto.timings¶
Global timing settings for all of pywinauto
This module has one object that should be used for all timing adjustments:
- timings.Timings
There are a couple of predefined settings:
timings.Timings.fast()
timings.Timings.defaults()
timings.Timings.slow()
The Following are the individual timing settings that can be adjusted:
- window_find_timeout (default 5)
- window_find_retry (default .09)
- app_start_timeout (default 10)
- app_start_retry (default .90)
- app_connect_timeout (default 5.)
- app_connect_retry (default .1)
- cpu_usage_interval (default .5)
- cpu_usage_wait_timeout (default 20)
- exists_timeout (default .5)
- exists_retry (default .3)
- after_click_wait (default .09)
- after_clickinput_wait (default .09)
- after_menu_wait (default .1)
- after_sendkeys_key_wait (default .01)
- after_button_click_wait (default 0)
- before_closeclick_wait (default .1)
- closeclick_retry (default .05)
- closeclick_dialog_close_wait (default 2)
- after_closeclick_wait (default .2)
- after_windowclose_timeout (default 2)
- after_windowclose_retry (default .5)
- after_setfocus_wait (default .06)
- setfocus_timeout (default 2)
- setfocus_retry (default .1)
- after_setcursorpos_wait (default .01)
- sendmessagetimeout_timeout (default .01)
- after_tabselect_wait (default .05)
- after_listviewselect_wait (default .01)
- after_listviewcheck_wait default(.001)
- listviewitemcontrol_timeout default(1.5)
- after_treeviewselect_wait default(.1)
- after_toobarpressbutton_wait default(.01)
- after_updownchange_wait default(.1)
- after_movewindow_wait default(0)
- after_buttoncheck_wait default(0)
- after_comboboxselect_wait default(.001)
- after_listboxselect_wait default(0)
- after_listboxfocuschange_wait default(0)
- after_editsetedittext_wait default(0)
- after_editselect_wait default(.02)
- drag_n_drop_move_mouse_wait default(.1)
- before_drag_wait default(.2)
- before_drop_wait default(.1)
- after_drag_n_drop_wait default(.1)
- scroll_step_wait default(.1)
- class
pywinauto.timings.
TimeConfig
¶Central storage and manipulation of timing values
Defaults
(*args, **kwargs)¶
Fast
(*args, **kwargs)¶
Slow
(*args, **kwargs)¶
defaults
()¶Set all timings to the default time
fast
()¶Set fast timing values
Currently this changes the timing in the following ways: timeouts = 1 second waits = 0 seconds retries = .001 seconds (minimum!)
(if existing times are faster then keep existing times)
slow
()¶Set slow timing values
Currently this changes the timing in the following ways: timeouts = default timeouts * 10 waits = default waits * 3 retries = default retries * 3
(if existing times are slower then keep existing times)
- exception
pywinauto.timings.
TimeoutError
¶
pywinauto.timings.
always_wait_until
(timeout, retry_interval, value=True, op=<built-in function eq>)¶Decorator to call wait_until(...) every time for a decorated function/method
pywinauto.timings.
always_wait_until_passes
(timeout, retry_interval, exceptions=<class 'Exception'>)¶Decorator to call wait_until_passes(...) every time for a decorated function/method
pywinauto.timings.
timestamp
()¶Get a precise timestamp
pywinauto.timings.
wait_until
(timeout, retry_interval, func, value=True, op=<built-in function eq>, *args, **kwargs)¶Wait until
op(function(*args, **kwargs), value)
is True or until timeout expires
- timeout how long the function will try the function
- retry_interval how long to wait between retries
- func the function that will be executed
- value the value to be compared against (defaults to True)
- op the comparison function (defaults to equality)
- args optional arguments to be passed to func when called
- kwargs optional keyword arguments to be passed to func when called
Returns the return value of the function If the operation times out then the return value of the the function is in the ‘function_value’ attribute of the raised exception.
e.g.
try: # wait a maximum of 10.5 seconds for the # the objects item_count() method to return 10 # in increments of .5 of a second wait_until(10.5, .5, self.item_count, 10) except TimeoutError as e: print("timed out")
pywinauto.timings.
wait_until_passes
(timeout, retry_interval, func, exceptions=<class 'Exception'>, *args, **kwargs)¶Wait until
func(*args, **kwargs)
does not raise one of the exceptions
- timeout how long the function will try the function
- retry_interval how long to wait between retries
- func the function that will be executed
- exceptions list of exceptions to test against (default: Exception)
- args optional arguments to be passed to func when called
- kwargs optional keyword arguments to be passed to func when called
Returns the return value of the function If the operation times out then the original exception raised is in the ‘original_exception’ attribute of the raised exception.
e.g.
try: # wait a maximum of 10.5 seconds for the # window to be found in increments of .5 of a second. # P.int a message and re-raise the original exception if never found. wait_until_passes(10.5, .5, self.Exists, (ElementNotFoundError)) except TimeoutError as e: print("timed out") raise e.