pywinauto_recorder.player.UIPath

class pywinauto_recorder.player.UIPath(relative_path=None, regex_title=False)[source]

Bases: object

UIPath is a context manager used to keep track of the current path in the UI tree.

Example of code not using a ‘UIPath’ object:
from pywinauto_recorder.player import click

click("Calculator||Window->*->Number pad||Group->One||Button")
click("Calculator||Window->*->Number pad||Group->Two||Button")

The code above clicks on two buttons. On each line that corresponds to a click operation, the whole path is repeated. A UIPath object will allow to factorize a common path where several operations will be performed.

The following code does the same as the previous example:

Example of code using a ‘UIPath’ object:
from pywinauto_recorder.player import UIPath, click

with UIPath("Calculator||Window"):
        click("*->Number pad||Group->One||Button")
        click("*->Number pad||Group->Two||Button")

UIPath objects can be nested.

The following code does the same as the previous example:

Example of code using nested ‘UIPath’ objects:
from pywinauto_recorder.player import UIPath, click

with UIPath("Calculator||Window"):
        with UIPath("*->Number pad||Group"):
                click("One||Button")
                click("Two||Button")

Methods

get_full_path([element_path])

If the element_path is None, return the full path of the current UI element

static get_full_path(element_path=None)[source]

If the element_path is None, return the full path of the current UI element

Parameters

element_path (Optional[UI_Path]) – Optional[UI_Path] = None

Return type

str

Returns

The full path of the element.