How to Expand/Collapse Tree item.
Q7, 21.08.2013 by Ulyana Skorokhodova
We always want Q7 tests to be easy-readable and laconic. That’s why we didn’t what to overweight it with “intermediate” user actions which are not followed by a resulting action (like mouse-movements or tree expanding). In the most use cases tree expanding/collapsing are not the subject of testing so Q7 records only the result (e.g. item selection), automatically expanding a tree.
But in some cases we may need to specify expand/collapse state of a tree.
In Q7 we have 4 ECL commands which can be used for this purpose:
Let’s say we have Project1 and Project2 containing some files and folders.
To Expand all tree items we need to use expand-all
So the result is:
Note: you should be careful with applying expand-all
command to Java Projects (or to any item with a huge amount of nesting items) – it can make your application hang.
Similarly, to collapse all items collapse-all
should be used:
So we come back to an initial state:
To expand all children and sub-children of a specific item use get-item | expand-all
Project1 is expanded:
These commands are used if you need to expand/collapse an item only not affecting its children.
Project1 is expanded only (Folder A stays collapsed):
Let’s say we have Project1 and all its children expanded. Collapse
command being applied to Project1 collapses Project1 only leaving its children expanded. So when you expand Project1 next time – all children state remains the same, as it was before collapsing.
Expand Project1 (all children stayed expanded):