mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/by/ByChain.java
protected Object findElementOrElements()
    {
        WebDriver driver = WebDriverFactory.retrieveWebDriver();
        return new FluentWait<WebDriver>(driver)
            .withTimeout(30, TimeUnit.SECONDS)
            .pollingEvery(1, TimeUnit.SECONDS)
            .ignoring(StaleElementReferenceException.class)
            .until(new ExpectedCondition<Object>()
            {
                @Override
                public Object apply(WebDriver driver)
                {   
                    WebElement element = null;
                    List<WebElement> elements = null;
                    boolean firstElement = true;
                    for (ByElement byElement : m_Chain)
                    {
                        if (firstElement)
                        {
                            switch (byElement.getType())
                            {
                                case SINGLE:
                                    element = driver.findElement(byElement.getSelector()); 
                                    elements = null; // make sure next part of chain uses element
                                    break;
                                    
                                case MULTIPLE:
                                    elements = driver.findElements(byElement.getSelector());
                                    element = null; // make sure next part of chain uses elements
                                    break;
                                    
                                case INDEX:
                                    throw new IllegalStateException("Index can't be the first element");
                            }
                            firstElement = false;
                        }
                        else
                        {
                            switch (byElement.getType())
                            {
                                case SINGLE:
                                    element = element.findElement(byElement.getSelector()); 
                                    elements = null; // make sure next part of chain uses element
                                    break;
                                    
                                case MULTIPLE:
                                    elements = element.findElements(byElement.getSelector());
                                    element = null; // make sure next part of chain uses elements
                                    break;
                                    
                                case INDEX:
                                    element = elements.get(byElement.getIndex());
                                    elements = null; // make sure next part of chain uses elment
                                    break;
                            }
                        }
                    }
                    
                    if (Iterables.getLast(m_Chain).getType() == ByType.MULTIPLE)
                    {
                        return elements;
                    }
                    else
                    {
                        return element;
                    }
                }
            });
    }
/**
     * Internal methods that will return either a single {@link WebElement} object or a list of them depending on the 
     * last element in the chain.
     */
Internal methods that will return either a single  WebElement object or a list of them depending on the
last element in the chain.
Internal methods that will return either a single WebElement object or a list of them depending on the last element in the chain .
protected Object findElementOrElements()
    {
        WebDriver driver = WebDriverFactory.retrieveWebDriver();
        return new FluentWait<WebDriver>(driver)
            .withTimeout(30, TimeUnit.SECONDS)
            .pollingEvery(1, TimeUnit.SECONDS)
            .ignoring(StaleElementReferenceException.class)
            .until(new ExpectedCondition<Object>()
            {
                @Override
                public Object apply(WebDriver driver)
                {   
                    WebElement element = null;
                    List<WebElement> elements = null;
                    boolean firstElement = true;
                    for (ByElement byElement : m_Chain)
                    {
                        if (firstElement)
                        {
                            switch (byElement.getType())
                            {
                                case SINGLE:
                                    element = driver.findElement(byElement.getSelector()); 
                                    elements = null; 
                                    break;
                                case MULTIPLE:
                                    elements = driver.findElements(byElement.getSelector());
                                    element = null; s
                                    break;
                                case INDEX:
                                    throw new IllegalStateException("Index can't be the first element");
                            }
                            firstElement = false;
                        }
                        else
                        {
                            switch (byElement.getType())
                            {
                                case SINGLE:
                                    element = element.findElement(byElement.getSelector()); 
                                    elements = null; 
                                    break;
                                case MULTIPLE:
                                    elements = element.findElements(byElement.getSelector());
                                    element = null; s
                                    break;
                                case INDEX:
                                    element = elements.get(byElement.getIndex());
                                    elements = null; 
                                    break;
                            }
                        }
                    }
                    if (Iterables.getLast(m_Chain).getType() == ByType.MULTIPLE)
                    {
                        return elements;
                    }
                    else
                    {
                        return element;
                    }
                }
            });
    }
protected Object findElementOrElements ( ) { WebDriver driver = WebDriverFactory . retrieveWebDriver ( ) ; return new FluentWait < WebDriver > ( driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class ) . until ( new ExpectedCondition < Object > ( ) { @ Override public Object apply ( WebDriver driver ) { WebElement element = null ; List < WebElement > elements = null ; boolean firstElement = true ; for ( ByElement byElement : m_Chain ) { if ( firstElement ) { switch ( byElement . getType ( ) ) { case SINGLE : element = driver . findElement ( byElement . getSelector ( ) ) ; elements = null ; break ; case MULTIPLE : elements = driver . findElements ( byElement . getSelector ( ) ) ; element = null ; break ; case INDEX : throw new IllegalStateException ( "Index can't be the first element" ) ; } firstElement = false ; } else { switch ( byElement . getType ( ) ) { case SINGLE : element = element . findElement ( byElement . getSelector ( ) ) ; elements = null ; break ; case MULTIPLE : elements = element . findElements ( byElement . getSelector ( ) ) ; element = null ; break ; case INDEX : element = elements . get ( byElement . getIndex ( ) ) ; elements = null ; break ; } } } if ( Iterables . getLast ( m_Chain ) . getType ( ) == ByType . MULTIPLE ) { return elements ; } else { return element ; } } } ) ; }
Internal methods that will return either a single {@link WebElement} object or a list of them depending on the
 last element in the chain.
Internal methods that will return either a single { @link WebElement } object or a list of them depending on the last element in the chain .
// make sure next part of chain uses element // make sure next part of chain uses elements // make sure next part of chain uses element // make sure next part of chain uses elements // make sure next part of chain uses elment