Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlSelect


    /**
     * Sets the value of the "selectedIndex" property.
     * @param index the new value
     */
    public void jsxSet_selectedIndex(final int index) {
        final HtmlSelect htmlSelect = getHtmlSelect();

        if (index != 0 && getBrowserVersion().isFirefox() && (index < -1 || index >= htmlSelect.getOptionSize())) {
            throw Context.reportRuntimeError("Invalid index for select node: " + index);
        }

        for (final HtmlOption itemToUnSelect : htmlSelect.getSelectedOptions()) {
            htmlSelect.setSelectedAttribute(itemToUnSelect, false);
        }
        if (index < 0) {
            return;
        }

        final List<HtmlOption> allOptions = htmlSelect.getOptions();

        if (index < allOptions.size()) {
            final HtmlOption itemToSelect = allOptions.get(index);
            htmlSelect.setSelectedAttribute(itemToSelect, true, false);
        }
    }
View Full Code Here


     * Returns the actual value of the selected Option.
     * @return the value
     */
    @Override
    public String jsxGet_value() {
        final HtmlSelect htmlSelect = getHtmlSelect();
        final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions();
        if (selectedOptions.isEmpty()) {
            return "";
        }
        return ((HTMLOptionElement) selectedOptions.get(0).getScriptObject()).jsxGet_value();
    }
View Full Code Here

            getDomNodeOrDie().removeAttribute("multiple");
        }
    }

    private void ensureSelectedIndex() {
        final HtmlSelect select = getHtmlSelect();
        if (select.getOptionSize() == 0) {
            jsxSet_selectedIndex(-1);
        }
        else if (jsxGet_selectedIndex() == -1) {
            jsxSet_selectedIndex(0);
        }
View Full Code Here

        assertTrue(-1 != adhocText.indexOf("ExecuteQuery"));//button text

        //list values
        HtmlForm adhocForm = adhocPage.getFormByName("DasForm");
        //adhocPage.getEnclosingWindow().getWebClient()
        HtmlSelect adhocList = (HtmlSelect)adhocForm.getHtmlElementById("sqlQuery");
        List adhocListOptions = adhocList.getOptions();//.asText();
        //System.out.println(" adhocListOptionsText-->\n" + adhocListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<adhocListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)adhocListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("SELECT * FROM COMPANY")){
            adhocList.setSelectedAttribute(curOption, true);
            //System.out.println("select option..."+curOptionText);
          }
        }
        //System.out.println("allOptionsText:"+allOptionsText);

View Full Code Here

        assertTrue(-1 != commandText.indexOf("DAS Command:"));//heading
        assertTrue(-1 != commandText.indexOf("ExecuteCommand"));//button text

        //list values
        HtmlForm commandForm = commandPage.getFormByName("DasForm");
        HtmlSelect commandList = (HtmlSelect)commandForm.getHtmlElementById("DasCommand");
        List commandListOptions = commandList.getOptions();
        //System.out.println(" commandListOptionsText-->\n" + commandListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<commandListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)commandListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("AllCompaniesAndDepartments")){
            commandList.setSelectedAttribute(curOption, true);
            //System.out.println("select option..."+curOptionText);
          }
        }
        assertTrue(-1 != allOptionsText.indexOf("NullCommand"));//check each option
        assertTrue(-1 != allOptionsText.indexOf("AllCompanies"));//check each option
View Full Code Here

        assertTrue(-1 != adhocText.indexOf("ExecuteQuery"));//button text

        //list values
        HtmlForm adhocForm = adhocPage.getFormByName("DasForm");
        //adhocPage.getEnclosingWindow().getWebClient()
        HtmlSelect adhocList = (HtmlSelect)adhocForm.getHtmlElementById("sqlQuery");
        List adhocListOptions = adhocList.getOptions();//.asText();
        //System.out.println(" adhocListOptionsText-->\n" + adhocListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<adhocListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)adhocListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.startsWith("{INSERT INTO DEPARTMENT (NAME, COMPANYID) VALUES ('MyDept',1)}" )){
            adhocList.setSelectedAttribute(curOption, true);
            //System.out.println("insert option..."+curOptionText);
          }
        }
        //System.out.println("allOptionsText:"+allOptionsText);
View Full Code Here

        assertTrue(-1 != commandText.indexOf("DAS Command:"));//heading
        assertTrue(-1 != commandText.indexOf("ExecuteCommand"));//button text

        //list values
        HtmlForm commandForm = commandPage.getFormByName("DasForm");
        HtmlSelect commandList = (HtmlSelect)commandForm.getHtmlElementById("DasCommand");
        List commandListOptions = commandList.getOptions();
        //System.out.println(" commandListOptionsText-->\n" + commandListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<commandListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)commandListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("DeleteDepartmentFromFirstCompany")){
            commandList.setSelectedAttribute(curOption, true);
            //System.out.println("delete option..."+curOptionText);
          }
        }
        assertTrue(-1 != allOptionsText.indexOf("NullCommand"));//check each option
        assertTrue(-1 != allOptionsText.indexOf("AllCompanies"));//check each option
View Full Code Here

                break;
            }
        }
        assertNotNull(tr);
        HtmlElement settingsMainElement = tr.getOneHtmlElementByAttribute("td", "class", "setting-main");
        HtmlSelect select = (HtmlSelect)settingsMainElement.getChildElements().iterator().next();
        Iterator<HtmlElement> iterator = select.getChildElements().iterator();
        HtmlElement option = iterator.next();
        String value = option.getAttribute("value");
        //This will test that the default values are correct.
        assertEquals("First value should be CRVW", "CRVW", value);
        option = iterator.next();
View Full Code Here

                break;
            }
        }
        assertNotNull(tr);
        HtmlElement settingsMainElement = tr.getOneHtmlElementByAttribute("td", "class", "setting-main");
        HtmlSelect select = (HtmlSelect)settingsMainElement.getChildElements().iterator().next();

        Iterator<HtmlElement> iterator = select.getChildElements().iterator();

        HtmlElement option = iterator.next();
        String value = option.getAttribute("value");
        //This will test that the default values are correct.
        assertEquals("First value should be VRIF", "VRIF", value);
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlSelect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.