mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/asset/TestAssetPage.java
@Test
    public void testEditAssetName() throws InterruptedException
    {
        AssetHelper.createAsset(m_Driver, "ExampleAsset", "testExampleAsset");
        
        //---edit asset name---
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("img[id$='assetNameImg']")));
        WebElement editImg = m_Driver.findElement(By.cssSelector("img[id$='assetNameImg']"));
        editImg.click();
        
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[id$='assetName']")));
        
        WebElement assetName = m_Driver.findElement(By.cssSelector("input[id$='assetName']"));
        assetName.sendKeys("testAsset");
        
        WebElement editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        
        //verify confirm and cancel buttons show up
        WebElement cancelButton = editPanel.findElement(By.cssSelector("button[title='Cancel']"));
        
        WebElement saveButton = editPanel.findElement(By.cssSelector("button[title='Save']"));
        
        saveButton.click();
        
        //wait until asset updates
        wait.until(ExpectedConditions.stalenessOf(saveButton));
        
        //verify name changed
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.cssSelector("input[id$='assetName']"), 
                "testAsset"));
        
        editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        
        //---begin to edit asset name and cancel---
        //Wait needed since the edit button may be stale due to the name changing being changed. At the point the edit
        //button is clicked ajax may not be finished updating the asset panel.
        Wait<WebDriver> editWait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(2,
                TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, NoSuchElementException.class);
        editWait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                driver.findElement(By.cssSelector("img[id$='assetNameImg']")).click();
                return true;
            }
        });
        
        editWait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return driver.findElement(By.cssSelector("input[id$='assetName']")).isDisplayed();
            }
        });
        
        assetName = m_Driver.findElement(By.cssSelector("input[id$='assetName']"));
        assetName.clear();
        assetName.sendKeys("garbage");
        
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[title='Cancel']")));
        //Thread sleep required due to stale element since the cancel button may not be finished updating when it
        //is clicked.
        GeneralHelper.sleepWithText(3, "Waiting for cancel button to be finished updating.");
        editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        cancelButton = editPanel.findElement(By.cssSelector("button[title='Cancel']"));
        cancelButton.click();
        
        //html will appear in text if a sleep is not used here
        GeneralHelper.sleepWithText(2, "html will appear in text if a sleep is not used here");
        
        //---verify asset name didn't change---
        
        assertThat(editPanel.getText(), is("testAsset"));
        
        AssetHelper.removeAsset(m_Driver, "testAsset");
    }
/**
     * Verify that the asset name can be edited, verify the cancel button works properly.
     */
Verify that the asset name can be edited, verify the cancel button works properly.
Verify that the asset name can be edited verify the cancel button works properly .
@Test
    public void testEditAssetName() throws InterruptedException
    {
        AssetHelper.createAsset(m_Driver, "ExampleAsset", "testExampleAsset");
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("img[id$='assetNameImg']")));
        WebElement editImg = m_Driver.findElement(By.cssSelector("img[id$='assetNameImg']"));
        editImg.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[id$='assetName']")));
        WebElement assetName = m_Driver.findElement(By.cssSelector("input[id$='assetName']"));
        assetName.sendKeys("testAsset");
        WebElement editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        WebElement cancelButton = editPanel.findElement(By.cssSelector("button[title='Cancel']"));
        WebElement saveButton = editPanel.findElement(By.cssSelector("button[title='Save']"));
        saveButton.click();
        wait.until(ExpectedConditions.stalenessOf(saveButton));
        wait.until(ExpectedConditions.textToBePresentInElementValue(By.cssSelector("input[id$='assetName']"), 
                "testAsset"));
        editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        Wait<WebDriver> editWait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(2,
                TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, NoSuchElementException.class);
        editWait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                driver.findElement(By.cssSelector("img[id$='assetNameImg']")).click();
                return true;
            }
        });
        editWait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                return driver.findElement(By.cssSelector("input[id$='assetName']")).isDisplayed();
            }
        });
        assetName = m_Driver.findElement(By.cssSelector("input[id$='assetName']"));
        assetName.clear();
        assetName.sendKeys("garbage");
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[title='Cancel']")));
        GeneralHelper.sleepWithText(3, "Waiting for cancel button to be finished updating.");
        editPanel = m_Driver.findElement(By.cssSelector("span[id$='editPanel']"));
        cancelButton = editPanel.findElement(By.cssSelector("button[title='Cancel']"));
        cancelButton.click();
        GeneralHelper.sleepWithText(2, "html will appear in text if a sleep is not used here");
        assertThat(editPanel.getText(), is("testAsset"));
        AssetHelper.removeAsset(m_Driver, "testAsset");
    }
@ Test public void testEditAssetName ( ) throws InterruptedException { AssetHelper . createAsset ( m_Driver , "ExampleAsset" , "testExampleAsset" ) ; wait . until ( ExpectedConditions . elementToBeClickable ( By . cssSelector ( "img[id$='assetNameImg']" ) ) ) ; WebElement editImg = m_Driver . findElement ( By . cssSelector ( "img[id$='assetNameImg']" ) ) ; editImg . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "input[id$='assetName']" ) ) ) ; WebElement assetName = m_Driver . findElement ( By . cssSelector ( "input[id$='assetName']" ) ) ; assetName . sendKeys ( "testAsset" ) ; WebElement editPanel = m_Driver . findElement ( By . cssSelector ( "span[id$='editPanel']" ) ) ; WebElement cancelButton = editPanel . findElement ( By . cssSelector ( "button[title='Cancel']" ) ) ; WebElement saveButton = editPanel . findElement ( By . cssSelector ( "button[title='Save']" ) ) ; saveButton . click ( ) ; wait . until ( ExpectedConditions . stalenessOf ( saveButton ) ) ; wait . until ( ExpectedConditions . textToBePresentInElementValue ( By . cssSelector ( "input[id$='assetName']" ) , "testAsset" ) ) ; editPanel = m_Driver . findElement ( By . cssSelector ( "span[id$='editPanel']" ) ) ; Wait < WebDriver > editWait = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 2 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; editWait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { driver . findElement ( By . cssSelector ( "img[id$='assetNameImg']" ) ) . click ( ) ; return true ; } } ) ; editWait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { return driver . findElement ( By . cssSelector ( "input[id$='assetName']" ) ) . isDisplayed ( ) ; } } ) ; assetName = m_Driver . findElement ( By . cssSelector ( "input[id$='assetName']" ) ) ; assetName . clear ( ) ; assetName . sendKeys ( "garbage" ) ; wait . until ( ExpectedConditions . elementToBeClickable ( By . cssSelector ( "button[title='Cancel']" ) ) ) ; GeneralHelper . sleepWithText ( 3 , "Waiting for cancel button to be finished updating." ) ; editPanel = m_Driver . findElement ( By . cssSelector ( "span[id$='editPanel']" ) ) ; cancelButton = editPanel . findElement ( By . cssSelector ( "button[title='Cancel']" ) ) ; cancelButton . click ( ) ; GeneralHelper . sleepWithText ( 2 , "html will appear in text if a sleep is not used here" ) ; assertThat ( editPanel . getText ( ) , is ( "testAsset" ) ) ; AssetHelper . removeAsset ( m_Driver , "testAsset" ) ; }
Verify that the asset name can be edited, verify the cancel button works properly.
Verify that the asset name can be edited verify the cancel button works properly .
//---edit asset name--- //verify confirm and cancel buttons show up //wait until asset updates //verify name changed //---begin to edit asset name and cancel--- //Wait needed since the edit button may be stale due to the name changing being changed. At the point the edit //button is clicked ajax may not be finished updating the asset panel. //Thread sleep required due to stale element since the cancel button may not be finished updating when it //is clicked. //html will appear in text if a sleep is not used here //---verify asset name didn't change---