mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/helpers/ControllerHelper.java
public static boolean changeControllerOpMode(final WebDriver driver, final String name, 
        final OperationMode desiredMode, final boolean verifyGrowl) throws InterruptedException, ExecutionException, 
            TimeoutException
    {
        WebDriverWait wait = new WebDriverWait(driver, 10);
        
        final WebElement controller = getControllerListElement(driver, name);
        
        //open controller menu
        final WebElement controllerMenu = controller.
                findElement(By.cssSelector("button[id$='controllerMenu_button']"));
        controllerMenu.click();
        
        //get the row index associated with the desired controller from the list
        final String controllerIndex = GeneralHelper.getElementIndex(controllerMenu.getAttribute("id"));
        
        //Bring up the controller mode selection dialog for the desired controller
        final WebElement controllerMode = driver.findElement(By.cssSelector("a[id$='"+ controllerIndex
                +":controllerMode']"));
        wait.until(ExpectedConditions.visibilityOf(controllerMode));   
        controllerMode.click();
        
        wait.until(ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector("span[id$='controllerModePanel']")));

        boolean modeChanged = false;
        //check the mode. 
        boolean opMode = driver.findElement(By.cssSelector("button[id$='opModeButton']")).isEnabled();
        if (opMode && desiredMode == OperationMode.OPERATIONAL_MODE)
        {
            if (verifyGrowl)
            {
                GrowlVerifier.verifyAndWaitToDisappear(30, 
                    driver.findElement(By.cssSelector("button[id$='opModeButton']")), "Controller Status Updated");
            }
            else
            {
                WebElement opModeElement = driver.findElement(By.cssSelector("button[id$='opModeButton']"));
                opModeElement.click();
            }
            modeChanged = true;
        }
        else if (!opMode && desiredMode == OperationMode.TEST_MODE)
        {
            if (verifyGrowl)
            {
                GrowlVerifier.verifyAndWaitToDisappear(30,
                    driver.findElement(By.cssSelector("button[id$='testModeButton']")), "Controller Status Updated");
            }
            else
            {
                WebElement testModeElement = driver.findElement(By.cssSelector("button[id$='testModeButton']"));
                testModeElement.click();
            }
            modeChanged = true;
        }
        else
        {
            //---close the dialog--- so it isn't in the way
            WebElement dialogElement = driver.findElement(
                By.cssSelector("div[id$='controllerModeDialog']"));
            WebElement closeDialog = dialogElement.findElement(
                    By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
            closeDialog.click();
            modeChanged = false;
        }

        wait.until(ExpectedConditions.invisibilityOfElementLocated(
                By.cssSelector("span[id$='controllerModePanel']")));
        return modeChanged;
    }
/**
     * Set a Controller's Operational Mode. Not if the mode is 
     * {@link mil.dod.th.core.controller.TerraHarvestController.OperationMode#TEST_MODE} it can only be
     * changed to {@link mil.dod.th.core.controller.TerraHarvestController.OperationMode#OPERATIONAL_MODE}. 
     * @param driver
     *          Current web driver.
     * @param name
     *          the name of the Controller to change the operational mode of
     * @param verifyGrowl
     *          if any the mode changed message should be searched for
     * @return
     *     if the mode actually changed, false means that the mode was already set to the desired value
     */
Set a Controller's Operational Mode.
Set a Controller ' s Operational Mode .
public static boolean changeControllerOpMode(final WebDriver driver, final String name, 
        final OperationMode desiredMode, final boolean verifyGrowl) throws InterruptedException, ExecutionException, 
            TimeoutException
    {
        WebDriverWait wait = new WebDriverWait(driver, 10);
        final WebElement controller = getControllerListElement(driver, name);
        final WebElement controllerMenu = controller.
                findElement(By.cssSelector("button[id$='controllerMenu_button']"));
        controllerMenu.click();
        final String controllerIndex = GeneralHelper.getElementIndex(controllerMenu.getAttribute("id"));
        final WebElement controllerMode = driver.findElement(By.cssSelector("a[id$='"+ controllerIndex
                +":controllerMode']"));
        wait.until(ExpectedConditions.visibilityOf(controllerMode));   
        controllerMode.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector("span[id$='controllerModePanel']")));
        boolean modeChanged = false;
        boolean opMode = driver.findElement(By.cssSelector("button[id$='opModeButton']")).isEnabled();
        if (opMode && desiredMode == OperationMode.OPERATIONAL_MODE)
        {
            if (verifyGrowl)
            {
                GrowlVerifier.verifyAndWaitToDisappear(30, 
                    driver.findElement(By.cssSelector("button[id$='opModeButton']")), "Controller Status Updated");
            }
            else
            {
                WebElement opModeElement = driver.findElement(By.cssSelector("button[id$='opModeButton']"));
                opModeElement.click();
            }
            modeChanged = true;
        }
        else if (!opMode && desiredMode == OperationMode.TEST_MODE)
        {
            if (verifyGrowl)
            {
                GrowlVerifier.verifyAndWaitToDisappear(30,
                    driver.findElement(By.cssSelector("button[id$='testModeButton']")), "Controller Status Updated");
            }
            else
            {
                WebElement testModeElement = driver.findElement(By.cssSelector("button[id$='testModeButton']"));
                testModeElement.click();
            }
            modeChanged = true;
        }
        else
        {
            WebElement dialogElement = driver.findElement(
                By.cssSelector("div[id$='controllerModeDialog']"));
            WebElement closeDialog = dialogElement.findElement(
                    By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
            closeDialog.click();
            modeChanged = false;
        }
        wait.until(ExpectedConditions.invisibilityOfElementLocated(
                By.cssSelector("span[id$='controllerModePanel']")));
        return modeChanged;
    }
public static boolean changeControllerOpMode ( final WebDriver driver , final String name , final OperationMode desiredMode , final boolean verifyGrowl ) throws InterruptedException , ExecutionException , TimeoutException { WebDriverWait wait = new WebDriverWait ( driver , 10 ) ; final WebElement controller = getControllerListElement ( driver , name ) ; final WebElement controllerMenu = controller . findElement ( By . cssSelector ( "button[id$='controllerMenu_button']" ) ) ; controllerMenu . click ( ) ; final String controllerIndex = GeneralHelper . getElementIndex ( controllerMenu . getAttribute ( "id" ) ) ; final WebElement controllerMode = driver . findElement ( By . cssSelector ( "a[id$='" + controllerIndex + ":controllerMode']" ) ) ; wait . until ( ExpectedConditions . visibilityOf ( controllerMode ) ) ; controllerMode . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "span[id$='controllerModePanel']" ) ) ) ; boolean modeChanged = false ; boolean opMode = driver . findElement ( By . cssSelector ( "button[id$='opModeButton']" ) ) . isEnabled ( ) ; if ( opMode && desiredMode == OperationMode . OPERATIONAL_MODE ) { if ( verifyGrowl ) { GrowlVerifier . verifyAndWaitToDisappear ( 30 , driver . findElement ( By . cssSelector ( "button[id$='opModeButton']" ) ) , "Controller Status Updated" ) ; } else { WebElement opModeElement = driver . findElement ( By . cssSelector ( "button[id$='opModeButton']" ) ) ; opModeElement . click ( ) ; } modeChanged = true ; } else if ( ! opMode && desiredMode == OperationMode . TEST_MODE ) { if ( verifyGrowl ) { GrowlVerifier . verifyAndWaitToDisappear ( 30 , driver . findElement ( By . cssSelector ( "button[id$='testModeButton']" ) ) , "Controller Status Updated" ) ; } else { WebElement testModeElement = driver . findElement ( By . cssSelector ( "button[id$='testModeButton']" ) ) ; testModeElement . click ( ) ; } modeChanged = true ; } else { WebElement dialogElement = driver . findElement ( By . cssSelector ( "div[id$='controllerModeDialog']" ) ) ; WebElement closeDialog = dialogElement . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-closethick']" ) ) ; closeDialog . click ( ) ; modeChanged = false ; } wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "span[id$='controllerModePanel']" ) ) ) ; return modeChanged ; }
Set a Controller's Operational Mode.
Set a Controller ' s Operational Mode .
//open controller menu //get the row index associated with the desired controller from the list //Bring up the controller mode selection dialog for the desired controller //check the mode.  //---close the dialog--- so it isn't in the way