def find_element(
locator: Union[_Locator, str],
locator_variables: dict = {},
window_mode: Literal["auto", "topmost", "noaction"] = WindowMode.Auto
) -> UiElement
Return the UI element defined by the given locator.
Remarks: An alias method ui() is equivalent to clicknium.find_element().
Parameters:
locator[Required]: str | _Locator
locator string, the visit path of locator for target UI element, eg: ‘locator.chrome.bing.search_sb_form_q’, locator store is chrome, and locator name is search_sb_form_q. For more details, please refer to Locator.
locator_variables: dict
locator variables, set to initialize parameters in locator, eg: { "row": 1, "column": 1}
.
More about variables, please refer to Parametric Locator.
window_mode: WindowMode
It defines whether to set the UI element’s parent window to topmost before an action is invoked.
auto
: default value, set the window to topmost by default.
topmost
: always set the window to topmost
noaction
: doing nothing for topmost mode
Returns: The first matched UI element with type UiElement.
Example:
from clicknium import clicknium as cc, locator, ui
searchBox = cc.find_element(locator.chrome.bing.search_sb_form_q)
#or
searchBox = ui(locator.chrome.bing.search_sb_form_q)
#parametric locator
variables = {"name":"test"}
searchBox = ui(locator.chrome.bing.search_sb_form_q, variables)