mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/asset/TestAssetPage.java
@Test
    public void testCreateAssetDialogImage()
    {
        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
        }
        
        int assetTypeCount = m_Driver.findElements(By.cssSelector("a[id*='assetTypeList']")).size();
        assertThat(assetTypeCount, greaterThan(0));

        Map<String, String> assetTypeImageMap = new HashMap<String, String>();
        for (int assetTypeIdx = 0; assetTypeIdx < assetTypeCount; assetTypeIdx++)
        {
            WebElement assetTypeLink = GeneralHelper.scrollElementIntoView(
                    By.cssSelector(String.format("a[id*='assetTypeList:%d']", assetTypeIdx)));
            
            List<WebElement> assetTypeTables = 
                    m_Driver.findElements(By.cssSelector("div[id='createAssetForm:assetTypeList_content'] > table"));
            WebElement assetIcon = assetTypeTables.get(assetTypeIdx).findElement(By.tagName("img"));
            
            if (assetTypeLink.getText().contains("ExampleObservationsAsset"))
            {
                assertThat(assetIcon.isDisplayed(), is(true));
                String source = assetIcon.getAttribute("src");
                String img = ImageHelper.getPictureOrIconName(source, ".png");
                
                assetTypeImageMap.put("ExampleObservationsAsset", img);
            }
            else if (assetTypeLink.getText().contains("ExampleAsset"))
            {
                assertThat(assetIcon.isDisplayed(), is(true));
                String source = assetIcon.getAttribute("src");
                String img = ImageHelper.getPictureOrIconName(source, ".png");
                
                assetTypeImageMap.put("ExampleAsset", img);
            }
        }
        
        assertThat(assetTypeImageMap, hasEntry("ExampleObservationsAsset","acoustic.png"));
        assertThat(assetTypeImageMap, hasEntry("ExampleAsset","magnetic.png"));
        
        //---close the dialog---
        WebElement addAssetDialog = m_Driver.findElement(By.cssSelector("div[id*='addAssetDialog']"));
        WebElement closeDialog = addAssetDialog.findElement(By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
    }
/**
     * Verify the correct images shows up for different asset types in the add asset dialog.
     */
Verify the correct images shows up for different asset types in the add asset dialog.
Verify the correct images shows up for different asset types in the add asset dialog .
@Test
    public void testCreateAssetDialogImage()
    {
        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)
        {
        }
        int assetTypeCount = m_Driver.findElements(By.cssSelector("a[id*='assetTypeList']")).size();
        assertThat(assetTypeCount, greaterThan(0));
        Map<String, String> assetTypeImageMap = new HashMap<String, String>();
        for (int assetTypeIdx = 0; assetTypeIdx < assetTypeCount; assetTypeIdx++)
        {
            WebElement assetTypeLink = GeneralHelper.scrollElementIntoView(
                    By.cssSelector(String.format("a[id*='assetTypeList:%d']", assetTypeIdx)));
            List<WebElement> assetTypeTables = 
                    m_Driver.findElements(By.cssSelector("div[id='createAssetForm:assetTypeList_content'] > table"));
            WebElement assetIcon = assetTypeTables.get(assetTypeIdx).findElement(By.tagName("img"));
            if (assetTypeLink.getText().contains("ExampleObservationsAsset"))
            {
                assertThat(assetIcon.isDisplayed(), is(true));
                String source = assetIcon.getAttribute("src");
                String img = ImageHelper.getPictureOrIconName(source, ".png");
                assetTypeImageMap.put("ExampleObservationsAsset", img);
            }
            else if (assetTypeLink.getText().contains("ExampleAsset"))
            {
                assertThat(assetIcon.isDisplayed(), is(true));
                String source = assetIcon.getAttribute("src");
                String img = ImageHelper.getPictureOrIconName(source, ".png");
                assetTypeImageMap.put("ExampleAsset", img);
            }
        }
        assertThat(assetTypeImageMap, hasEntry("ExampleObservationsAsset","acoustic.png"));
        assertThat(assetTypeImageMap, hasEntry("ExampleAsset","magnetic.png"));
        WebElement addAssetDialog = m_Driver.findElement(By.cssSelector("div[id*='addAssetDialog']"));
        WebElement closeDialog = addAssetDialog.findElement(By.cssSelector("span[class='ui-icon ui-icon-closethick']"));
        assertThat(closeDialog.isDisplayed(), is(true));
        closeDialog.click();
    }
@ Test public void testCreateAssetDialogImage ( ) { 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 ) { } int assetTypeCount = m_Driver . findElements ( By . cssSelector ( "a[id*='assetTypeList']" ) ) . size ( ) ; assertThat ( assetTypeCount , greaterThan ( 0 ) ) ; Map < String , String > assetTypeImageMap = new HashMap < String , String > ( ) ; for ( int assetTypeIdx = 0 ; assetTypeIdx < assetTypeCount ; assetTypeIdx ++ ) { WebElement assetTypeLink = GeneralHelper . scrollElementIntoView ( By . cssSelector ( String . format ( "a[id*='assetTypeList:%d']" , assetTypeIdx ) ) ) ; List < WebElement > assetTypeTables = m_Driver . findElements ( By . cssSelector ( "div[id='createAssetForm:assetTypeList_content'] > table" ) ) ; WebElement assetIcon = assetTypeTables . get ( assetTypeIdx ) . findElement ( By . tagName ( "img" ) ) ; if ( assetTypeLink . getText ( ) . contains ( "ExampleObservationsAsset" ) ) { assertThat ( assetIcon . isDisplayed ( ) , is ( true ) ) ; String source = assetIcon . getAttribute ( "src" ) ; String img = ImageHelper . getPictureOrIconName ( source , ".png" ) ; assetTypeImageMap . put ( "ExampleObservationsAsset" , img ) ; } else if ( assetTypeLink . getText ( ) . contains ( "ExampleAsset" ) ) { assertThat ( assetIcon . isDisplayed ( ) , is ( true ) ) ; String source = assetIcon . getAttribute ( "src" ) ; String img = ImageHelper . getPictureOrIconName ( source , ".png" ) ; assetTypeImageMap . put ( "ExampleAsset" , img ) ; } } assertThat ( assetTypeImageMap , hasEntry ( "ExampleObservationsAsset" , "acoustic.png" ) ) ; assertThat ( assetTypeImageMap , hasEntry ( "ExampleAsset" , "magnetic.png" ) ) ; WebElement addAssetDialog = m_Driver . findElement ( By . cssSelector ( "div[id*='addAssetDialog']" ) ) ; WebElement closeDialog = addAssetDialog . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-closethick']" ) ) ; assertThat ( closeDialog . isDisplayed ( ) , is ( true ) ) ; closeDialog . click ( ) ; }
Verify the correct images shows up for different asset types in the add asset dialog.
Verify the correct images shows up for different asset types in the add asset dialog .
//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 //---close the dialog---