com.ibm.team.fvt.tests.web
Class WebFolderElement

java.lang.Object
  extended by com.ibm.team.fvt.tests.web.WebPageElement
      extended by com.ibm.team.fvt.tests.web.WebElementWrapper
          extended by com.ibm.team.fvt.tests.web.WebFolderElement

public class WebFolderElement
extends WebElementWrapper

Class to handle a folder web element in a web page. A folder may contain multiple folders, which may be several levels deep.

Following API features are available on a folder:

Following internal features are available for a folder:


Constructor Summary
WebFolderElement(WebPage page, org.openqa.selenium.By elementBy, org.openqa.selenium.By expandBy, org.openqa.selenium.By expansionBy, org.openqa.selenium.By containerBy)
           
WebFolderElement(WebPage page, org.openqa.selenium.By elementBy, org.openqa.selenium.By expandBy, org.openqa.selenium.By expansionBy, org.openqa.selenium.By containerBy, WebFolderElement parentFolder)
           
WebFolderElement(WebPage page, WebBrowserElement element, org.openqa.selenium.By expandBy, org.openqa.selenium.By expansionBy, org.openqa.selenium.By containerBy)
           
WebFolderElement(WebPage page, WebBrowserElement element, org.openqa.selenium.By expandBy, org.openqa.selenium.By expansionBy, org.openqa.selenium.By containerBy, WebFolderElement parentFolder)
           
WebFolderElement(WebPage page, WebBrowserElement element, WebFolderElement parentFolder)
           
 
Method Summary
 void collapse()
          Collapse the folder.
 void expand()
          Expand the folder.
 WebFolderElement findFolder(java.lang.String folder)
          Search for a folder name in the tree.
 WebFolderElement findFolder(java.lang.String parentName, java.lang.String folder)
          Search for a folder name in the tree relatively to a given parent.
 java.util.List<WebFolderElement> getAllLeaves()
          Return all leaves of the current folder.
 java.util.List<java.lang.String> getAllLeavesPath()
          Return path for all leaves of the current folder.
 java.util.List<java.lang.String> getAllNodes()
          Return all nodes of the current folder.
 java.util.List<java.lang.String> getAllPaths()
          Deprecated. Since 5.0.1, use getAllLeavesPath() instead.
 java.util.List<WebFolderElement> getChildren()
          Returns the folder's children.
 java.util.List<java.lang.String> getChildrenNodes()
          Return children nodes of the current folder.
 WebFolderElement getFolder(java.lang.String folderPath)
          Gets the sub-folder for the given path.
 java.lang.String getPath()
          Returns the path of the current folder.
 java.lang.String getText()
          Return the text of the expandable element.
 WebFolderElement searchFolder(java.lang.String folder)
          Searches the folder with the given name in the hierarchy starting from current folder.
 void select()
          Select the folder.
 WebFolderElement selectFolder(java.lang.String folderPath)
          Selects the sub-folder for the given path.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebFolderElement

public WebFolderElement(WebPage page,
                        org.openqa.selenium.By elementBy,
                        org.openqa.selenium.By expandBy,
                        org.openqa.selenium.By expansionBy,
                        org.openqa.selenium.By containerBy)

WebFolderElement

public WebFolderElement(WebPage page,
                        org.openqa.selenium.By elementBy,
                        org.openqa.selenium.By expandBy,
                        org.openqa.selenium.By expansionBy,
                        org.openqa.selenium.By containerBy,
                        WebFolderElement parentFolder)

WebFolderElement

public WebFolderElement(WebPage page,
                        WebBrowserElement element,
                        org.openqa.selenium.By expandBy,
                        org.openqa.selenium.By expansionBy,
                        org.openqa.selenium.By containerBy)

WebFolderElement

public WebFolderElement(WebPage page,
                        WebBrowserElement element,
                        org.openqa.selenium.By expandBy,
                        org.openqa.selenium.By expansionBy,
                        org.openqa.selenium.By containerBy,
                        WebFolderElement parentFolder)

WebFolderElement

public WebFolderElement(WebPage page,
                        WebBrowserElement element,
                        WebFolderElement parentFolder)
Method Detail

collapse

public void collapse()
Collapse the folder.


expand

public void expand()
Expand the folder.


findFolder

public WebFolderElement findFolder(java.lang.String folder)
Search for a folder name in the tree.

The search is performed depth first.

Note that if there are several folders with the same name, then first found is returned.

Parameters:
folder - Name of the child folder to search
Returns:
The matching child folder as a WebFolderElement or null if current folder has no child with the given name.

findFolder

public WebFolderElement findFolder(java.lang.String parentName,
                                   java.lang.String folder)
Search for a folder name in the tree relatively to a given parent.

The search is performed depth first.

Note that if there are several folders with the same name, then first found is returned.

Parameters:
parentName - Name of the parent folder. Can be null.
folder - Name of the child folder to search
Returns:
The matching child folder as a WebFolderElement or null if current folder has no child with the given name.

getAllLeaves

public java.util.List<WebFolderElement> getAllLeaves()
Return all leaves of the current folder.

Returns:
All folder leaves as a List of WebFolderElement.

getAllLeavesPath

public java.util.List<java.lang.String> getAllLeavesPath()
Return path for all leaves of the current folder.

Returns:
All paths as a List of String.

getAllNodes

public java.util.List<java.lang.String> getAllNodes()
Return all nodes of the current folder.

Returns:
All nodes as a List of String.

getAllPaths

@Deprecated
public java.util.List<java.lang.String> getAllPaths()
Deprecated. Since 5.0.1, use getAllLeavesPath() instead.

Return path for all leaves of the current folder.

Returns:
All paths as a List of String.

getChildren

public final java.util.List<WebFolderElement> getChildren()
Returns the folder's children.

Returns:
The list of children as a List of WebFolderElement.

getChildrenNodes

public java.util.List<java.lang.String> getChildrenNodes()
Return children nodes of the current folder.

Returns:
Children nodes as a List of String.

getFolder

public WebFolderElement getFolder(java.lang.String folderPath)
Gets the sub-folder for the given path. If path has several segments, then the search occurs recursively through sub-folders levels to match each segment of the given path.

For example, "JKE Banking/JKE Enterprise Project/Business Goals" accesses the Business Goals sub-sub-folder. To access the top folder or project folder just enter the folder name, ex. "JKE Banking".

Parameters:
folderPath - The folder path. Might be a simple name or a fully-qualified path using '/' character for segment delimiter.
Returns:
The selected folder as a WebFolderElement or null if no folder was not found for the given folder path.

getPath

public java.lang.String getPath()
Returns the path of the current folder.

The path is made of all containing folders texts separated by /'s plus the folder text (e.g. "/Custom Reports/Sample Report Definitions/CCM").

TODO: It seems to be a really costly operation, needs to be improved...


getText

public java.lang.String getText()
Return the text of the expandable element.

Overrides to return the text of the expandable element.

Overrides:
getText in class WebElementWrapper
Returns:
The text as a String.

searchFolder

public WebFolderElement searchFolder(java.lang.String folder)
Searches the folder with the given name in the hierarchy starting from current folder.

There's no indication if the returned folder is the unique one with the given name in the hierarchy, as the first matching folder (deepest first) is returned.

Parameters:
folder - The folder to search in the hierarchy. That might be either a name or a path (absolute or relative).
Returns:
The first folder matching the given name as a WebFolderElement or null if none was found.

select

public void select()
Select the folder.


selectFolder

public WebFolderElement selectFolder(java.lang.String folderPath)
                              throws ScenarioFailedError
Selects the sub-folder for the given path.

If path has several segments, then the search occurs recursively through sub-folders levels to match each segment of the given path.

For example, "JKE Banking/JKE Enterprise Project/Business Goals" accesses the Business Goals sub-folder. To access the top folder or project folder just enter the folder name, ex. "JKE Banking".

Parameters:
folderPath - The folder path. Might be a simple name or a fully-qualified path using '/' character for segment delimiter.
Returns:
The selected folder as a WebFolderElement.
Throws:
ScenarioFailedError - if no folder was not found for the given folder path.