mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/comms/TestAddCommsDlg.java
@Test
    public void testCreateStackValidationFail() throws InterruptedException
    {
        NavigationHelper.pageAndTabCheck(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS, null);

        // Bring up the add comms dialog
        WebElement addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        addCommsButton.click();

        // Wait til the add comms dialog is visible
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id$='addAccordion']")));

        // select a transport link to test validation of transport layer inputs
        WebElement layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                "example.ccomms.DirectTransport");
        // If there are more then 3 in the list, select next page, then check again
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                    "example.ccomms.DirectTransport");
        }
        assertThat(layer, is(notNullValue()));
        layer.click();
        wait.until(ExpectedConditions.textToBePresentInElementValue(
                By.cssSelector("input[name$='transportData_selection']"), "example.ccomms.DirectTransport"));

        // click confirm stack to create new stack
        WebElement confirmStackButton = m_Driver.findElement(By.cssSelector("button[id$='confirmStackButton']"));
        confirmStackButton.click();

        // wait until close validation dialog button appears then click it
        wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='closeValidationButton']")));
        WebElement closeButton = m_Driver.findElement(By.cssSelector("button[id*='closeValidationButton']"));
        closeButton.click();

        // grab all validation errors
        List<WebElement> validationErrors = m_Driver.findElements(
                By.cssSelector("span[class='ui-message-error-detail']"));

        // add each validation error from dialog to an array list
        List<String> dialogErrors = new ArrayList<String>();
        for (WebElement error : validationErrors)
        {
            dialogErrors.add(CommsGeneralHelper.getHiddenText(m_Driver, error));
        }

        // assert that all of the dialog errors match the known errors
        assertThat(dialogErrors, hasItems("Type must be selected.", "Enter a name for the new link layer.",
                "Physical link must be selected.", "Enter a name for the new transport layer."));

        // open the force add physical link dialog
        CommsAddDialogHelper.putInForceAddPhysicalLinkMode(m_Driver);

        // ensure that the Physical Link tab is still open
        CommsAddDialogHelper.layerSelectHelper(m_Driver, "Physical Link", null);

        // assert that validation errors have been cleared
        validationErrors = m_Driver.findElements(By.cssSelector("span[class='ui-message-error-detail']"));
        assertThat(validationErrors.size(), is(0));

        // click confirm
        confirmStackButton = m_Driver.findElement(By.cssSelector("button[id$='confirmStackButton']"));
        confirmStackButton.click();

        // wait until validation error dlg button appears and click it
        wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='closeValidationButton']")));
        closeButton = m_Driver.findElement(By.cssSelector("button[id*='closeValidationButton']"));
        closeButton.click();

        // retrieve new list of validation errors from dialog
        validationErrors = m_Driver.findElements(By.cssSelector("span[class='ui-message-error-detail']"));

        // add each validation error from dialog to an array list
        dialogErrors.clear();
        for (WebElement error : validationErrors)
        {
            dialogErrors.add(CommsGeneralHelper.getHiddenText(m_Driver, error));
        }

        // assert that all of the dialog errors match the known errors
        assertThat(dialogErrors, hasItems("Type must be selected.", "Enter a name for the new physical layer."));

        // ---close the dialog---
        closeButton = m_Driver.findElement(By.cssSelector("button[id*='cancelStackButton']"));
        closeButton.click();

        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id$='addCommsDialog']")));
        m_Driver.navigate().refresh(); // used to reset values and validation state for next test
    }
/**
     * Verify all expected validation errors are displayed.
     */
Verify all expected validation errors are displayed.
Verify all expected validation errors are displayed .
@Test
    public void testCreateStackValidationFail() throws InterruptedException
    {
        NavigationHelper.pageAndTabCheck(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS, null);
        WebElement addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        addCommsButton.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id$='addAccordion']")));
        WebElement layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                "example.ccomms.DirectTransport");
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                    "example.ccomms.DirectTransport");
        }
        assertThat(layer, is(notNullValue()));
        layer.click();
        wait.until(ExpectedConditions.textToBePresentInElementValue(
                By.cssSelector("input[name$='transportData_selection']"), "example.ccomms.DirectTransport"));
        WebElement confirmStackButton = m_Driver.findElement(By.cssSelector("button[id$='confirmStackButton']"));
        confirmStackButton.click();
        wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='closeValidationButton']")));
        WebElement closeButton = m_Driver.findElement(By.cssSelector("button[id*='closeValidationButton']"));
        closeButton.click();
        List<WebElement> validationErrors = m_Driver.findElements(
                By.cssSelector("span[class='ui-message-error-detail']"));
        List<String> dialogErrors = new ArrayList<String>();
        for (WebElement error : validationErrors)
        {
            dialogErrors.add(CommsGeneralHelper.getHiddenText(m_Driver, error));
        }
        assertThat(dialogErrors, hasItems("Type must be selected.", "Enter a name for the new link layer.",
                "Physical link must be selected.", "Enter a name for the new transport layer."));
        CommsAddDialogHelper.putInForceAddPhysicalLinkMode(m_Driver);
        CommsAddDialogHelper.layerSelectHelper(m_Driver, "Physical Link", null);
        validationErrors = m_Driver.findElements(By.cssSelector("span[class='ui-message-error-detail']"));
        assertThat(validationErrors.size(), is(0));
        confirmStackButton = m_Driver.findElement(By.cssSelector("button[id$='confirmStackButton']"));
        confirmStackButton.click();
        wait.until(
                ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='closeValidationButton']")));
        closeButton = m_Driver.findElement(By.cssSelector("button[id*='closeValidationButton']"));
        closeButton.click();
        validationErrors = m_Driver.findElements(By.cssSelector("span[class='ui-message-error-detail']"));
        dialogErrors.clear();
        for (WebElement error : validationErrors)
        {
            dialogErrors.add(CommsGeneralHelper.getHiddenText(m_Driver, error));
        }
        assertThat(dialogErrors, hasItems("Type must be selected.", "Enter a name for the new physical layer."));
        closeButton = m_Driver.findElement(By.cssSelector("button[id*='cancelStackButton']"));
        closeButton.click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id$='addCommsDialog']")));
        m_Driver.navigate().refresh(); 
    }
@ Test public void testCreateStackValidationFail ( ) throws InterruptedException { NavigationHelper . pageAndTabCheck ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_COMMS , null ) ; WebElement addCommsButton = m_Driver . findElement ( By . cssSelector ( "button[id*='addCommsButton']" ) ) ; addCommsButton . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id$='addAccordion']" ) ) ) ; WebElement layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; if ( layer == null ) { CommsAddDialogHelper . selectNextCommsLayerPage ( m_Driver ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; } assertThat ( layer , is ( notNullValue ( ) ) ) ; layer . click ( ) ; wait . until ( ExpectedConditions . textToBePresentInElementValue ( By . cssSelector ( "input[name$='transportData_selection']" ) , "example.ccomms.DirectTransport" ) ) ; WebElement confirmStackButton = m_Driver . findElement ( By . cssSelector ( "button[id$='confirmStackButton']" ) ) ; confirmStackButton . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "button[id*='closeValidationButton']" ) ) ) ; WebElement closeButton = m_Driver . findElement ( By . cssSelector ( "button[id*='closeValidationButton']" ) ) ; closeButton . click ( ) ; List < WebElement > validationErrors = m_Driver . findElements ( By . cssSelector ( "span[class='ui-message-error-detail']" ) ) ; List < String > dialogErrors = new ArrayList < String > ( ) ; for ( WebElement error : validationErrors ) { dialogErrors . add ( CommsGeneralHelper . getHiddenText ( m_Driver , error ) ) ; } assertThat ( dialogErrors , hasItems ( "Type must be selected." , "Enter a name for the new link layer." , "Physical link must be selected." , "Enter a name for the new transport layer." ) ) ; CommsAddDialogHelper . putInForceAddPhysicalLinkMode ( m_Driver ) ; CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Physical Link" , null ) ; validationErrors = m_Driver . findElements ( By . cssSelector ( "span[class='ui-message-error-detail']" ) ) ; assertThat ( validationErrors . size ( ) , is ( 0 ) ) ; confirmStackButton = m_Driver . findElement ( By . cssSelector ( "button[id$='confirmStackButton']" ) ) ; confirmStackButton . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "button[id*='closeValidationButton']" ) ) ) ; closeButton = m_Driver . findElement ( By . cssSelector ( "button[id*='closeValidationButton']" ) ) ; closeButton . click ( ) ; validationErrors = m_Driver . findElements ( By . cssSelector ( "span[class='ui-message-error-detail']" ) ) ; dialogErrors . clear ( ) ; for ( WebElement error : validationErrors ) { dialogErrors . add ( CommsGeneralHelper . getHiddenText ( m_Driver , error ) ) ; } assertThat ( dialogErrors , hasItems ( "Type must be selected." , "Enter a name for the new physical layer." ) ) ; closeButton = m_Driver . findElement ( By . cssSelector ( "button[id*='cancelStackButton']" ) ) ; closeButton . click ( ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[id$='addCommsDialog']" ) ) ) ; m_Driver . navigate ( ) . refresh ( ) ; }
Verify all expected validation errors are displayed.
Verify all expected validation errors are displayed .
// Bring up the add comms dialog // Wait til the add comms dialog is visible // select a transport link to test validation of transport layer inputs // If there are more then 3 in the list, select next page, then check again // click confirm stack to create new stack // wait until close validation dialog button appears then click it // grab all validation errors // add each validation error from dialog to an array list // assert that all of the dialog errors match the known errors // open the force add physical link dialog // ensure that the Physical Link tab is still open // assert that validation errors have been cleared // click confirm // wait until validation error dlg button appears and click it // retrieve new list of validation errors from dialog // add each validation error from dialog to an array list // assert that all of the dialog errors match the known errors // ---close the dialog--- // used to reset values and validation state for next test