mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/helpers/GeneralHelper.java
public static WebElement safeFindElement(final WebElement parent, final By by)
    {
        DebugText.pushText("Safe wait for [%s]", by);
        
        try
        {
            WebDriver driver = WebDriverFactory.retrieveWebDriver();
            return new FluentWait<WebDriver>(driver)
                .withTimeout(30, TimeUnit.SECONDS)
                .pollingEvery(1, TimeUnit.SECONDS)
                .ignoring(StaleElementReferenceException.class)
                .until(new ExpectedCondition<WebElement>()
                {
                    @Override
                    public WebElement apply(WebDriver driver)
                    {   
                        if (parent == null)
                        {
                            return driver.findElement(by);
                        }
                        return parent.findElement(by);
                    }
                });
        }
        finally
        {
            DebugText.popText();
        }
    }
/**
     * Convenience method to find an element, but allow it to be stale before finding the one.
     * 
     * @param parent
     *      parent element that the element to find is contained in or null if the base web driver should be used to
     *      find the element.
     * @param by
     *      the locating mechanism
     * @return
     *      the element that has been found
     */
Convenience method to find an element, but allow it to be stale before finding the one.

@param parent
parent element that the element to find is contained in or null if the base web driver should be used to
find the element.
@param by
the locating mechanism
@return
the element that has been found
Convenience method to find an element but allow it to be stale before finding the one . @param parent parent element that the element to find is contained in or null if the base web driver should be used to find the element . @param by the locating mechanism @return the element that has been found
public static WebElement safeFindElement(final WebElement parent, final By by)
    {
        DebugText.pushText("Safe wait for [%s]", by);
        try
        {
            WebDriver driver = WebDriverFactory.retrieveWebDriver();
            return new FluentWait<WebDriver>(driver)
                .withTimeout(30, TimeUnit.SECONDS)
                .pollingEvery(1, TimeUnit.SECONDS)
                .ignoring(StaleElementReferenceException.class)
                .until(new ExpectedCondition<WebElement>()
                {
                    @Override
                    public WebElement apply(WebDriver driver)
                    {   
                        if (parent == null)
                        {
                            return driver.findElement(by);
                        }
                        return parent.findElement(by);
                    }
                });
        }
        finally
        {
            DebugText.popText();
        }
    }
public static WebElement safeFindElement ( final WebElement parent , final By by ) { DebugText . pushText ( "Safe wait for [%s]" , by ) ; try { WebDriver driver = WebDriverFactory . retrieveWebDriver ( ) ; return new FluentWait < WebDriver > ( driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class ) . until ( new ExpectedCondition < WebElement > ( ) { @ Override public WebElement apply ( WebDriver driver ) { if ( parent == null ) { return driver . findElement ( by ) ; } return parent . findElement ( by ) ; } } ) ; } finally { DebugText . popText ( ) ; } }
Convenience method to find an element, but allow it to be stale before finding the one.
Convenience method to find an element but allow it to be stale before finding the one .