use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver 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()));
}
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WLabelExample_Test method testGetByLabelComplexPartial.
@Test
public void testGetByLabelComplexPartial() {
String labelText = "one or more";
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WCheckBoxSelect[1]"));
SeleniumWComponentWebElement actual = driver.findElement(new ByLabel(labelText, true));
Assert.assertEquals(expected.getAttribute("id"), actual.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WLabelExample_Test method testGetComponentComplex.
@Test
public void testGetComponentComplex() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWLabelWebElement label = driver.findWLabel(byWComponentPath("WLabel[7]"));
SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WCheckBoxSelect[1]"));
Assert.assertEquals(expected.getAttribute("id"), label.getLabelledComponent().getAttribute("id"));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WMessagesExample_Test method testMessageBoxTypes.
@Test
public void testMessageBoxTypes() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWMessagesWebElement messages = driver.findWMessages(byWComponentPath("WMessages[0]"));
List<SeleniumWMessageBoxWebElement> messageBoxes = messages.getMessageBoxes();
Assert.assertEquals(4, messageBoxes.size());
// first one is expected to be an error box
Assert.assertTrue(messageBoxes.get(0).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_ERROR_CLASS_NAME));
Assert.assertTrue(messageBoxes.get(1).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_WARNING_CLASS_NAME));
Assert.assertTrue(messageBoxes.get(2).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_INFO_CLASS_NAME));
Assert.assertTrue(messageBoxes.get(3).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_SUCCESS_CLASS_NAME));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WRadioButtonSelectExample_Test method testComponentLevelProperties.
@Test
public void testComponentLevelProperties() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWRadioButtonSelectWebElement interactive = getExampleNoSelection();
SeleniumWRadioButtonSelectWebElement disabled = getDisabledExample();
SeleniumWRadioButtonSelectWebElement readOnly = getReadOnlyExampleWithSelection();
// isReadOnly
Assert.assertFalse(interactive.isReadOnly());
Assert.assertFalse(disabled.isReadOnly());
Assert.assertTrue(readOnly.isReadOnly());
// isDisabled
Assert.assertTrue(interactive.isEnabled());
Assert.assertFalse(disabled.isEnabled());
Assert.assertFalse(readOnly.isEnabled());
// isMandatory
Assert.assertFalse(interactive.isMandatory());
Assert.assertFalse(readOnly.isMandatory());
Assert.assertFalse(disabled.isMandatory());
SeleniumWRadioButtonSelectWebElement cbs = driver.findWRadioButtonSelect(new ByLabel("Mandatory selection", false));
Assert.assertTrue(cbs.isMandatory());
}
Aggregations