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

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.WebWindow
              extended by com.ibm.team.fvt.tests.web.WebMenu

public class WebMenu
extends WebWindow

Class to manage menus.

Menus can be considered like window as they are also opened by clicking on a web element, usually a menu item or drop-down button.

The open operation looks like a window one but have the peculiarity to check that items are loaded before returning.

Additionally, this generic level offers the following features:

Following actions are accessible or overridden in this page:


Constructor Summary
WebMenu(WebPage page)
           
WebMenu(WebPage page, org.openqa.selenium.By findBy)
           
WebMenu(WebPage page, org.openqa.selenium.By findBy, java.lang.String frame)
           
WebMenu(WebPage page, WebBrowserElement parentElement)
           
 
Method Summary
 void clickItem(java.lang.String item)
          Click on item element found using the given label.
<P extends WebPage>
P
clickItem(java.lang.String itemLabel, org.openqa.selenium.By linkBy, java.lang.Class<P> pageClass, java.lang.String... data)
          Open the given page by clicking on the link element found by using the given relative xpath from the given menu item element found by using the item label.
<W extends WebWindow>
W
clickItem(java.lang.String item, org.openqa.selenium.By windowBy, java.lang.Class<W> windowClass)
          Open the given menu by clicking on the given menu item.
<P extends WebPage>
P
clickItem(java.lang.String itemLabel, java.lang.Class<P> pageClass, java.lang.String... data)
          Open the given page by clicking on the given menu item label.
<W extends WebWindow>
W
clickItem(java.lang.String item, java.lang.Class<W> windowClass)
          Open the given window by clicking on the given menu item.
 WebBrowserElement getItemElement(java.lang.String itemLabel)
          Return the web element for the item matching the given label.
 WebBrowserElement getItemElement(java.lang.String itemLabel, boolean displayed)
          Return the web element for the item matching the given label.
 java.util.List<WebBrowserElement> getMenuOptions()
          Returns the list of Menu option elements within this menu.
 java.util.List<java.lang.String> getStringMenuOptions(boolean shouldClose)
          Returns the list of Menu option strings within this popup menu.
 WebBrowserElement open(WebBrowserElement webElement)
          Open the window by clicking on the given web element.
 
Methods inherited from class com.ibm.team.fvt.tests.web.WebWindow
cancel, close
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebMenu

public WebMenu(WebPage page)

WebMenu

public WebMenu(WebPage page,
               org.openqa.selenium.By findBy)

WebMenu

public WebMenu(WebPage page,
               org.openqa.selenium.By findBy,
               java.lang.String frame)

WebMenu

public WebMenu(WebPage page,
               WebBrowserElement parentElement)
Method Detail

clickItem

public void clickItem(java.lang.String item)
Click on item element found using the given label.

Parameters:
item - The item text to click on

clickItem

public <P extends WebPage> P clickItem(java.lang.String itemLabel,
                                       java.lang.Class<P> pageClass,
                                       java.lang.String... data)
Open the given page by clicking on the given menu item label.

Parameters:
itemLabel - The item label to click on
pageClass - The class of the page to be opened by the item click
data - Additional data to store in the opened page
Returns:
The opened page

clickItem

public <W extends WebWindow> W clickItem(java.lang.String item,
                                         java.lang.Class<W> windowClass)
Open the given window by clicking on the given menu item.

Parameters:
item - The item label to click on
windowClass - The class of the window which will be opened when clicking on the item
Returns:
The opened window as an instance of the given class

clickItem

public <W extends WebWindow> W clickItem(java.lang.String item,
                                         org.openqa.selenium.By windowBy,
                                         java.lang.Class<W> windowClass)
Open the given menu by clicking on the given menu item.

Parameters:
item - The item label to click on
windowBy - The mechanism to find the window when opened
windowClass - The class of the window which will be opened when clicking on the item
Returns:
The opened window as an instance of the given class

clickItem

public <P extends WebPage> P clickItem(java.lang.String itemLabel,
                                       org.openqa.selenium.By linkBy,
                                       java.lang.Class<P> pageClass,
                                       java.lang.String... data)
Open the given page by clicking on the link element found by using the given relative xpath from the given menu item element found by using the item label.

Parameters:
itemLabel - The item label to click on
linkBy - The relative path from the found item web element to the web element on which it's necessary to click to have the real action.
pageClass - The class of the page to be opened by the item click
data - Additional data to store in the opened page
Returns:
The opened page

getItemElement

public WebBrowserElement getItemElement(java.lang.String itemLabel)
Return the web element for the item matching the given label.

Note that the returned element has to be visible otherwise this method will fail.

Parameters:
itemLabel - The label of the item to click on

getItemElement

public WebBrowserElement getItemElement(java.lang.String itemLabel,
                                        boolean displayed)
Return the web element for the item matching the given label.

Parameters:
itemLabel - The label of the item to click on
displayed - Tells whether the return item has to be displayed or can be hidden.

getMenuOptions

public java.util.List<WebBrowserElement> getMenuOptions()
Returns the list of Menu option elements within this menu.

Menu options are identified as tr tag name web element having ids starting with 'jazz_ui_menu_MenuItem' or 'dijit_MenuItem'.

Returns:
A list of WebElements representing the menu items

getStringMenuOptions

public java.util.List<java.lang.String> getStringMenuOptions(boolean shouldClose)
Returns the list of Menu option strings within this popup menu.

Menu options are identified as tr tag name web element having ids starting with 'jazz_ui_menu_MenuItem' or 'dijit_MenuItem'.

Parameters:
shouldClose - Tells whether to close the menu after providing the list
Returns:
A list of Strings representing the menu items

open

public WebBrowserElement open(WebBrowserElement webElement)
Open the window by clicking on the given web element.

Open the menu found with the given search mechanism and return the corresponding web element.

Note that the menu is opened by clicking on a link element found using the given search mechanism.

When possible, it also waits for all items to be loaded before returning.

Specified by:
open in class WebWindow
Parameters:
webElement - The element on which to perform the open action.
Returns:
The opened window as a WebWindow subclass.