mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/asset/TestAssetPage.java
@Test
    public void testCreateAssetDialog()
    {
        WebElement addAssetButton = m_Driver.findElement(By.cssSelector("button[id*='addAsset']"));
        addAssetButton.click();
        
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id*='addAssetDialog']")));
        
        //refresh the asset types 
        WebElement refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshAssetTypes']"));
        refreshTypesButton.click();
        
        WebElement createAssetPanel = m_Driver.findElement(
                By.cssSelector("span[id='createAssetForm:createAssetPanel']"));
        
        //Asset panel may or may not go stale due to being updated by the refresh types button being clicked. This is
        //due to the speed at which the web driver may move. Therefore the wait may timeout if it does not go stale.
        try
        {
            wait.until(ExpectedConditions.stalenessOf(createAssetPanel));
        }
        catch (final TimeoutException exception)
        {
            //Do nothing
        }
        
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        
        //Monitor the asset types list for the specified asset type.
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return AssetHelper.retrieveAssetType(driver, "ExampleAsset") != null;
            }
        });
        
        WebElement exampleAsset = AssetHelper.retrieveAssetType(m_Driver, "ExampleAsset");
        
        assertThat(exampleAsset, is(notNullValue()));
        exampleAsset.click();
        
        //make sure text changes
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(
                "span[id='createAssetForm:factoryName']"), "ExampleAsset"));
        
        //---click on the spec button verify information is correct---
        GeneralHelper.safeClickBySelector(By.cssSelector("button[id*='assetSpecsButton']"));
        
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement capabilHeader = driver.findElement(By.cssSelector("div[id*='assetCapabilitiesHeader']"));
                WebElement header = capabilHeader.findElement(By.cssSelector("span[class='ui-dialog-title']"));
                return header.getText().equals("Capabilities Document");
            }
        });

        //--verify capabilities are displayed---
        WebElement capabilHeader = m_Driver.findElement(By.cssSelector("div[id*='assetCapabilitiesHeader']"));
        WebElement assetCapabils = capabilHeader.findElement(By.cssSelector("div[id*='assetTreeTable']"));
        assertThat(assetCapabils.getText().isEmpty(), is(false));
        
        //--verify specific item to capabilities
        //TODO: TH-1274 Improve testing.
        WebElement caps = capabilHeader.findElement(By.cssSelector("div[id*='TreeTable']"));
        assertThat(caps.getText().isEmpty(), is(false));
        assertThat(caps.getText(), containsString("ExampleAsset"));
        
        //---close the dialog---
        WebElement closeDialog = capabilHeader.findElement(
                By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
        
        WebElement exampleAssetElement = null;
        
        //make sure that an exampleAsset type exists
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id*='assetTypeList_content']")));
        for (WebElement assetType : m_Driver.findElements(By.cssSelector("a[id*='assetTypeList']")))
        {
            if (assetType.getText().contains("ExampleAsset"))
            {
                exampleAssetElement = assetType;
                break;
            }
        }
        
        assertThat(exampleAssetElement, is(notNullValue()));
        exampleAssetElement.click();
        
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("span[id*='factoryName']"), 
                "ExampleAsset"));
        
        //---close the dialog---
        WebElement addAssetDialog = m_Driver.findElement(By.cssSelector("div[id*='addAssetDialog']"));
        closeDialog = addAssetDialog.findElement(By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
    }
/**
     * Assuming default controller is the active controller, assuming example asset and example platform 
     * bundles are in the controller. Verify the example exception asset and example asset show up in the asset type 
     * list.. verify we can create a new asset with the example asset type.
     */
Assuming default controller is the active controller, assuming example asset and example platform
bundles are in the controller. Verify the example exception asset and example asset show up in the asset type
list.. verify we can create a new asset with the example asset type.
Assuming default controller is the active controller assuming example asset and example platform bundles are in the controller . Verify the example exception asset and example asset show up in the asset type list .. verify we can create a new asset with the example asset type .
@Test
    public void testCreateAssetDialog()
    {
        WebElement addAssetButton = m_Driver.findElement(By.cssSelector("button[id*='addAsset']"));
        addAssetButton.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id*='addAssetDialog']")));
        WebElement refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshAssetTypes']"));
        refreshTypesButton.click();
        WebElement createAssetPanel = m_Driver.findElement(
                By.cssSelector("span[id='createAssetForm:createAssetPanel']"));
        try
        {
            wait.until(ExpectedConditions.stalenessOf(createAssetPanel));
        }
        catch (final TimeoutException exception)
        {
        }
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return AssetHelper.retrieveAssetType(driver, "ExampleAsset") != null;
            }
        });
        WebElement exampleAsset = AssetHelper.retrieveAssetType(m_Driver, "ExampleAsset");
        assertThat(exampleAsset, is(notNullValue()));
        exampleAsset.click();
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(
                "span[id='createAssetForm:factoryName']"), "ExampleAsset"));
        GeneralHelper.safeClickBySelector(By.cssSelector("button[id*='assetSpecsButton']"));
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement capabilHeader = driver.findElement(By.cssSelector("div[id*='assetCapabilitiesHeader']"));
                WebElement header = capabilHeader.findElement(By.cssSelector("span[class='ui-dialog-title']"));
                return header.getText().equals("Capabilities Document");
            }
        });
        WebElement capabilHeader = m_Driver.findElement(By.cssSelector("div[id*='assetCapabilitiesHeader']"));
        WebElement assetCapabils = capabilHeader.findElement(By.cssSelector("div[id*='assetTreeTable']"));
        assertThat(assetCapabils.getText().isEmpty(), is(false));
        WebElement caps = capabilHeader.findElement(By.cssSelector("div[id*='TreeTable']"));
        assertThat(caps.getText().isEmpty(), is(false));
        assertThat(caps.getText(), containsString("ExampleAsset"));
        WebElement closeDialog = capabilHeader.findElement(
                By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
        WebElement exampleAssetElement = null;
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id*='assetTypeList_content']")));
        for (WebElement assetType : m_Driver.findElements(By.cssSelector("a[id*='assetTypeList']")))
        {
            if (assetType.getText().contains("ExampleAsset"))
            {
                exampleAssetElement = assetType;
                break;
            }
        }
        assertThat(exampleAssetElement, is(notNullValue()));
        exampleAssetElement.click();
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("span[id*='factoryName']"), 
                "ExampleAsset"));
        WebElement addAssetDialog = m_Driver.findElement(By.cssSelector("div[id*='addAssetDialog']"));
        closeDialog = addAssetDialog.findElement(By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
    }
@ Test public void testCreateAssetDialog ( ) { WebElement addAssetButton = m_Driver . findElement ( By . cssSelector ( "button[id*='addAsset']" ) ) ; addAssetButton . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id*='addAssetDialog']" ) ) ) ; WebElement refreshTypesButton = m_Driver . findElement ( By . cssSelector ( "button[id*='refreshAssetTypes']" ) ) ; refreshTypesButton . click ( ) ; WebElement createAssetPanel = m_Driver . findElement ( By . cssSelector ( "span[id='createAssetForm:createAssetPanel']" ) ) ; try { wait . until ( ExpectedConditions . stalenessOf ( createAssetPanel ) ) ; } catch ( final TimeoutException exception ) { } Wait < WebDriver > fwait = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { return AssetHelper . retrieveAssetType ( driver , "ExampleAsset" ) != null ; } } ) ; WebElement exampleAsset = AssetHelper . retrieveAssetType ( m_Driver , "ExampleAsset" ) ; assertThat ( exampleAsset , is ( notNullValue ( ) ) ) ; exampleAsset . click ( ) ; wait . until ( ExpectedConditions . textToBePresentInElementLocated ( By . cssSelector ( "span[id='createAssetForm:factoryName']" ) , "ExampleAsset" ) ) ; GeneralHelper . safeClickBySelector ( By . cssSelector ( "button[id*='assetSpecsButton']" ) ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { WebElement capabilHeader = driver . findElement ( By . cssSelector ( "div[id*='assetCapabilitiesHeader']" ) ) ; WebElement header = capabilHeader . findElement ( By . cssSelector ( "span[class='ui-dialog-title']" ) ) ; return header . getText ( ) . equals ( "Capabilities Document" ) ; } } ) ; WebElement capabilHeader = m_Driver . findElement ( By . cssSelector ( "div[id*='assetCapabilitiesHeader']" ) ) ; WebElement assetCapabils = capabilHeader . findElement ( By . cssSelector ( "div[id*='assetTreeTable']" ) ) ; assertThat ( assetCapabils . getText ( ) . isEmpty ( ) , is ( false ) ) ; WebElement caps = capabilHeader . findElement ( By . cssSelector ( "div[id*='TreeTable']" ) ) ; assertThat ( caps . getText ( ) . isEmpty ( ) , is ( false ) ) ; assertThat ( caps . getText ( ) , containsString ( "ExampleAsset" ) ) ; WebElement closeDialog = capabilHeader . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-closethick']" ) ) ; assertThat ( closeDialog . isDisplayed ( ) , is ( true ) ) ; closeDialog . click ( ) ; WebElement exampleAssetElement = null ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id*='assetTypeList_content']" ) ) ) ; for ( WebElement assetType : m_Driver . findElements ( By . cssSelector ( "a[id*='assetTypeList']" ) ) ) { if ( assetType . getText ( ) . contains ( "ExampleAsset" ) ) { exampleAssetElement = assetType ; break ; } } assertThat ( exampleAssetElement , is ( notNullValue ( ) ) ) ; exampleAssetElement . click ( ) ; wait . until ( ExpectedConditions . textToBePresentInElementLocated ( By . cssSelector ( "span[id*='factoryName']" ) , "ExampleAsset" ) ) ; WebElement addAssetDialog = m_Driver . findElement ( By . cssSelector ( "div[id*='addAssetDialog']" ) ) ; closeDialog = addAssetDialog . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-closethick']" ) ) ; assertThat ( closeDialog . isDisplayed ( ) , is ( true ) ) ; closeDialog . click ( ) ; }
Assuming default controller is the active controller, assuming example asset and example platform
 bundles are in the controller.
Assuming default controller is the active controller assuming example asset and example platform bundles are in the controller .
//refresh the asset types  //Asset panel may or may not go stale due to being updated by the refresh types button being clicked. This is //due to the speed at which the web driver may move. Therefore the wait may timeout if it does not go stale. //Do nothing //Monitor the asset types list for the specified asset type. //make sure text changes //---click on the spec button verify information is correct--- //--verify capabilities are displayed--- //--verify specific item to capabilities //TODO: TH-1274 Improve testing. //---close the dialog--- //make sure that an exampleAsset type exists //---close the dialog---