mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/helpers/AssetCommandHelper.java
public static void inputAllParameters(final WebDriver driver, final String assetName, final String command, 
            final Map<String, String> params) throws InterruptedException
    {
        WebElement assetCommandPanel = getAssetCommandPanel(driver, assetName);
        
        clickAccordionPanel(driver, assetName, command, ExpandCollapse.EXPAND);
        
        WebElement accordion = assetCommandPanel.findElement(By.cssSelector(
                "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                "[aria-hidden='false'][id*='tabView:assetCommandControl']"));
        WebElement table = accordion.findElement(By.tagName("tbody"));
        
        List<WebElement> rows = table.findElements(By.tagName("tr"));
        
        assertThat(rows.size(), greaterThan(0));
        
        int numberOfRows = rows.size();
        
        int lastTreeLevel = 0;
        Stack<String> path = new Stack<>(); // current path from the root of the tree to the current node
        for (int i = 0; i < numberOfRows; i++)
        {
            WebElement row = rows.get(i);
            
            List<WebElement> paramNameCell = row.findElements(By.cssSelector("td:nth-child(1)"));
            List<WebElement> valueCell = row.findElements(By.cssSelector("td:nth-child(3)"));
            
            if (valueCell.size() == 0)
            {
                continue;
            }
            
            // id will be something like xxxxxxx_node_0_0_0 where the numbers at the end will be the index within the 
            // tree, use the tree level to figure out where we are on the path of the tree
            String nodeLabel = row.getAttribute("id").split("_node_")[1];
            int treeLevel = nodeLabel.split("_").length;
            if (treeLevel == lastTreeLevel)
            {
                // at same level, pop last node
                path.pop();
            }
            else if (treeLevel < lastTreeLevel)
            {
                // at a lower level, pop last 2 nodes
                path.pop(); // pop last visited node
                path.pop(); // pop the parent too
            }
            lastTreeLevel = treeLevel;
            
            path.push(paramNameCell.get(0).getText());
            String paramName = Joiner.on(".").join(path);
            
            LOG.info("found param name = " + paramName);
            String desiredValue = params.remove(paramName); // take parameter from map so we don't try to use again
            if (desiredValue == null)
            {
                // do not want to set parameter, not in map of things to set
                continue;
            }
            
            //find what it contains. used the findElements method to avoid the NoSuchElementException
            //so lists should always be a size of one or empty.
            List<WebElement> buttons = valueCell.get(0).findElements(By.cssSelector("button"));
            List<WebElement> inputs = valueCell.get(0).findElements(By.cssSelector("input"));
            List<WebElement> dropDowns = valueCell.get(0).findElements(By.cssSelector("div[id$='enumDropDown']"));
            
            if (buttons.size() > 0)
            {
                // assume add button
                WebElement button = buttons.get(0);
                
                if (button.getText().equals("Add") && desiredValue.equals(ADD))
                {
                    button.click();
                    
                    GeneralHelper.sleepWithText(5, "Waiting for accordion to expand and update the DOM");
                    
                    WebDriverWait wait = new WebDriverWait(driver, 20);
                    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
                            "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                            "[aria-hidden='false'][id*='tabView:assetCommandControl']")));
                    
                    table = assetCommandPanel.findElement(By.cssSelector(
                            "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                            "[aria-hidden='false'][id*='tabView:assetCommandControl']"));
                    
                    rows = table.findElements(By.tagName("tr"));
                    numberOfRows = rows.size();
                }
            }
            else if (inputs.size() > 0)
            {
                // no button, but we have input, assume text entry
                WebElement textInput = inputs.get(0);
                
                if (!textInput.getText().equals(desiredValue))
                {
                    GeneralHelper.retrySendKeys(driver, textInput, desiredValue, 5);
                }
            }
            else if (dropDowns.size() > 0)
            {
                // no button, no input, we have drop down
                WebElement dropDown = dropDowns.get(0);
                
                WebElement dropDownButton = dropDown.findElement(
                        By.cssSelector("label[class='ui-selectonemenu-label ui-inputfield ui-corner-all']"));
                dropDownButton.click();
                
                WebDriverWait wait = new WebDriverWait(driver, 20);
                wait.until(ExpectedConditions.visibilityOfElementLocated(
                        By.cssSelector("div[id*='enumDropDown_panel'][style*='block;']")));
                WebElement dropDownList = driver.findElement(
                        By.cssSelector("div[id*='enumDropDown_panel'][style*='block;']"));
                
                List<WebElement> dropDownValues = dropDownList.findElements(By.tagName("li"));
                
                for (WebElement dropDownValue : dropDownValues)
                {
                    if (dropDownValue.getText().equals(desiredValue))
                    {
                        dropDownValue.click();
                        break;
                    }
                }
            }
        } 
        
        assertThat("Not all desired parameters where changed: " + params, params.size(), is(0));
    }
/**
     * Function takes a list of string input values and iterates through the list and fills out 
     * the command on the respective panel. Function will expand the command drop down based on the 
     * supplied string.
     * @param driver
     *  the web driver to use
     * @param assetName
     *  the asset on which the command is to be filled in and executed.
     * @param command
     *  the command which is to be expanded and filled in.
     * @param params
     *  the parameters to edit where the key is the parameter name and value is the parameter value to use
     */
Function takes a list of string input values and iterates through the list and fills out
the command on the respective panel. Function will expand the command drop down based on the
supplied string.
@param driver
the web driver to use
@param assetName
the asset on which the command is to be filled in and executed.
@param command
the command which is to be expanded and filled in.
@param params
the parameters to edit where the key is the parameter name and value is the parameter value to use
Function takes a list of string input values and iterates through the list and fills out the command on the respective panel . Function will expand the command drop down based on the supplied string . @param driver the web driver to use @param assetName the asset on which the command is to be filled in and executed . @param command the command which is to be expanded and filled in . @param params the parameters to edit where the key is the parameter name and value is the parameter value to use
public static void inputAllParameters(final WebDriver driver, final String assetName, final String command, 
            final Map<String, String> params) throws InterruptedException
    {
        WebElement assetCommandPanel = getAssetCommandPanel(driver, assetName);
        clickAccordionPanel(driver, assetName, command, ExpandCollapse.EXPAND);
        WebElement accordion = assetCommandPanel.findElement(By.cssSelector(
                "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                "[aria-hidden='false'][id*='tabView:assetCommandControl']"));
        WebElement table = accordion.findElement(By.tagName("tbody"));
        List<WebElement> rows = table.findElements(By.tagName("tr"));
        assertThat(rows.size(), greaterThan(0));
        int numberOfRows = rows.size();
        int lastTreeLevel = 0;
        Stack<String> path = new Stack<>(); 
        for (int i = 0; i < numberOfRows; i++)
        {
            WebElement row = rows.get(i);
            List<WebElement> paramNameCell = row.findElements(By.cssSelector("td:nth-child(1)"));
            List<WebElement> valueCell = row.findElements(By.cssSelector("td:nth-child(3)"));
            if (valueCell.size() == 0)
            {
                continue;
            }
            String nodeLabel = row.getAttribute("id").split("_node_")[1];
            int treeLevel = nodeLabel.split("_").length;
            if (treeLevel == lastTreeLevel)
            {
                path.pop();
            }
            else if (treeLevel < lastTreeLevel)
            {
                path.pop(); 
                path.pop(); 
            }
            lastTreeLevel = treeLevel;
            path.push(paramNameCell.get(0).getText());
            String paramName = Joiner.on(".").join(path);
            LOG.info("found param name = " + paramName);
            String desiredValue = params.remove(paramName); 
            if (desiredValue == null)
            {
                continue;
            }
            List<WebElement> buttons = valueCell.get(0).findElements(By.cssSelector("button"));
            List<WebElement> inputs = valueCell.get(0).findElements(By.cssSelector("input"));
            List<WebElement> dropDowns = valueCell.get(0).findElements(By.cssSelector("div[id$='enumDropDown']"));
            if (buttons.size() > 0)
            {
                WebElement button = buttons.get(0);
                if (button.getText().equals("Add") && desiredValue.equals(ADD))
                {
                    button.click();
                    GeneralHelper.sleepWithText(5, "Waiting for accordion to expand and update the DOM");
                    WebDriverWait wait = new WebDriverWait(driver, 20);
                    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
                            "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                            "[aria-hidden='false'][id*='tabView:assetCommandControl']")));
                    table = assetCommandPanel.findElement(By.cssSelector(
                            "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" +
                            "[aria-hidden='false'][id*='tabView:assetCommandControl']"));
                    rows = table.findElements(By.tagName("tr"));
                    numberOfRows = rows.size();
                }
            }
            else if (inputs.size() > 0)
            {
                WebElement textInput = inputs.get(0);
                if (!textInput.getText().equals(desiredValue))
                {
                    GeneralHelper.retrySendKeys(driver, textInput, desiredValue, 5);
                }
            }
            else if (dropDowns.size() > 0)
            {
                WebElement dropDown = dropDowns.get(0);
                WebElement dropDownButton = dropDown.findElement(
                        By.cssSelector("label[class='ui-selectonemenu-label ui-inputfield ui-corner-all']"));
                dropDownButton.click();
                WebDriverWait wait = new WebDriverWait(driver, 20);
                wait.until(ExpectedConditions.visibilityOfElementLocated(
                        By.cssSelector("div[id*='enumDropDown_panel'][style*='block;']")));
                WebElement dropDownList = driver.findElement(
                        By.cssSelector("div[id*='enumDropDown_panel'][style*='block;']"));
                List<WebElement> dropDownValues = dropDownList.findElements(By.tagName("li"));
                for (WebElement dropDownValue : dropDownValues)
                {
                    if (dropDownValue.getText().equals(desiredValue))
                    {
                        dropDownValue.click();
                        break;
                    }
                }
            }
        } 
        assertThat("Not all desired parameters where changed: " + params, params.size(), is(0));
    }
public static void inputAllParameters ( final WebDriver driver , final String assetName , final String command , final Map < String , String > params ) throws InterruptedException { WebElement assetCommandPanel = getAssetCommandPanel ( driver , assetName ) ; clickAccordionPanel ( driver , assetName , command , ExpandCollapse . EXPAND ) ; WebElement accordion = assetCommandPanel . findElement ( By . cssSelector ( "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" + "[aria-hidden='false'][id*='tabView:assetCommandControl']" ) ) ; WebElement table = accordion . findElement ( By . tagName ( "tbody" ) ) ; List < WebElement > rows = table . findElements ( By . tagName ( "tr" ) ) ; assertThat ( rows . size ( ) , greaterThan ( 0 ) ) ; int numberOfRows = rows . size ( ) ; int lastTreeLevel = 0 ; Stack < String > path = new Stack < > ( ) ; for ( int i = 0 ; i < numberOfRows ; i ++ ) { WebElement row = rows . get ( i ) ; List < WebElement > paramNameCell = row . findElements ( By . cssSelector ( "td:nth-child(1)" ) ) ; List < WebElement > valueCell = row . findElements ( By . cssSelector ( "td:nth-child(3)" ) ) ; if ( valueCell . size ( ) == 0 ) { continue ; } String nodeLabel = row . getAttribute ( "id" ) . split ( "_node_" ) [ 1 ] ; int treeLevel = nodeLabel . split ( "_" ) . length ; if ( treeLevel == lastTreeLevel ) { path . pop ( ) ; } else if ( treeLevel < lastTreeLevel ) { path . pop ( ) ; path . pop ( ) ; } lastTreeLevel = treeLevel ; path . push ( paramNameCell . get ( 0 ) . getText ( ) ) ; String paramName = Joiner . on ( "." ) . join ( path ) ; LOG . info ( "found param name = " + paramName ) ; String desiredValue = params . remove ( paramName ) ; if ( desiredValue == null ) { continue ; } List < WebElement > buttons = valueCell . get ( 0 ) . findElements ( By . cssSelector ( "button" ) ) ; List < WebElement > inputs = valueCell . get ( 0 ) . findElements ( By . cssSelector ( "input" ) ) ; List < WebElement > dropDowns = valueCell . get ( 0 ) . findElements ( By . cssSelector ( "div[id$='enumDropDown']" ) ) ; if ( buttons . size ( ) > 0 ) { WebElement button = buttons . get ( 0 ) ; if ( button . getText ( ) . equals ( "Add" ) && desiredValue . equals ( ADD ) ) { button . click ( ) ; GeneralHelper . sleepWithText ( 5 , "Waiting for accordion to expand and update the DOM" ) ; WebDriverWait wait = new WebDriverWait ( driver , 20 ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" + "[aria-hidden='false'][id*='tabView:assetCommandControl']" ) ) ) ; table = assetCommandPanel . findElement ( By . cssSelector ( "div[class*='ui-accordion-content ui-helper-reset ui-widget-content']" + "[aria-hidden='false'][id*='tabView:assetCommandControl']" ) ) ; rows = table . findElements ( By . tagName ( "tr" ) ) ; numberOfRows = rows . size ( ) ; } } else if ( inputs . size ( ) > 0 ) { WebElement textInput = inputs . get ( 0 ) ; if ( ! textInput . getText ( ) . equals ( desiredValue ) ) { GeneralHelper . retrySendKeys ( driver , textInput , desiredValue , 5 ) ; } } else if ( dropDowns . size ( ) > 0 ) { WebElement dropDown = dropDowns . get ( 0 ) ; WebElement dropDownButton = dropDown . findElement ( By . cssSelector ( "label[class='ui-selectonemenu-label ui-inputfield ui-corner-all']" ) ) ; dropDownButton . click ( ) ; WebDriverWait wait = new WebDriverWait ( driver , 20 ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id*='enumDropDown_panel'][style*='block;']" ) ) ) ; WebElement dropDownList = driver . findElement ( By . cssSelector ( "div[id*='enumDropDown_panel'][style*='block;']" ) ) ; List < WebElement > dropDownValues = dropDownList . findElements ( By . tagName ( "li" ) ) ; for ( WebElement dropDownValue : dropDownValues ) { if ( dropDownValue . getText ( ) . equals ( desiredValue ) ) { dropDownValue . click ( ) ; break ; } } } } assertThat ( "Not all desired parameters where changed: " + params , params . size ( ) , is ( 0 ) ) ; }
Function takes a list of string input values and iterates through the list and fills out
 the command on the respective panel.
Function takes a list of string input values and iterates through the list and fills out the command on the respective panel .
// current path from the root of the tree to the current node // id will be something like xxxxxxx_node_0_0_0 where the numbers at the end will be the index within the  // tree, use the tree level to figure out where we are on the path of the tree // at same level, pop last node // at a lower level, pop last 2 nodes // pop last visited node // pop the parent too // take parameter from map so we don't try to use again // do not want to set parameter, not in map of things to set //find what it contains. used the findElements method to avoid the NoSuchElementException //so lists should always be a size of one or empty. // assume add button // no button, but we have input, assume text entry // no button, no input, we have drop down