public class PCTree extends Tree
Historically, the algorithm used here and in the ProcessContainer classes was intended to mirror the algorithm used by earlier versions of SQA Robot a.k.a Rational Robot. In this way, recognition strings that would work for Robot would also work in other testing tools that might be used simultaneously. This allowed one App Map to work for all testing tools involved.
However, more recent versions of Robot have introduced large and critical departures from the traditional algorithm in different environments. For example, the .Net support in Robot has introduced a completely different algorithm for object recognition that is inconsistent with previous versions of Robot and other environments supported by Robot.
Consequently, the algorithm here is no longer guaranteed to mirror these later versions of Robot recognition algorithms. Instead, we will stick with this single, fairly well-defined algorithm that should provide consistency and interoperability for all current and future SAFS engines EXCEPT for later versions of IBM's Rational Robot in certain environments (like later versions of .NET).
The tradional algorithm:
For a type, a child will increment the index, depth first, a sibling will also increment the index, breadth second.
example:
1 | _________2___________ \ \ ___3________ ___4_________ / /\ \ \ / /\ \ \ 4 5 7 9 10 5 6 8 10 11 / \ / \ 6 8 7 9 / \ / \ text1,2 text3,4 text5,6 text7,8
Items with onlyOneChildVisible like TabControls are an exception, because their immediate child containers share the same space and are not all visible
example:
1 | _________2____________________________________ \ \ TabControl ___4________ \ \____tabN______ / /\ \ \ \ \ / / \ \ \ visible not-visible 5 6 8 10 11 ___3________ ___3________ / \ / /\ \ \ / /\ \ \ 7 9 4 5 7 9 10 4 5 7 9 10 / \ / \ / \ text5,6 text7,8 6 8 6 8 / \ / \ text1,2 text3,4 text1 text2Same app with TabControl with different Tab visible:
1 | _________2____________________________________ \ \ TabControl ___4________ \ \____tabN______ / /\ \ \ \ \ / / \ \ \ not-visible visible 5 6 8 10 11 ___3________ ___3________ / \ / /\ \ \ / /\ \ \ 7 9 4 5 7 9 10 4 5 7 9 10 / \ / \ / \ text3,4 text5,6 6 8 6 8 / \ / \ text1,2 text3,4 text1 text2 clicking on yet a another tab may find: 1-2--TabControl \ 3 / table1Note how all containers immediately under each tab start with the same index. In other words, the sibling breadth layer does not increment the index. This is because at any given time only one pane will be visible and it will always be found at Index=3 (given the example above).There are known shortcomings to this algorithm. Most notable is the changing indices of components shown in the rightmost Panel #4 when different Tabs are selected in the TabControl. Alternative algorithms may be used in later releases allowing the user to choose between using the traditional algorithm, and any new one.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
captionPart |
static java.lang.String |
classIndexPart |
static java.lang.String |
classPart |
static java.lang.String |
idPart |
static java.lang.String |
indexPart |
static java.lang.String |
namePart |
static java.lang.String |
partSeparator |
static java.lang.String |
pathPart |
static java.lang.String |
processName |
static java.lang.String |
recogSeparator |
static java.lang.String |
textPart |
static int |
totalChildCountWithCommentsAndBlankLines |
static java.lang.String |
typePart |
EQUAL_SEPARATOR, PATH_SEPARATOR
Constructor and Description |
---|
PCTree() |
Modifier and Type | Method and Description |
---|---|
boolean |
doAppendCompInfo()
Return TRUE if we are to append CompType info to output recognition strings.
|
protected java.lang.String |
generateMapKey(java.lang.String prefix,
java.lang.String value)
Generate a key to be used for map
idNameIndexMap |
protected java.lang.String |
getAppendedCompInfo() |
protected java.lang.String |
getBlankLine()
Output a blank line and 'Child of' information if the parent control has onlyOneChildVisible
(like TabControls).
|
java.lang.String |
getClassAbsIndex()
Get absolute class index return from engine (use for RFSM mode)
|
java.util.Map |
getCompMap() |
java.lang.String |
getComponentRecogString(boolean includeParentPart)
generate recognition string for the PCTree on this level.
|
java.lang.String |
getDefaultRecognition()
Return any defaultRecognition set.
|
java.lang.String |
getDomainName() |
protected java.lang.String |
getHeader()
Output header String (like '[windowname]'), if isContainerTypesUsedToSetupIndexMap.
|
java.lang.String |
getId() |
java.lang.String[] |
getIndex_types() |
java.lang.String |
getIndex_typesIndex(int index) |
protected int |
getIndex()
Get index, first try using the 'indexMap' setup with setupCompIndex, then try getIndexOld
|
protected int |
getIndex(java.lang.String type)
if type equals our type, return getIndex()+1, basically incrementing any previous index
for a component of the same type.
|
protected int |
getIndexBase()
Generate base index based on this algorithm:
getting our matching index based on all of our siblings, and our position.
|
protected int |
getIndexOld()
Generate index based on this algorithm:
First get a starting index by asking our parent for an index for the type.
|
boolean |
getIndexOnly() |
java.lang.String |
getMyclass() |
java.lang.String |
getName() |
java.lang.String |
getNameValue() |
java.lang.String |
getObjectClass() |
PCTree |
getParent() |
protected java.lang.String |
getParentRecogString()
Recursively get all of the parent->parent->...
|
java.lang.String |
getPath() |
protected int |
getPathIndex()
(Future) Currently ALWAYS returns 0
|
protected java.lang.String |
getRecogString(boolean origCallerIsParent)
Build the piece of the recognition string that represents this component only.
|
protected java.lang.String |
getRFSMRecogString(boolean origCallerIsParent)
Build the piece of RFSM the recognition string that represents this component only.
|
int |
getSiblingIndex() |
int |
getTotalChildCountFromFirstChild()
Calculate the total child count of all children of this component.
|
java.lang.String |
getType() |
protected boolean |
ignoreParentRecognitionString(PCTree aparent) |
boolean |
isCaption() |
boolean |
isClassIndex() |
boolean |
isComponentVisible() |
boolean |
isFullPathSearchMode() |
boolean |
isIgnoredNode()
See if this node can be ignored according to 'shortenGeneralRecognition'.
|
boolean |
isMappedClassSearchMode() |
boolean |
isOnlyOneChildVisible() |
boolean |
isRfsmSearchMode() |
boolean |
isShortenGeneralRecognition() |
boolean |
isTextValue() |
boolean |
isWithCommentsAndBlankLines() |
boolean |
isWithNameIncludeOnlyCaption() |
static void |
main(java.lang.String[] args)
For testing only.
|
static java.lang.String |
removeNonNameChars(java.lang.String text)
Remove most typical non-alphanumeric characters from the provided text.
|
static java.lang.String |
removeNonNameChars(java.lang.String text,
java.lang.String nextChar)
Remove all occurrences of nextChar from the text string.
|
void |
setAppendCompInfo(boolean appendCompInfo)
Set TRUE to append CompType info at the end of output recognition strings.
|
void |
setCaption(boolean caption)
Set true if the NameValue stored represents a components Caption= value.
|
void |
setClassAbsIndex(java.lang.String classAbsIndex)
Set absoulate class index
|
void |
setClassIndex(boolean classIndex)
Set true if the index stored for this component is considered to be a ClassIndex
index instead of the normal object type index.
|
void |
setCompMap(java.util.Map compMap)
Set the Map object that holds the PCTrees for
all objects encountered up to this point in the object hierarchy.
|
void |
setComponentVisible(boolean setVisible)
Set true if this component was visible at the time of processing.
|
void |
setDefaultRecognition(java.lang.String recog)
Usually only for the topmost parent, the recognition string provided by the user (or Process Container)
Can be null;
|
void |
setDomainName(java.lang.String domainName) |
void |
setFullPathSearchMode(boolean fullPathSearchMode) |
void |
setId(java.lang.String id) |
void |
setIndex_types(java.lang.String[] index_types) |
void |
setIndexOnly(boolean indexOnly) |
void |
setMappedClassSearchMode(boolean mappedClassSearchMode)
set if MappedClassSearchMode is to be used.
|
void |
setMyclass(java.lang.String myclass)
Sets the class for the represented component.
|
void |
setName(java.lang.String name)
Sets the user-friendly name deduced for the represented component by something like ProcessContainer.
|
void |
setNameValue(java.lang.String nameValue)
Sets the text associated with any Name=, Caption=, or Text= recognition string.
|
void |
setObjectClass(java.lang.String objectclass)
Sets the class for the represented component.
|
void |
setOnlyOneChildVisible(boolean onlyOneChildVisible)
Set true if this component, like TabControls, has multiple children, but only one is visible
at any given time.
|
void |
setParent(PCTree parent)
Set the parent PCTree object that represents the parent component of the component
represented by this PCTree object.
|
void |
setPath(java.lang.String path)
Set the Path= information that may exist for some components (like menuitems).
|
void |
setRfsmSearchMode(boolean rfsmSearchMode) |
void |
setShortenGeneralRecognition(boolean shorten)
Set true if recognition strings should be stripped of intermediate parent recognition
info that may be deemed unnecessary.
|
void |
setSiblingIndex(int siblingIndex)
Set the index of this sibling among all siblings.
|
void |
setTextValue(boolean textval)
Set true if the NameValue stored represents a components Text= value.
|
void |
setType(java.lang.String type)
Set the deduced component type for the represented component.
|
protected void |
setupIndexForIDName()
Set the absolute index for tree nodes who have the same ID or Name.
It will be called during the traversal of the whole tree. |
void |
setupIndexMap()
Setup the IndexMap values based on our described algorithm.
|
protected void |
setupIndexMap(int rdepth,
java.util.HashMap indexMap,
boolean onlyOneChildVisible,
java.util.HashMap altMap)
Setup the IndexMap values based on our described algorithm.
|
void |
setWithCommentsAndBlankLines(boolean withCommentsAndBlankLines)
Set true if output is to include comments and\or blank lines.
|
void |
setWithNameIncludeOnlyCaption(boolean withNameIncludeOnlyCaption)
Set true if recognition strings should be stripped of intermediate parent recognition
info that may be deemed unnecessary when we have a (uniquely) named target component.
|
java.lang.String |
toIniString() |
java.lang.String |
toIniStringWithoutIgnoredNodes() |
java.lang.String |
toString()
Output the PCTree
|
boolean |
updateName(java.lang.String oldName,
java.lang.String newName)
Update the tree node's name.
|
exactMatchPath, findMatchPath, getChildCount, getFirstChild, getLevel, getNextSibling, getSiblingCount, getUserObject, setChildCount, setFirstChild, setLevel, setNextSibling, setSiblingCount, setUserObject, toStringArray, toStringArrayWOSiblings
public static final int totalChildCountWithCommentsAndBlankLines
public static final java.lang.String recogSeparator
public static final java.lang.String typePart
public static final java.lang.String classPart
public static final java.lang.String partSeparator
public static final java.lang.String namePart
public static final java.lang.String captionPart
public static final java.lang.String indexPart
public static final java.lang.String pathPart
public static final java.lang.String textPart
public static final java.lang.String classIndexPart
public static final java.lang.String idPart
public static final java.lang.String processName
public boolean isRfsmSearchMode()
public void setRfsmSearchMode(boolean rfsmSearchMode)
set
- true if rfsmSearchMode is to be used.public boolean isFullPathSearchMode()
public void setFullPathSearchMode(boolean fullPathSearchMode)
set
- true if fullPathSearchMode is to be used.public boolean isMappedClassSearchMode()
public void setMappedClassSearchMode(boolean mappedClassSearchMode)
mappedClassSearchMode
- public void setDefaultRecognition(java.lang.String recog)
public java.lang.String getDefaultRecognition()
setDefaultRecognition(String)
public void setAppendCompInfo(boolean appendCompInfo)
public boolean doAppendCompInfo()
setAppendCompInfo(boolean)
public java.lang.String getId()
public void setId(java.lang.String id)
public boolean getIndexOnly()
public void setIndexOnly(boolean indexOnly)
public java.lang.String getName()
public boolean updateName(java.lang.String oldName, java.lang.String newName)
oldName
- newName
- public void setName(java.lang.String name)
public java.lang.String[] getIndex_types()
public java.lang.String getIndex_typesIndex(int index)
public void setIndex_types(java.lang.String[] index_types)
index_types
- the index_types to setpublic java.lang.String getType()
GuiClassData
public void setType(java.lang.String type)
GuiClassData
public java.lang.String getObjectClass()
public void setObjectClass(java.lang.String objectclass)
public java.lang.String getMyclass()
public void setMyclass(java.lang.String myclass)
public java.lang.String getNameValue()
public void setNameValue(java.lang.String nameValue)
public boolean isCaption()
public void setCaption(boolean caption)
public boolean isTextValue()
public void setTextValue(boolean textval)
public boolean isWithNameIncludeOnlyCaption()
public void setWithNameIncludeOnlyCaption(boolean withNameIncludeOnlyCaption)
public boolean isWithCommentsAndBlankLines()
public void setWithCommentsAndBlankLines(boolean withCommentsAndBlankLines)
public boolean isShortenGeneralRecognition()
public void setShortenGeneralRecognition(boolean shorten)
public boolean isOnlyOneChildVisible()
public void setOnlyOneChildVisible(boolean onlyOneChildVisible)
public boolean isComponentVisible()
public void setComponentVisible(boolean setVisible)
public boolean isClassIndex()
public void setClassIndex(boolean classIndex)
public java.lang.String getClassAbsIndex()
public void setClassAbsIndex(java.lang.String classAbsIndex)
classAbsIndex
- public int getSiblingIndex()
public void setSiblingIndex(int siblingIndex)
public java.lang.String getPath()
public void setPath(java.lang.String path)
public PCTree getParent()
public void setParent(PCTree parent)
public java.util.Map getCompMap()
public void setCompMap(java.util.Map compMap)
public void setDomainName(java.lang.String domainName)
public java.lang.String getDomainName()
protected java.lang.String getAppendedCompInfo()
protected java.lang.String getRecogString(boolean origCallerIsParent)
origCallerIsParent
- true if this component is the topmost parent window.getParentRecogString()
protected java.lang.String getRFSMRecogString(boolean origCallerIsParent)
origCallerIsParent
- true if this component is the topmost parent window.origCallerIsParent
- getParentRecogString()
protected int getIndex()
protected int getIndex(java.lang.String type)
type,
- String type (getType)protected int getIndexOld()
protected int getIndexBase()
protected void setupIndexMap(int rdepth, java.util.HashMap indexMap, boolean onlyOneChildVisible, java.util.HashMap altMap)
rdepth,
- int depth into the hierarchy as we recursively drill downindexMap,
- Map, used to keep the types with index appended (keys),the values are the PCTree instances themselves.onlyOneChildVisible,
- boolean, used to indicate containers like TabControlsaltMap,
- Map, alternate map cloned for siblings under containers like TabControls
with onlyOneChildVisibleprotected void setupIndexForIDName()
protected java.lang.String generateMapKey(java.lang.String prefix, java.lang.String value)
idNameIndexMap
prefix
- String, the key prefix, like NAME_INDEX_PREFIX
or ID_INDEX_PREFIX
value
- String, the object's name or object's idsetupIndexForIDName()
public void setupIndexMap()
Note: This version calls the other 'protected' version, which uses recursion, and passes 'false' for the parameter 'onlyOneChildVisible' Note: All of the top level siblings are split out into separate calls if they are of type 'Window' or 'JavaWindow' using separate HashMaps
protected int getPathIndex()
public java.lang.String toString()
protected boolean ignoreParentRecognitionString(PCTree aparent)
aparent
- #containerTypesIgnoredForRecognition
,
#containerNamesIgnoredForRecognition
,
GuiObjectRecognition.containerClassesIgnoredForRecognition
protected java.lang.String getParentRecogString()
Other items which modify the completeness or format of the recognition information include:
getRecogString(boolean)
protected java.lang.String getHeader()
protected java.lang.String getBlankLine()
public int getTotalChildCountFromFirstChild()
public java.lang.String toIniString()
public java.lang.String toIniStringWithoutIgnoredNodes()
public boolean isIgnoredNode()
public java.lang.String getComponentRecogString(boolean includeParentPart)
includeParentPart
- public static void main(java.lang.String[] args)
infilename,
- Stringoutfilename,
- Stringpublic static java.lang.String removeNonNameChars(java.lang.String text)
text,
- Stringpublic static java.lang.String removeNonNameChars(java.lang.String text, java.lang.String nextChar)
text,
- StringnextChar,
- String of one characterCopyright © SAS Institute. All Rights Reserved.