mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/observation/TestRelatedObservations.java
@Test
    public void testRelatedObservationDialog() throws InterruptedException, ExecutionException, TimeoutException
    {
        //main obs is index 0; weather obs is index 1
        final List<ExpectedObservation> obs = createRelatedObservations();
        AssetHelper.assetCaptureData(m_Driver, ASSET_NAME, 1);
        
        m_Driver.navigate().refresh();
        
        AssetHelper.chooseAssetTab(m_Driver, AssetTabConstants.OBSERVATION_TAB);
        
        ObservationFilterHelper.clickFilterAccordionPanel(m_Driver, ExpandCollapse.EXPAND);
        ObservationFilterHelper.clickFilterByExpressionCheckBox(m_Driver);
        
        //grab the observation identified by the sensor id 12345 which is the 'main' observation
        WebElement observationPanel = ObservationHelper.grabObservationPanelBySensorId(obs.get(0).getSensorId());
        ObservationHelper.toggleObservationPanel(observationPanel);
        WebElement relationSection = ObservationHelper.findRelatedObservationSectionByType(
                observationPanel, RelationshipTypeEnum.PARENT);
        ObservationHelper.getAndClickFirstRelatedObservation(relationSection);
        
        //wait for the related observation dialog to open
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id$='relatedObsDlg']")));
        
        //grab the observation panel and verify that this is the weather observation
        WebElement divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        WebElement dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(1));
        
        //find the child which should be the main observation and then click that
        WebElement dlgRelationSection = ObservationHelper.findRelatedObservationSectionByType(
                dlgObservationPanel, RelationshipTypeEnum.CHILD);
        ObservationHelper.getAndClickFirstRelatedObservation(dlgRelationSection);
        
        //give dialog time to reload. since dialog never disappears no good way to verify that the observation
        //dialog has reloaded.
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(10, TimeUnit.SECONDS)
                .pollingEvery(1, TimeUnit.SECONDS).ignoring(
                        StaleElementReferenceException.class, NoSuchElementException.class);
        
        //wait until the main obs is visible by waiting for sensor id to change
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                
                return sensorId.getText().contains(obs.get(0).getSensorId());
            }
        });
        
        //grab the observation panel and verify that this is the main observation
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(0));
        
        //now hit the back button to hopefully go back to the weather observation
        WebElement backButton = m_Driver.findElement(
                By.cssSelector(
                        "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsBack']"));
        backButton.click();
        
        //wait until the weather obs is visible by waiting for sensor id to change
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                
                return sensorId.getText().contains(obs.get(1).getSensorId());
            }
        });
        
        //verify the back button worked which means the weather observation should be shown
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(1));
        
        //get button to go forward and make sure that the observation shown is the 'main' observation
        WebElement forwardButton = m_Driver.findElement(By.cssSelector(
                "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsForward']"));
        forwardButton.click();
        
        //wait until the main obs is visible by waiting for sensor id to change
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                
                return sensorId.getText().contains(obs.get(0).getSensorId());
            }
        });
        
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(0));
        
        //close out the dialog
        WebElement dialogClose = m_Driver.findElement(By.cssSelector("div[id$='relatedObsDlg']>div:nth-child(1)>a"));
        dialogClose.click();
    }
/**
     * Verify that when a related observation is selected then the correct items are displayed in the dialog
     * as well as in proper sequence.
     */
Verify that when a related observation is selected then the correct items are displayed in the dialog
as well as in proper sequence.
Verify that when a related observation is selected then the correct items are displayed in the dialog as well as in proper sequence .
@Test
    public void testRelatedObservationDialog() throws InterruptedException, ExecutionException, TimeoutException
    {
        final List<ExpectedObservation> obs = createRelatedObservations();
        AssetHelper.assetCaptureData(m_Driver, ASSET_NAME, 1);
        m_Driver.navigate().refresh();
        AssetHelper.chooseAssetTab(m_Driver, AssetTabConstants.OBSERVATION_TAB);
        ObservationFilterHelper.clickFilterAccordionPanel(m_Driver, ExpandCollapse.EXPAND);
        ObservationFilterHelper.clickFilterByExpressionCheckBox(m_Driver);
        WebElement observationPanel = ObservationHelper.grabObservationPanelBySensorId(obs.get(0).getSensorId());
        ObservationHelper.toggleObservationPanel(observationPanel);
        WebElement relationSection = ObservationHelper.findRelatedObservationSectionByType(
                observationPanel, RelationshipTypeEnum.PARENT);
        ObservationHelper.getAndClickFirstRelatedObservation(relationSection);
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id$='relatedObsDlg']")));
        WebElement divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        WebElement dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(1));
        WebElement dlgRelationSection = ObservationHelper.findRelatedObservationSectionByType(
                dlgObservationPanel, RelationshipTypeEnum.CHILD);
        ObservationHelper.getAndClickFirstRelatedObservation(dlgRelationSection);
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(10, TimeUnit.SECONDS)
                .pollingEvery(1, TimeUnit.SECONDS).ignoring(
                        StaleElementReferenceException.class, NoSuchElementException.class);
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                return sensorId.getText().contains(obs.get(0).getSensorId());
            }
        });
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(0));
        WebElement backButton = m_Driver.findElement(
                By.cssSelector(
                        "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsBack']"));
        backButton.click();
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                return sensorId.getText().contains(obs.get(1).getSensorId());
            }
        });
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(1));
        WebElement forwardButton = m_Driver.findElement(By.cssSelector(
                "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsForward']"));
        forwardButton.click();
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement divWithObsInfo = m_Driver.findElement(
                        By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
                WebElement dlgObservationPanel = divWithObsInfo.findElement(
                        By.cssSelector("div[id$='observationPanel']"));
                WebElement sensorId = dlgObservationPanel.findElement(By.cssSelector("span[id*='sensorId']"));
                return sensorId.getText().contains(obs.get(0).getSensorId());
            }
        });
        divWithObsInfo = m_Driver.findElement(
                By.cssSelector("span[id$='relatedObsDlgComponent']>div:nth-child(2)"));
        dlgObservationPanel = divWithObsInfo.findElement(By.cssSelector("div[id$='observationPanel']"));
        ObservationHelper.verifyObservationPanel(dlgObservationPanel, obs.get(0));
        WebElement dialogClose = m_Driver.findElement(By.cssSelector("div[id$='relatedObsDlg']>div:nth-child(1)>a"));
        dialogClose.click();
    }
@ Test public void testRelatedObservationDialog ( ) throws InterruptedException , ExecutionException , TimeoutException { final List < ExpectedObservation > obs = createRelatedObservations ( ) ; AssetHelper . assetCaptureData ( m_Driver , ASSET_NAME , 1 ) ; m_Driver . navigate ( ) . refresh ( ) ; AssetHelper . chooseAssetTab ( m_Driver , AssetTabConstants . OBSERVATION_TAB ) ; ObservationFilterHelper . clickFilterAccordionPanel ( m_Driver , ExpandCollapse . EXPAND ) ; ObservationFilterHelper . clickFilterByExpressionCheckBox ( m_Driver ) ; WebElement observationPanel = ObservationHelper . grabObservationPanelBySensorId ( obs . get ( 0 ) . getSensorId ( ) ) ; ObservationHelper . toggleObservationPanel ( observationPanel ) ; WebElement relationSection = ObservationHelper . findRelatedObservationSectionByType ( observationPanel , RelationshipTypeEnum . PARENT ) ; ObservationHelper . getAndClickFirstRelatedObservation ( relationSection ) ; WebDriverWait wait = new WebDriverWait ( m_Driver , 5 ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id$='relatedObsDlg']" ) ) ) ; WebElement divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; WebElement dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; ObservationHelper . verifyObservationPanel ( dlgObservationPanel , obs . get ( 1 ) ) ; WebElement dlgRelationSection = ObservationHelper . findRelatedObservationSectionByType ( dlgObservationPanel , RelationshipTypeEnum . CHILD ) ; ObservationHelper . getAndClickFirstRelatedObservation ( dlgRelationSection ) ; Wait < WebDriver > fwait = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 10 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { WebElement divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; WebElement dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; WebElement sensorId = dlgObservationPanel . findElement ( By . cssSelector ( "span[id*='sensorId']" ) ) ; return sensorId . getText ( ) . contains ( obs . get ( 0 ) . getSensorId ( ) ) ; } } ) ; divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; ObservationHelper . verifyObservationPanel ( dlgObservationPanel , obs . get ( 0 ) ) ; WebElement backButton = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsBack']" ) ) ; backButton . click ( ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { WebElement divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; WebElement dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; WebElement sensorId = dlgObservationPanel . findElement ( By . cssSelector ( "span[id*='sensorId']" ) ) ; return sensorId . getText ( ) . contains ( obs . get ( 1 ) . getSensorId ( ) ) ; } } ) ; divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; ObservationHelper . verifyObservationPanel ( dlgObservationPanel , obs . get ( 1 ) ) ; WebElement forwardButton = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(1)>button[id$='relatedObsForward']" ) ) ; forwardButton . click ( ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { WebElement divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; WebElement dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; WebElement sensorId = dlgObservationPanel . findElement ( By . cssSelector ( "span[id*='sensorId']" ) ) ; return sensorId . getText ( ) . contains ( obs . get ( 0 ) . getSensorId ( ) ) ; } } ) ; divWithObsInfo = m_Driver . findElement ( By . cssSelector ( "span[id$='relatedObsDlgComponent']>div:nth-child(2)" ) ) ; dlgObservationPanel = divWithObsInfo . findElement ( By . cssSelector ( "div[id$='observationPanel']" ) ) ; ObservationHelper . verifyObservationPanel ( dlgObservationPanel , obs . get ( 0 ) ) ; WebElement dialogClose = m_Driver . findElement ( By . cssSelector ( "div[id$='relatedObsDlg']>div:nth-child(1)>a" ) ) ; dialogClose . click ( ) ; }
Verify that when a related observation is selected then the correct items are displayed in the dialog
 as well as in proper sequence.
Verify that when a related observation is selected then the correct items are displayed in the dialog as well as in proper sequence .
//main obs is index 0; weather obs is index 1 //grab the observation identified by the sensor id 12345 which is the 'main' observation //wait for the related observation dialog to open //grab the observation panel and verify that this is the weather observation //find the child which should be the main observation and then click that //give dialog time to reload. since dialog never disappears no good way to verify that the observation //dialog has reloaded. //wait until the main obs is visible by waiting for sensor id to change //grab the observation panel and verify that this is the main observation //now hit the back button to hopefully go back to the weather observation //wait until the weather obs is visible by waiting for sensor id to change //verify the back button worked which means the weather observation should be shown //get button to go forward and make sure that the observation shown is the 'main' observation //wait until the main obs is visible by waiting for sensor id to change //close out the dialog