Skip to main content

Determine-If-Text-Exists

Command Description

Find the text in the specified element.True = exists.False = not exists

Command Prototype

bRet = Text.Exists(objUiElement,sText,iRule,iOccurrence,iTimeOut,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
objUiElementTruedecorator@ui""To find the parent element of the text, the program conducts "find text" within this element. When the property is passed as a string, the child element is looked up as a feature string. When the property is passed as an UiElement, the lookup is directly done in the UiElement. When the property is passed as null, the lookup is done in all windows
sTextTruestring""The text used for finding elements
iRuleTrueenum"instr"The rule used for finding text
iOccurrenceTruenumber1If the string in the Text field appears multiple times in the indicated UI element, specify the number of occurrences to click, for example, if the string appears 4 times and you want to click the first match, please Write 1 in this field
iTimeOutTruenumber10000Specify the amount of time (in milliseconds) that wait for the event to run before selectorNotFoundException to trigger an error (in milliseconds) The default value is 10,000 ms (10 seconds)
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
bSetForegroundNonebooleanTrueWhether to activate the target window before executing

return

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

Demo

TracePrint("--------------------------Determine whether the text exists ----------------- ----------") 
//-------------------------------------------------------------------------------
//[Remarks] Find text in the specified element, return true if the text exists, otherwise return false
//Input parameter 1:
// objUiElement--Identifies the target. Note: If you need to find the parent element of the text, the program will search for the text operation in this element. When the attribute is passed as string type, it will search for the interface element as a feature string and then search for child elements. When the attribute is passed as UiElement type , lookup directly in this UiElement element, if passed as null, lookup in all windows
// sText--The text that needs to be found in the target. Note: Text to use when finding elements
// iRule--find rules. Note: Rules to use when looking for text
// iOccurrence--similar result location. Note: If the string in the Text field appears multiple times in the indicated interface element, specify the number of occurrences to click here. For example, if the string appears 4 times and you want to click on the first occurrence, write 1 in this field
// iTimeOut--timeout time (milliseconds). Note: Specifies the time (in milliseconds) to wait to retry to find screen extents before throwing an error. Default 30000 milliseconds (30 seconds)
// optionArgs--Optional parameters. Note: This parameter is a number of optional parameters, including error continue execution, delay after execution, delay before execution, activation window, cursor position, abscissa offset, ordinate offset, auxiliary keys, operation type
//out parameters:
// bRet--The variable to which the output of the function call is saved.
//
//Command Prototype:bRet = Text.Exists(objUiElement,sText,iRule,iOccurrence,iTimeOut,optionArgs)
bRet = Text.Exists(@ui"Block-level element <div>_Exists to determine whether the text exists Command Description Find text in the specified element, return true if the text exists, ","text","instr",1,10000, {"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"bSetForeground":true})
TracePrint(bRet)