use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver 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.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WRadioButtonSelectExample_Test method testExample.
@Test
public void testExample() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
// Select NT and submit
driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Northern Territory")).click();
driver.findElement(byWComponentPath("WButton")).click();
Assert.assertTrue("Northern Territory should be selected", driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Northern Territory")).isSelected());
Assert.assertTrue("Incorrect selection text", driver.getPageSource().contains("The selected item is: Northern Territory"));
// Select WA and submit
driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Western Australia")).click();
driver.findElement(byWComponentPath("WButton")).click();
Assert.assertTrue("Western Australia should be selected", driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Western Australia")).isSelected());
Assert.assertTrue("Incorrect selection text", driver.getPageSource().contains("The selected item is: Western Australia"));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver 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.driver.SeleniumWComponentsWebDriver 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.driver.SeleniumWComponentsWebDriver 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));
}
Aggregations