mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/helpers/AssetHelper.java
public static void createAsset(final WebDriver driver, final String assetTypeName, final String desiredName,
             Map<String, Object> props) 
        throws InterruptedException
    {
        //Instantiate web driver wait and fluent wait.
        WebDriverWait wait = new WebDriverWait(driver, 10);
        
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(driver).withTimeout(20, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        
        //Initial page/tab check.
        NavigationHelper.pageAndTabCheck(driver, NavigationButtonNameConstants.NAVBUT_PROP_ASSETS, ASSET_CONFIG_TAB_ID);
        
        //Bring up the add asset dialog.
        driver.findElement(By.cssSelector("button[id*='addAsset']")).click();
        
        //Wait till the add asset dialog is visible.
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div[id*='assetTypeList']")));

        ///refresh the asset types 
        driver.findElement(By.cssSelector("button[id*='refreshAssetTypes']")).click();

        //Retrieve the specified asset type once it is verified that it exists.
        WebElement desiredAssetTypeElement = retrieveAssetType(driver, assetTypeName);
        
        //Select the specified asset type.
        assertThat(desiredAssetTypeElement, is(notNullValue()));
        desiredAssetTypeElement.click();
        
        //Wait till the dialog reflects that the asset type has been selected.
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span[id*='factoryName']")));
        
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("span[id*='factoryName']"), 
                assetTypeName));
        
        //create asset with name specified.
        WebElement assetExampleName = driver.findElement(By.cssSelector("input[id*='aName']"));
        assetExampleName.clear();
        assetExampleName.sendKeys(desiredName);
        
        //click ok to create new asset.
        driver.findElement(By.cssSelector("button[id$='configureAsset']")).click();
        
        //Wait till the configure new asset dialog is visible.
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span[id*='newAssetconfigPanel']")));
        wait.until(ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector("tbody[id$='compositeConfigTable_data']")));
        
        //Alter asset configuration properties.
        if (props != null && !props.isEmpty())
        {
            for (String key: props.keySet())
            {
                final WebElement assetConfigPanel = driver.findElement(
                        By.cssSelector("span[id$='newAssetconfigPanel']"));
                final WebElement configTable = assetConfigPanel.findElement(
                        By.cssSelector("tbody[id$='compositeConfigTable_data']"));
                ConfigurationHelper.updateValue(configTable, key, props.get(key));
            }
        }
        
        //Wait till the dialog add button is visible to click it.
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id$='newAssetCreate']")));
        
        //click add to create new asset.
        GrowlVerifier.verifyAndWaitToDisappear(20, driver.findElement(By.cssSelector("button[id$='newAssetCreate']")), 
                "Asset created.");

        
        //Sleep for a second to ensure that AJAX has completed.
        Thread.sleep(1000);
        
        //Wait for the created asset to appear in the assets list.
        Boolean result = fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return retrieveAsset(driver, desiredName) != null;
            }
        });
        
        assertThat(result, is(true));
    }
/**
     * Create a new asset with the specified name, types, and configuration property values. Will wait until asset is 
     * created and will remain on the asset page. This method assumes an active controller the the correct asset
     * bundles are on the controller.
     */
Create a new asset with the specified name, types, and configuration property values. Will wait until asset is
created and will remain on the asset page. This method assumes an active controller the the correct asset
bundles are on the controller.
Create a new asset with the specified name types and configuration property values . Will wait until asset is created and will remain on the asset page . This method assumes an active controller the the correct asset bundles are on the controller .
public static void createAsset(final WebDriver driver, final String assetTypeName, final String desiredName,
             Map<String, Object> props) 
        throws InterruptedException
    {
        WebDriverWait wait = new WebDriverWait(driver, 10);
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(driver).withTimeout(20, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        NavigationHelper.pageAndTabCheck(driver, NavigationButtonNameConstants.NAVBUT_PROP_ASSETS, ASSET_CONFIG_TAB_ID);
        driver.findElement(By.cssSelector("button[id*='addAsset']")).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div[id*='assetTypeList']")));
        driver.findElement(By.cssSelector("button[id*='refreshAssetTypes']")).click();
        WebElement desiredAssetTypeElement = retrieveAssetType(driver, assetTypeName);
        assertThat(desiredAssetTypeElement, is(notNullValue()));
        desiredAssetTypeElement.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span[id*='factoryName']")));
        wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("span[id*='factoryName']"), 
                assetTypeName));
        WebElement assetExampleName = driver.findElement(By.cssSelector("input[id*='aName']"));
        assetExampleName.clear();
        assetExampleName.sendKeys(desiredName);
        driver.findElement(By.cssSelector("button[id$='configureAsset']")).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span[id*='newAssetconfigPanel']")));
        wait.until(ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector("tbody[id$='compositeConfigTable_data']")));
        if (props != null && !props.isEmpty())
        {
            for (String key: props.keySet())
            {
                final WebElement assetConfigPanel = driver.findElement(
                        By.cssSelector("span[id$='newAssetconfigPanel']"));
                final WebElement configTable = assetConfigPanel.findElement(
                        By.cssSelector("tbody[id$='compositeConfigTable_data']"));
                ConfigurationHelper.updateValue(configTable, key, props.get(key));
            }
        }
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id$='newAssetCreate']")));
        GrowlVerifier.verifyAndWaitToDisappear(20, driver.findElement(By.cssSelector("button[id$='newAssetCreate']")), 
                "Asset created.");
        Thread.sleep(1000);
        Boolean result = fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return retrieveAsset(driver, desiredName) != null;
            }
        });
        assertThat(result, is(true));
    }
public static void createAsset ( final WebDriver driver , final String assetTypeName , final String desiredName , Map < String , Object > props ) throws InterruptedException { WebDriverWait wait = new WebDriverWait ( driver , 10 ) ; Wait < WebDriver > fwait = new FluentWait < WebDriver > ( driver ) . withTimeout ( 20 , TimeUnit . SECONDS ) . pollingEvery ( 2 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; NavigationHelper . pageAndTabCheck ( driver , NavigationButtonNameConstants . NAVBUT_PROP_ASSETS , ASSET_CONFIG_TAB_ID ) ; driver . findElement ( By . cssSelector ( "button[id*='addAsset']" ) ) . click ( ) ; wait . until ( ExpectedConditions . presenceOfElementLocated ( By . cssSelector ( "div[id*='assetTypeList']" ) ) ) ; driver . findElement ( By . cssSelector ( "button[id*='refreshAssetTypes']" ) ) . click ( ) ; WebElement desiredAssetTypeElement = retrieveAssetType ( driver , assetTypeName ) ; assertThat ( desiredAssetTypeElement , is ( notNullValue ( ) ) ) ; desiredAssetTypeElement . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "span[id*='factoryName']" ) ) ) ; wait . until ( ExpectedConditions . textToBePresentInElementLocated ( By . cssSelector ( "span[id*='factoryName']" ) , assetTypeName ) ) ; WebElement assetExampleName = driver . findElement ( By . cssSelector ( "input[id*='aName']" ) ) ; assetExampleName . clear ( ) ; assetExampleName . sendKeys ( desiredName ) ; driver . findElement ( By . cssSelector ( "button[id$='configureAsset']" ) ) . click ( ) ; wait . until ( ExpectedConditions . presenceOfElementLocated ( By . cssSelector ( "span[id*='newAssetconfigPanel']" ) ) ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "tbody[id$='compositeConfigTable_data']" ) ) ) ; if ( props != null && ! props . isEmpty ( ) ) { for ( String key : props . keySet ( ) ) { final WebElement assetConfigPanel = driver . findElement ( By . cssSelector ( "span[id$='newAssetconfigPanel']" ) ) ; final WebElement configTable = assetConfigPanel . findElement ( By . cssSelector ( "tbody[id$='compositeConfigTable_data']" ) ) ; ConfigurationHelper . updateValue ( configTable , key , props . get ( key ) ) ; } } wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "button[id$='newAssetCreate']" ) ) ) ; GrowlVerifier . verifyAndWaitToDisappear ( 20 , driver . findElement ( By . cssSelector ( "button[id$='newAssetCreate']" ) ) , "Asset created." ) ; Thread . sleep ( 1000 ) ; Boolean result = fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { return retrieveAsset ( driver , desiredName ) != null ; } } ) ; assertThat ( result , is ( true ) ) ; }
Create a new asset with the specified name, types, and configuration property values.
Create a new asset with the specified name types and configuration property values .
//Instantiate web driver wait and fluent wait. //Initial page/tab check. //Bring up the add asset dialog. //Wait till the add asset dialog is visible. ///refresh the asset types  //Retrieve the specified asset type once it is verified that it exists. //Select the specified asset type. //Wait till the dialog reflects that the asset type has been selected. //create asset with name specified. //click ok to create new asset. //Wait till the configure new asset dialog is visible. //Alter asset configuration properties. //Wait till the dialog add button is visible to click it. //click add to create new asset. //Sleep for a second to ensure that AJAX has completed. //Wait for the created asset to appear in the assets list.