Package com.vaadin.testbench.elements

Examples of com.vaadin.testbench.elements.ComboBoxElement


    @Test
    public void testClosePopupRetainText() throws Exception {
        openTestURL();

        ComboBoxElement cb = $(ComboBoxElement.class).first();
        WebElement textbox = cb.findElement(By.vaadin("#textbox"));
        textbox.sendKeys("I");
        cb.openPopup();
        cb.openPopup(); // openPopup() actually toggles
        // The entered value should remain
        assertEquals("I", textbox.getAttribute("value"));
    }
View Full Code Here


    }

    @Test
    public void testClosePopupRetainText_selectingAValue() throws Exception {
        openTestURL();
        ComboBoxElement cb = $(ComboBoxElement.class).first();
        cb.selectByText("Item 3");
        WebElement textbox = cb.findElement(By.vaadin("#textbox"));
        textbox.clear();
        textbox.sendKeys("I");
        cb.openPopup();
        // Entered value should remain in the text field even though the popup
        // is opened
        assertEquals("I", textbox.getAttribute("value"));

    }
View Full Code Here

    @Test
    public void promptIsHiddenForDisabledAndReadonly() {
        openTestURL();

        ComboBoxElement normalComboBox = getComboBoxWithCaption("Normal");
        ComboBoxElement disabledComboBox = getComboBoxWithCaption("Disabled");
        ComboBoxElement readOnlyComboBox = getComboBoxWithCaption("Read-only");

        assertThat(getInputPromptValue(normalComboBox),
                is("Normal input prompt"));
        assertThat(getInputPromptValue(disabledComboBox), isEmptyString());
        assertThat(getInputPromptValue(readOnlyComboBox), isEmptyString());
View Full Code Here

        return comboBox.findElement(By.tagName("input"));
    }

    @Test
    public void defaultComboBoxClearsInputOnInvalidValue() {
        ComboBoxElement comboBox = getComboBox("default");

        assertThat(getComboBoxValue(comboBox), is(""));

        comboBox.selectByText("Value 1");
        sendKeysToComboBox(comboBox, "abc");

        removeFocusFromComboBoxes();

        assertThat(getComboBoxValue(comboBox), is("Value 1"));
View Full Code Here

        assertThat(comboBox.isElementPresent(By.vaadin("#popup")), is(false));
    }

    @Test
    public void comboBoxWithPromptClearsInputOnInvalidValue() {
        ComboBoxElement comboBox = getComboBox("default-prompt");

        assertThat(getComboBoxValue(comboBox), is("Please select"));

        comboBox.selectByText("Value 2");
        sendKeysToComboBox(comboBox, "def");

        removeFocusFromComboBoxes();

        assertThat(getComboBoxValue(comboBox), is("Value 2"));
View Full Code Here

        assertThatComboBoxSuggestionsAreHidden(comboBox);
    }

    @Test
    public void comboBoxWithNullItemClearsInputOnInvalidValue() {
        ComboBoxElement comboBox = getComboBox("null");

        assertThat(getComboBoxValue(comboBox), is("Null item"));

        sendKeysToComboBox(comboBox, "ghi");
View Full Code Here

        assertThatComboBoxSuggestionsAreHidden(comboBox);
    }

    @Test
    public void comboBoxWithNullItemAndPromptClearsInputOnInvalidValue() {
        ComboBoxElement comboBox = getComboBox("null-prompt");

        assertThat(getComboBoxValue(comboBox), is("Null item"));

        sendKeysToComboBox(comboBox, "jkl");
View Full Code Here

    }

    @Test
    public void comboBoxWithFilteringOffClearsInputOnInvalidValue() {
        ComboBoxElement comboBox = getComboBox("filtering-off");

        assertThat(getComboBoxValue(comboBox), is(""));

        //selectByText doesn't work when filtering is off.
        comboBox.openPopup();
        List<WebElement> filteredItems = findElements(By.className("gwt-MenuItem"));
        filteredItems.get(1).click();

        sendKeysToComboBox(comboBox, "mnop");
View Full Code Here

        Assert.assertFalse("Combobox popup items are visible",
                isElementPresent(By.className("gwt-MenuItem")));
    }

    private void openPopup() {
        ComboBoxElement combobox = $(ComboBoxElement.class).first();
        combobox.click();
        combobox.openPopup();
        combobox.focus();

        Actions actions = new Actions(getDriver());
        actions.moveToElement(
                getDriver().findElement(By.className("gwt-MenuItem"))).build()
                .perform();
View Full Code Here

public class ComboBoxItemAddingWithFocusListenerTest extends MultiBrowserTest {

    @Test
    public void testPopupViewContainsAddedItem() {
        openTestURL();
        ComboBoxElement cBox = $(ComboBoxElement.class).first();
        ButtonElement focusTarget = $(ButtonElement.class).first();
        cBox.openPopup();
        int i = 0;
        while (i < 3) {
            assertTrue("No item added on focus", cBox.getPopupSuggestions()
                    .contains("Focus" + i++));
            focusTarget.focus();
            ((TestBenchElement) cBox.findElement(By.vaadin("#textbox")))
                    .focus();
        }
        assertTrue("No item added on focus", cBox.getPopupSuggestions()
                .contains("Focus" + i));
    }
View Full Code Here

TOP

Related Classes of com.vaadin.testbench.elements.ComboBoxElement

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.