use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testDeselect.
@Test
public void testDeselect() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement cbs = getExampleWithSelections();
// by option
WebElement option = cbs.getOption(0);
Assert.assertTrue(cbs.isSelected(option));
cbs.deselect(option);
Assert.assertFalse("Option should not selected", cbs.isSelected(option));
// by index
// not 0 as we used that already, not that it matters
int idx = 1;
Assert.assertTrue(cbs.isSelected(idx));
cbs.deselect(idx);
Assert.assertFalse("Option at index 'idx' should not be selected", cbs.isSelected(idx));
// by label
String labelText = "South Australia";
Assert.assertTrue(cbs.isSelected(labelText));
cbs.deselect(labelText);
Assert.assertFalse("Option labelled '" + labelText + "' should not be selected", cbs.isSelected(labelText));
// Deselecting an unselected option should not change the selection
cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
// an unselected option in this example
idx = 1;
Assert.assertFalse(cbs.isSelected(idx));
cbs.deselect(idx);
Assert.assertFalse("Option should still not be selected", cbs.isSelected(idx));
// readOnly does nothing
cbs = getExampleWithReadOnlySelection();
Assert.assertTrue(cbs.isSelected(0));
cbs.deselect(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 testSelect.
@Test
public void testSelect() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement cbs = getExampleNoSelections();
// by option
WebElement option = cbs.getOption(0);
Assert.assertFalse(cbs.isSelected(option));
cbs.select(option);
Assert.assertTrue("Option should be selected", cbs.isSelected(option));
// by index
// not 0 as we used that already, not that it matters
int idx = 1;
Assert.assertFalse(cbs.isSelected(idx));
cbs.select(idx);
Assert.assertTrue("Option at index 'idx' should be selected", cbs.isSelected(idx));
// by label
String labelText = "South Australia";
Assert.assertFalse(cbs.isSelected(labelText));
cbs.select(labelText);
Assert.assertTrue("Option labelled '" + labelText + "' should be selected", cbs.isSelected(labelText));
// Selecting a selected option should not change the selection
cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
// the selected option in this example
idx = 0;
Assert.assertTrue(cbs.isSelected(idx));
cbs.select(idx);
Assert.assertTrue("Option should still be selected", cbs.isSelected(idx));
// select disabled does nothing
cbs = getDisabledExample();
Assert.assertFalse(cbs.isSelected(0));
cbs.select(0);
getDriver().waitForPageReady();
Assert.assertFalse(cbs.isSelected(0));
// readOnly does nothing
cbs = getExampleWithReadOnlySelection();
Assert.assertTrue(cbs.isSelected(0));
cbs.select(0);
getDriver().waitForPageReady();
Assert.assertTrue(cbs.isSelected(0));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WLabelExample_Test method testGetByLabelSimple.
// Use ByLabel to get a component by label text
@Test
public void testGetByLabelSimple() {
SeleniumWComponentsWebDriver driver = getDriver();
String labelText = "Normal input component";
SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WTextField[0]"));
SeleniumWComponentWebElement actual = driver.findElement(new ByLabel(labelText, false));
Assert.assertEquals(expected.getAttribute("id"), actual.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WLabelExample_Test method testGetByLabelComplex.
@Test
public void testGetByLabelComplex() {
String labelText = "Select one or more options";
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WCheckBoxSelect[1]"));
SeleniumWComponentWebElement actual = driver.findElement(new ByLabel(labelText, false));
Assert.assertEquals(expected.getAttribute("id"), actual.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WLabelExample_Test method testGetByLabelReadOnly.
@Test
public void testGetByLabelReadOnly() {
String labelText = "A hidden label for a read only field";
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WTextField[2]"));
SeleniumWComponentWebElement actual = driver.findElement(new ByLabel(labelText, false));
Assert.assertEquals(expected.getAttribute("id"), actual.getAttribute("id"));
}
Aggregations