Class CommandCenter

All Implemented Interfaces:
IDesktop

public class CommandCenter
extends Frame
implements IDesktop
Used to interact with the Command Center, performing actions such as logging in with a given username/password and opening menu items.

Several system properties are read each time CommandCenter is instantiated to set specific attributes:

web.protocolhttp or https. Defaults to http.
server.host.nameServer hostname for login. Defaults to localhost.
CommandCenter.widthBrowser window will be resized to this width after login. (Tests run more consistently when they run with identical browser dimensions each time.)
CommandCenter.heightBrowser window will be resized to this height after login. (Tests run more consistently when they run with identical browser dimensions each time.)
selenium.timeouts.implicitlyWaitWill be set on WebDriver.Timeouts.implicitlyWait(long, TimeUnit) before login. Value should be provided in seconds.
selenium.timeouts.scriptTimeoutWill be set on WebDriver.Timeouts.setScriptTimeout(long, TimeUnit) before login. Value should be provided in seconds.
  • Field Details

    • LOG

      protected static final PlatformLogger LOG
    • tabStripEl

      protected org.openqa.selenium.WebElement tabStripEl
    • tabBodiesEl

      protected org.openqa.selenium.WebElement tabBodiesEl
    • url

      protected static java.lang.String url
    • userName

      protected java.lang.String userName
    • password

      protected java.lang.String password
    • ONE_HEADER

      public static final org.openqa.selenium.By ONE_HEADER
    • USER_MENU_HEADER

      public static final org.openqa.selenium.By USER_MENU_HEADER
    • SWITCH_ROLE

      public static final org.openqa.selenium.By SWITCH_ROLE
    • SWITCH_USER

      public static final org.openqa.selenium.By SWITCH_USER
    • ROLES

      public static final org.openqa.selenium.By ROLES
    • ACTIVE_ROLE

      public static final org.openqa.selenium.By ACTIVE_ROLE
    • NEO_SLIDER_FRAME

      public static final org.openqa.selenium.By NEO_SLIDER_FRAME
    • NEO_ACCEPT_TERMS

      public static final org.openqa.selenium.By NEO_ACCEPT_TERMS
    • TAKE_TO_NEO_BUTTON

      public static final org.openqa.selenium.By TAKE_TO_NEO_BUTTON
    • NEO_NAV_BAR

      public static final org.openqa.selenium.By NEO_NAV_BAR
    • NEO_CC_HEADERS

      public static final org.openqa.selenium.By NEO_CC_HEADERS
    • NEO_HEADER

      public static final org.openqa.selenium.By NEO_HEADER
  • Constructor Details

    • CommandCenter

      public CommandCenter()
      Constructs an instance of this class along with an instance of UIContext, which is heavily used by the rest of the API. This will use a URL based on System properties web.protocol (http if not found) and server.host.name (localhost if not found).
    • CommandCenter

      public CommandCenter​(UIContext context)
      Constructs an instance of this class which will utilize the provided UIContext instance. This will create a URL based on System properties web.protocol (http if not found) and server.host.name (localhost if not found).
    • CommandCenter

      public CommandCenter​(UIContext context, java.lang.String url)
      Parameters:
      url - home page URL, for example http://localhost/oms
  • Method Details

    • login

      public void login​(java.lang.String userName, java.lang.String password)
      Logs into Command Center with the given [userName] and [password].
      Specified by:
      login in interface IDesktop
      Parameters:
      userName -
      password -
    • login

      public static void login​(java.lang.String userName, java.lang.String password, java.lang.String loginUrl, int width, int height, org.openqa.selenium.By header, AbstractUIContext context)
    • login

      public void login​(java.lang.String userName, java.lang.String password, java.lang.String url)
      Logs into Command Center with the given [url], [userName] and [password].
      Specified by:
      login in interface IDesktop
      Parameters:
      userName -
      password -
    • logout

      public void logout()
      Logs out of Command Center and closes the browser window
      Specified by:
      logout in interface IDesktop
    • logout

      public void logout​(boolean closeWindow)
      Logs out of Command Center and optionally closes the browser window
      Specified by:
      logout in interface IDesktop
      Parameters:
      closeWindow - whether to close the browser window
    • killBrowserErrorWindow

      protected static void killBrowserErrorWindow()
    • killBrowserAndDriver

      protected static void killBrowserAndDriver()
    • logoutUsingButton

      public void logoutUsingButton()
      Logs out of Command Center using Logout button and closes the browser window
    • switchRoleThroughControls

      @Deprecated public void switchRoleThroughControls​(java.lang.String roleName)
      Deprecated.
      Switches the role for the logged in user, using UI controls only (no JS shortcuts). Needed only to test the switch role functionality itself, not intended for use by typical tests which are switching to a role to test business fucntionality. Due to stability reason api is deprecated instead do use switchRole apis
      Parameters:
      roleName - role name to switch to
    • switchUser

      public void switchUser​(java.lang.String userName)
      Switches to specified user, using UI controls only (no JS shortcuts). Current user should of role InstanceAdminUser so that switchUser option is available in UI.
      Parameters:
      userName - user name to switch to
    • switchRole

      public void switchRole​(java.lang.String roleName)
      Switches the role for the logged in user.
      Parameters:
      roleName - role name to switch to
    • switchRole

      public void switchRole​(java.lang.String roleName, java.lang.String siteName)
      Switches the role for the logged in user based on site name.
      Parameters:
      roleName - role name to switch to
      siteName - site name of role
    • switchRole

      public void switchRole​(java.lang.String roleName, java.lang.String roleType, java.lang.String entName, java.lang.String orgName, java.lang.String siteName)
      Switches the role for the logged in user.
      Parameters:
      roleName - role name to switch to
      roleType - role type of role
      entName - enterprise name of role
      orgName - organization name of role
      siteName - site name of role
    • openLinkInNewTab

      public Tab openLinkInNewTab​(java.lang.String url, java.lang.String title)
    • openPanelInNewTab

      public Tab openPanelInNewTab​(java.lang.String panelName, org.json.JSONObject config, java.lang.String title)
    • openWebActionInNewTab

      public Tab openWebActionInNewTab​(java.lang.String webActionName, org.json.JSONObject config, java.lang.String title)
    • openTabFromMenu

      public Tab openTabFromMenu​(java.lang.String... path)
      Opens a new Tab from the menu. The [path] is an array of [1..N] Strings where each item is the label of a nested menu item. For example, the 1st string will always be the label of a top-level menu item, and if that opens a submenu, the 2nd string will be the label of one of its submenu items, and so on.
      Parameters:
      path -
      Returns:
      An instance which will serve as the interface for the tab that has just been opened in Command Center.
    • getTab

      public Tab getTab​(int tabPos)
      Creates a new Tab instance which represents the tab in Command Center at the provided [tabPos].
      Parameters:
      tabPos -
      Returns:
      An instance which will serve as the interface for the tab at [tabPos].
    • getTabCount

      public int getTabCount()
      Returns the total number of open tabs
    • getTab

      protected Tab getTab​(int tabPos, org.openqa.selenium.WebElement tabHeaderEl)
    • refreshTab

      public void refreshTab()
      Clicks the green Refresh button in Command Center.
    • awaitNewActiveTab

      public Tab awaitNewActiveTab​(Tab lastKnownActiveTab)
      Given a last known active tab, awaits a new tab to open and become active, then returns that Tab.
      Parameters:
      lastKnownActiveTab - last known active tab (call getActiveTab(), then invoke your action which launches a new tab, then call this method, giving the tab you fetched earlier
    • getActiveTab

      public Tab getActiveTab()
      Returns the active tab in Command Center. Throws an exception if there is no active tab.

      WARNING: to reliably get a await the opening of a new tab which is launched by some UI action other than the openTab methods in this class, use awaitNewActiveTab(Tab).

    • openTabFromMenuPath

      @Deprecated protected void openTabFromMenuPath​(java.lang.String... path)
      Deprecated.
    • execJsToOpenTabFromMenuPath

      public void execJsToOpenTabFromMenuPath​(java.lang.String... path)
      Executes javascript to open a tab from a menu path. Does not attempt to fetch the associated Tab object afterward
    • getTabOpenedByMenuItem

      protected java.lang.Integer getTabOpenedByMenuItem​(int numTabElements)
    • setTabStripEl

      public void setTabStripEl​(org.openqa.selenium.WebElement tabStripEl)
      Specified by:
      setTabStripEl in interface IDesktop
      Parameters:
      tabStripEl - the tabStripEl to set
    • setTabBodiesEl

      public void setTabBodiesEl​(org.openqa.selenium.WebElement tabBodiesEl)
      Parameters:
      tabBodiesEl - the tabBodiesEl to set
    • updateTabElements

      protected void updateTabElements()
    • openFavoriteMenu

      public void openFavoriteMenu​(java.lang.String path)
    • closeAllTabs

      public void closeAllTabs()
      Closes all currently open tabs.
    • login

      public static CommandCenter login​(java.lang.String username)
      Preferred method of getting a CommandCenter session - this login method caches CommandCenter sessions to maximize test speed. On a call to this method, the behavior is:
      • Open a new window if the given user does not yet have a CommandCenter window
      • If the user already has a CommandCenter window, reuse it (closing all tabs before proceeding)
      • On JVM shutdown, close all open CommandCenter windows

      You never need to call logout() if you call this login() method.

      Clients not wanting to use the cache can use the non-static login method.

    • login

      public static CommandCenter login​(java.lang.String username, java.lang.Class<? extends UIContext> uiContextClass)
      Like login(String), but allows the caller to specify a concrete subclass to be used for UIContext. (Must have a no-args constructor)
    • openTabByName

      public Tab openTabByName​(java.lang.String tabName)
    • closeTabByName

      public void closeTabByName​(java.lang.String tabName)
    • openTools

      public void openTools()
    • switchTheme

      public void switchTheme​(java.lang.String themeName)
    • getChatButton

      public NotifierButton getChatButton()
      Returns the Chat Button NotifierButton in the Command Center, or throws a NoSuchElementException if none was found.
      Returns:
      chat button of the Command Center.
    • getNotificationsButton

      public NotifierButton getNotificationsButton()
      Returns the Notifications Button NotifierButton in the Command Center, or throws a NoSuchElementException if none was found.
      Returns:
      notifications button of the Command Center.
    • getChatWindow

      public ChatWindow getChatWindow()
      Returns the chat window Window in the Command Center, or throws a NoSuchElementException if none was found.
    • showUserProfile

      public void showUserProfile()
    • showSessionInformation

      public void showSessionInformation()
      Opens the "Session Information" tab by clicking the associated Tools menu item in Command Center.
    • reset

      public void reset()
      It will close all Tabs and take you at the fresh login state.
    • reinit

      public void reinit()
      Reinitializes this Command Center component without a relogin. Useful in cases where the underlying command center window was refreshed.
    • getUrl

      public static java.lang.String getUrl()
      Returns:
      resolved host name
    • getUserProfileContext

      public org.json.JSONObject getUserProfileContext()
      Returns a JSON representing the user's context from the Desktop object in Command Center
      Specified by:
      getUserProfileContext in interface IDesktop
    • getActiveTabTitle

      public java.lang.String getActiveTabTitle()
      Return title for current active tab. It should be use in scenarios where new tab is get opened as a result of clicking on link and getTitle of Tab fails because title gets changed after tab initialization.
      Returns:
      String title of active tab
    • getAllRoles

      public java.util.List<java.lang.String> getAllRoles()
      Return list of roles for currently logged in user
      Returns:
    • clickBlipper

      public void clickBlipper()
    • clickNotification

      public void clickNotification()
    • viewAllChatRooms

      public void viewAllChatRooms()
    • getListOfMenuNames

      public java.util.ArrayList<java.lang.String> getListOfMenuNames()
    • getGlobalSearch

      public GlobalSearch getGlobalSearch()
    • getCommandCenterProperties

      public static java.util.Properties getCommandCenterProperties()
      Returns:
      the all command center properties
    • getCommandCenterProperty

      public static java.lang.String getCommandCenterProperty​(java.lang.String key)
      Returns specific command center property value
      Parameters:
      key -
      Returns:
    • switchToNeo

      public NeoDesktop switchToNeo()
      Call to this method switches context from currently opened CommandCenter and logs in to NeoDesktop