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));
}
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();
}
}
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());
}
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();
}
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());
}
Aggregations