use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WMultiSelectPairTestingExample_Test method testGetOptions.
@Test
public void testGetOptions() {
SeleniumWComponentsWebDriver driver = getDriver();
int expected = SHAPES.length;
// get options should get a single ArrayList containing all of the same options as in SHAPES
Assert.assertEquals(expected, getExampleNoSelection().getOptions().size());
Assert.assertEquals(expected, getExampleWithSelection().getOptions().size());
Assert.assertEquals(expected, getExampleReadOnlyWithSelection().getOptions().size());
Assert.assertEquals(expected, getExampleDisabledWithSelection().getOptions().size());
Assert.assertEquals(expected, getExampleWithSomeSelection().getOptions().size());
// read-only with no selection has no options
Assert.assertTrue(CollectionUtils.isEmpty(getExampleRadOnlyNoSelection().getOptions()));
// make sure we are not erroring when we have no options
SeleniumWMultiSelectPairWebElement msp = driver.findWMultiSelectPair(new ByLabel("No options", false));
Assert.assertTrue(CollectionUtils.isEmpty(msp.getOptions()));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testGetSelected.
@Test
public void testGetSelected() {
SeleniumWComponentsWebDriver driver = getDriver();
// use item with default selection
Assert.assertEquals(9, getExampleWithSelections().getSelected().size());
// read only with selection
Assert.assertEquals(9, getExampleWithReadOnlySelection().getSelected().size());
// no selection
Assert.assertTrue(CollectionUtils.isEmpty(getExampleNoSelections().getSelected()));
// read-only, no selection
Assert.assertTrue(CollectionUtils.isEmpty(getReadOnlyNoSelection().getSelected()));
// single selection
SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
Assert.assertEquals(1, cbs.getSelected().size());
// read-only one selection
cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made (read only)", false));
Assert.assertEquals(1, cbs.getSelected().size());
// disabled always empty
cbs = driver.findWCheckBoxSelect(new ByLabel("Disabled with many selections and COLUMN layout", false));
Assert.assertTrue(CollectionUtils.isEmpty(cbs.getSelected()));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testComponentLevelBooleanProperties.
@Test
public void testComponentLevelBooleanProperties() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement interactive = getExampleNoSelections();
SeleniumWCheckBoxSelectWebElement readOnly = getExampleWithReadOnlySelection();
SeleniumWCheckBoxSelectWebElement disabled = getDisabledExample();
// read-only
Assert.assertFalse(interactive.isReadOnly());
Assert.assertTrue(readOnly.isReadOnly());
Assert.assertFalse(disabled.isReadOnly());
// enabled
Assert.assertTrue(interactive.isEnabled());
Assert.assertFalse(readOnly.isEnabled());
Assert.assertFalse(disabled.isEnabled());
// mandatory
Assert.assertFalse(interactive.isMandatory());
Assert.assertFalse(readOnly.isMandatory());
Assert.assertFalse(disabled.isMandatory());
SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("A selection is required", true));
Assert.assertTrue(cbs.isMandatory());
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testClick.
@Test
public void testClick() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
// by option
// the selected option
WebElement option = cbs.getOption(0);
boolean selected = cbs.isSelected(option);
cbs.clickNoWait(option);
Assert.assertEquals("Option selection should have changed.", !selected, cbs.isSelected(option));
cbs.clickNoWait(option);
Assert.assertEquals("Option selection should have changed back.", selected, cbs.isSelected(option));
// by label
String labelText = "New South Wales";
selected = cbs.isSelected(labelText);
cbs.clickNoWait(labelText);
Assert.assertEquals("Option with label '" + labelText + "' selection should have changed.", !selected, cbs.isSelected(labelText));
cbs.clickNoWait(labelText);
Assert.assertEquals("Option with label '" + labelText + "' selection should have changed back.", selected, cbs.isSelected(labelText));
// by index
int idx = 3;
selected = cbs.isSelected(idx);
cbs.clickNoWait(idx);
Assert.assertEquals("Option with index '" + String.valueOf(idx) + "' selection should have changed.", !selected, cbs.isSelected(idx));
cbs.clickNoWait(idx);
Assert.assertEquals("Option with index '" + String.valueOf(idx) + "' selection should have changed back.", selected, cbs.isSelected(idx));
// disabled does nothing
cbs = getDisabledExample();
Assert.assertFalse(cbs.isSelected(0));
cbs.clickNoWait(0);
getDriver().waitForPageReady();
Assert.assertFalse(cbs.isSelected(0));
// readOnly does nothing
cbs = getExampleWithReadOnlySelection();
Assert.assertTrue(cbs.isSelected(0));
cbs.clickNoWait(0);
getDriver().waitForPageReady();
Assert.assertTrue(cbs.isSelected(0));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testIsSelected.
@Test
public void testIsSelected() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement interactive = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
SeleniumWCheckBoxSelectWebElement readOnly = driver.findWCheckBoxSelect(new ByLabel("One selection was made (read only)", false));
// by index
Assert.assertTrue(interactive.isSelected(0));
Assert.assertFalse(interactive.isSelected(1));
Assert.assertTrue(readOnly.isSelected(0));
// only one option so anything else is no selected.
Assert.assertFalse(readOnly.isSelected(1));
// by text
String labelText = "Outside Australia";
Assert.assertTrue(interactive.isSelected(labelText));
Assert.assertFalse(interactive.isSelected("Australian Capital Territory"));
Assert.assertTrue(readOnly.isSelected(labelText));
Assert.assertFalse(readOnly.isSelected("Australian Capital Territory"));
// by option
Assert.assertTrue(interactive.isSelected(interactive.getOption(0)));
Assert.assertFalse(interactive.isSelected(interactive.getOption(1)));
Assert.assertTrue(readOnly.isSelected(readOnly.getOption(0)));
// cannot test for false in read only mode
// disabled always false
SeleniumWCheckBoxSelectWebElement disabled = driver.findWCheckBoxSelect(new ByLabel("Disabled with many selections and COLUMN layout", false));
int i = 0;
for (WebElement option : disabled.getOptions()) {
Assert.assertFalse(disabled.isSelected(option));
Assert.assertFalse(disabled.isSelected(i++));
Assert.assertFalse(disabled.isSelected(option.getText()));
}
}
Aggregations