mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/asset/TestAssetObservationCounts.java
@Test
    public void testSideBarObservationCount() throws InterruptedException, ExecutionException, TimeoutException
    {
        //Wait to assure the page has loaded.
        Wait<WebDriver> waitForText = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        
        NavigationHelper.expandRightSideBarOnly(m_Driver);
        
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("0"))
                {
                    return true;
                }
                return false;
            }
        });
        
        WebDriverWait wait = new WebDriverWait(m_Driver, 10);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[class='ui-growl-item']")));
        
        //capture data from asset
        GrowlVerifier.verifyAndWaitToDisappear(30, 
                m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
        //Wait till growl message disappears to continue.
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id='growl-timed_container']")));
        
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("1"))
                {
                    return true;
                }
                return false;
            }
        });
        
        //capture data 4 more times and check at 5
        for (int i = 0; i < 4; i++)
        {
            GrowlVerifier.verifyAndWaitToDisappear(30, 
                    m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
            //Wait till growl message disappears to continue.
            wait.until(ExpectedConditions.invisibilityOfElementLocated(
                    By.cssSelector("div[id='growl-timed_container']")));
        }
        
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("5"))
                {
                    return true;
                }
                return false;
            }
        });
        
        //capture data 5 more times and check at 10
        for (int i = 0; i < 5; i++)
        {
            GrowlVerifier.verifyAndWaitToDisappear(30, 
                    m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
            //Wait till growl message disappears to continue.
            wait.until(ExpectedConditions.invisibilityOfElementLocated(
                    By.cssSelector("div[id='growl-timed_container']")));
        }
        
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("10"))
                {
                    return true;
                }
                return false;
            }
        });
        
        //Need to refresh the page since now the observation isn't reset if you are on the assets page and 
        //go to the observation tab
        m_Driver.navigate().refresh();
        
        //click on observation tab
        wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("a[href*='assetObsTab']")));
        WebElement observationTab = m_Driver.findElement(By.cssSelector("a[href*='assetObsTab']"));
        observationTab.click();
        
        //verify count is decremented
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("0"))
                {
                    return true;
                }
                return false;
            }
        });
    }
/**
     * Verify the observation count on the sidebar of the mainscreen template increments the count of observations
     * correctly and verify that it resets correctly when going to the observations page.
     */
Verify the observation count on the sidebar of the mainscreen template increments the count of observations
correctly and verify that it resets correctly when going to the observations page.
Verify the observation count on the sidebar of the mainscreen template increments the count of observations correctly and verify that it resets correctly when going to the observations page .
@Test
    public void testSideBarObservationCount() throws InterruptedException, ExecutionException, TimeoutException
    {
        Wait<WebDriver> waitForText = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        NavigationHelper.expandRightSideBarOnly(m_Driver);
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("0"))
                {
                    return true;
                }
                return false;
            }
        });
        WebDriverWait wait = new WebDriverWait(m_Driver, 10);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[class='ui-growl-item']")));
        GrowlVerifier.verifyAndWaitToDisappear(30, 
                m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id='growl-timed_container']")));
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("1"))
                {
                    return true;
                }
                return false;
            }
        });
        for (int i = 0; i < 4; i++)
        {
            GrowlVerifier.verifyAndWaitToDisappear(30, 
                    m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
            wait.until(ExpectedConditions.invisibilityOfElementLocated(
                    By.cssSelector("div[id='growl-timed_container']")));
        }
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("5"))
                {
                    return true;
                }
                return false;
            }
        });
        for (int i = 0; i < 5; i++)
        {
            GrowlVerifier.verifyAndWaitToDisappear(30, 
                    m_Driver.findElement(By.cssSelector("button[id$='captureData']")), "Asset captured data!");
            wait.until(ExpectedConditions.invisibilityOfElementLocated(
                    By.cssSelector("div[id='growl-timed_container']")));
        }
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("10"))
                {
                    return true;
                }
                return false;
            }
        });
        m_Driver.navigate().refresh();
        wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("a[href*='assetObsTab']")));
        WebElement observationTab = m_Driver.findElement(By.cssSelector("a[href*='assetObsTab']"));
        observationTab.click();
        waitForText.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                if (driver.findElement(By.cssSelector("span[class='controllerObsCnt']")).getText().equals("0"))
                {
                    return true;
                }
                return false;
            }
        });
    }
@ Test public void testSideBarObservationCount ( ) throws InterruptedException , ExecutionException , TimeoutException { Wait < WebDriver > waitForText = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 2 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; NavigationHelper . expandRightSideBarOnly ( m_Driver ) ; waitForText . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { if ( driver . findElement ( By . cssSelector ( "span[class='controllerObsCnt']" ) ) . getText ( ) . equals ( "0" ) ) { return true ; } return false ; } } ) ; WebDriverWait wait = new WebDriverWait ( m_Driver , 10 ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[class='ui-growl-item']" ) ) ) ; GrowlVerifier . verifyAndWaitToDisappear ( 30 , m_Driver . findElement ( By . cssSelector ( "button[id$='captureData']" ) ) , "Asset captured data!" ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[id='growl-timed_container']" ) ) ) ; waitForText . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { if ( driver . findElement ( By . cssSelector ( "span[class='controllerObsCnt']" ) ) . getText ( ) . equals ( "1" ) ) { return true ; } return false ; } } ) ; for ( int i = 0 ; i < 4 ; i ++ ) { GrowlVerifier . verifyAndWaitToDisappear ( 30 , m_Driver . findElement ( By . cssSelector ( "button[id$='captureData']" ) ) , "Asset captured data!" ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[id='growl-timed_container']" ) ) ) ; } waitForText . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { if ( driver . findElement ( By . cssSelector ( "span[class='controllerObsCnt']" ) ) . getText ( ) . equals ( "5" ) ) { return true ; } return false ; } } ) ; for ( int i = 0 ; i < 5 ; i ++ ) { GrowlVerifier . verifyAndWaitToDisappear ( 30 , m_Driver . findElement ( By . cssSelector ( "button[id$='captureData']" ) ) , "Asset captured data!" ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[id='growl-timed_container']" ) ) ) ; } waitForText . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { if ( driver . findElement ( By . cssSelector ( "span[class='controllerObsCnt']" ) ) . getText ( ) . equals ( "10" ) ) { return true ; } return false ; } } ) ; m_Driver . navigate ( ) . refresh ( ) ; wait . until ( ExpectedConditions . presenceOfAllElementsLocatedBy ( By . cssSelector ( "a[href*='assetObsTab']" ) ) ) ; WebElement observationTab = m_Driver . findElement ( By . cssSelector ( "a[href*='assetObsTab']" ) ) ; observationTab . click ( ) ; waitForText . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { if ( driver . findElement ( By . cssSelector ( "span[class='controllerObsCnt']" ) ) . getText ( ) . equals ( "0" ) ) { return true ; } return false ; } } ) ; }
Verify the observation count on the sidebar of the mainscreen template increments the count of observations
 correctly and verify that it resets correctly when going to the observations page.
Verify the observation count on the sidebar of the mainscreen template increments the count of observations correctly and verify that it resets correctly when going to the observations page .
//Wait to assure the page has loaded. //capture data from asset //Wait till growl message disappears to continue. //capture data 4 more times and check at 5 //Wait till growl message disappears to continue. //capture data 5 more times and check at 10 //Wait till growl message disappears to continue. //Need to refresh the page since now the observation isn't reset if you are on the assets page and  //go to the observation tab //click on observation tab //verify count is decremented