Skip to main content


Command Description

Usually a specified target element is a unique parent element, while the parent element has its own parent element, until the top of the parent element (ie, the desktop), so that the specified parent element layer and the unique parent element, Return the result is a memory address object

Command Prototype

objElement = UiElement.GetParent(objUiElement,upLevels,optionArgs)

Parameter Description

objUiElementTruedecorator@ui""Specifie the target elements of Get Parent Element
upLevelsTruenumber1The layer of parent element is set to be 1 by default, referring to the direct parent element. When the layer is set to be 2, the grandparent element will be obtained. And when the layer is set to be 3, the great-grandparent. The rest can be done in the same manner. When the parent element layer exceeds the topmost element (desktop) or the parent element layer ≤ 0, the obtained parent element will be the desktop
bContinueOnErrorNonebooleanNoneSpecify whether the automation should continue to support this field even if the activity is incorrect, it is only supported by the Boolean value (true, false) default value
iDelayAfterNonenumber300Delay time (in milliseconds) after executing the activity is 300 milliseconds
iDelayBeforeNonenumber200The delay time (in milliseconds) before any operations are executed is by default 200 milliseconds


objElement,The variable used to save the output of the command.


TracePrint "--------------------Get parent element--------------------" 
// --------------------------------------------------------
// [Remarks] Get the parent element, this Demo gets the parent element of the Baidu homepage search box element
// Input parameter 1:
// objUiElement--target element
// Input parameter 2:
// upLevels--parent element level
// Input parameter 3:
// optionArgs--optional parameters (including: error continue execution/delay after execution/delay before execution).Type:Dict

// Output parameters:
// objElement--The variable to which the output of the function call is saved

// Command prototype: objElement = UiElement.GetParent(objUiElement,upLevels,optionArgs)
// --------------------------------------------------------

objElement = UiElement.GetParent(@ui"input control<input>4",1,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})