Search in sources :

Example 16 with SeleniumWMultiDropdownWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement in project wcomponents by BorderTech.

the class WMultiDropdownTestingExample_Test method testDeselectFirstOption.

@Test(expected = SystemException.class)
public void testDeselectFirstOption() {
    SeleniumWMultiDropdownWebElement component = getByLabel(WMultiDropdownTestingExample.LABEL_SOME_SELECTED);
    component.deselect(WMultiDropdownTestingExample.DATA_SOME_SELECTED.get(0));
}
Also used : SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) Test(org.junit.Test)

Example 17 with SeleniumWMultiDropdownWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement in project wcomponents by BorderTech.

the class WMultiDropdownTestingExample_Test method testSelect.

@Test
public void testSelect() {
    try {
        // we know from the default selection tests that the component with no selection has a defalt seletion of the 0th element in the data list
        SeleniumWMultiDropdownWebElement component = getByLabel(WMultiDropdownTestingExample.LABEL_NO_SELECTION);
        List<WebElement> startSelection = component.getSelected();
        String text = WMultiDropdownTestingExample.DATA_LIST.get(1);
        component.select(text);
        List<WebElement> endSelection = component.getSelected();
        Assert.assertEquals(startSelection.size() + 1, endSelection.size());
        // the new selection is placed in the zeroth slot
        Assert.assertTrue(text.equalsIgnoreCase(endSelection.get(0).getText()));
    } finally {
        reset();
    }
}
Also used : SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) Test(org.junit.Test)

Example 18 with SeleniumWMultiDropdownWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement in project wcomponents by BorderTech.

the class WMultiDropdownTestingExample_Test method testDefaultSelection.

@Test
public void testDefaultSelection() {
    List<WebElement> actual;
    SeleniumWMultiDropdownWebElement component;
    WebElement selected;
    List<String> expectedData;
    String selectedValue;
    String expectedValue;
    // no selection will _always_ have one selected item - the first one
    component = getByLabel(WMultiDropdownTestingExample.LABEL_NO_SELECTION);
    actual = component.getSelected();
    Assert.assertEquals(1, actual.size());
    expectedValue = WMultiDropdownTestingExample.DATA_LIST.get(0);
    selectedValue = actual.get(0).getText();
    Assert.assertTrue(expectedValue.equalsIgnoreCase(selectedValue));
    // no selection read only has the default option (0)
    component = getByLabel(WMultiDropdownTestingExample.LABEL_RO_NO_SELECTION);
    actual = component.getSelected();
    Assert.assertEquals(1, actual.size());
    expectedValue = WMultiDropdownTestingExample.DATA_LIST.get(0);
    selectedValue = actual.get(0).getText();
    Assert.assertTrue(expectedValue.equalsIgnoreCase(selectedValue));
    // one selection
    component = getByLabel(WMultiDropdownTestingExample.LABEL_ONE_SELECTED);
    actual = component.getSelected();
    Assert.assertEquals(1, actual.size());
    expectedValue = WMultiDropdownTestingExample.DATA_ONE_SELECTED.get(0);
    selectedValue = actual.get(0).getText();
    Assert.assertTrue(expectedValue.equalsIgnoreCase(selectedValue));
    // one selection read-only
    component = getByLabel(WMultiDropdownTestingExample.LABEL_RO_ONE_SELECTED);
    actual = component.getSelected();
    Assert.assertEquals(1, actual.size());
    expectedValue = WMultiDropdownTestingExample.DATA_ONE_SELECTED.get(0);
    selectedValue = actual.get(0).getText();
    Assert.assertTrue(expectedValue.equalsIgnoreCase(selectedValue));
    // many selections
    component = getByLabel(WMultiDropdownTestingExample.LABEL_SOME_SELECTED);
    actual = component.getSelected();
    expectedData = WMultiDropdownTestingExample.DATA_SOME_SELECTED;
    Assert.assertEquals(expectedData.size(), actual.size());
    for (WebElement option : actual) {
        selectedValue = option.getText();
        Assert.assertTrue(expectedData.contains(selectedValue));
    }
    // many selections readonly
    component = getByLabel(WMultiDropdownTestingExample.LABEL_RO_SOME_SELECTED);
    actual = component.getSelected();
    expectedData = WMultiDropdownTestingExample.DATA_SOME_SELECTED;
    Assert.assertEquals(expectedData.size(), actual.size());
    for (WebElement option : actual) {
        selectedValue = option.getText();
        Assert.assertTrue(expectedData.contains(selectedValue));
    }
    // many selections but disabled is a bit different
    component = getByLabel(WMultiDropdownTestingExample.LABEL_DISABLED);
    Assert.assertTrue(component.getSelected().isEmpty());
    // getSelected is empty but there are still dropdowns available
    Assert.assertEquals(WMultiDropdownTestingExample.DATA_SOME_SELECTED.size(), component.getDropdowns().size());
}
Also used : SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) Test(org.junit.Test)

Example 19 with SeleniumWMultiDropdownWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement in project wcomponents by BorderTech.

the class WMultiDropdownTestingExample_Test method testGetFirstDropdownRO.

@Test(expected = SystemException.class)
public void testGetFirstDropdownRO() {
    SeleniumWMultiDropdownWebElement component = getByLabel(WMultiDropdownTestingExample.LABEL_RO_SOME_SELECTED);
    component.getFirstDropdown();
}
Also used : SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) Test(org.junit.Test)

Example 20 with SeleniumWMultiDropdownWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement in project wcomponents by BorderTech.

the class WMultiDropdownTestingExample_Test method testMandatory.

@Test
public void testMandatory() {
    SeleniumWMultiDropdownWebElement component = getByLabel(WMultiDropdownTestingExample.LABEL_MANDATORY);
    Assert.assertTrue(component.isMandatory());
    component = getByLabel(WMultiDropdownTestingExample.LABEL_SOME_SELECTED);
    Assert.assertFalse(component.isMandatory());
}
Also used : SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) Test(org.junit.Test)

Aggregations

SeleniumWMultiDropdownWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement)28 Test (org.junit.Test)25 WebElement (org.openqa.selenium.WebElement)9 Select (org.openqa.selenium.support.ui.Select)1