use of com.github.bordertech.wcomponents.test.selenium.ByLabel 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.ByLabel 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());
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class SeleniumCheckableGroupInputWebElement method getOption.
/**
* Find an option with a particular label.
*
* @param labelText the text content of the option's label
* @return the option
*/
public WebElement getOption(final String labelText) {
List<WebElement> options = getOptions();
if (CollectionUtils.isEmpty(options)) {
throw new SystemException("No options available");
}
if (isReadOnly()) {
for (WebElement o : options) {
if (labelText.equalsIgnoreCase(o.getText())) {
return o;
}
}
throw new IllegalArgumentException("Could not find option identified by " + labelText);
}
SeleniumWComponentWebElement input = findElementImmediate(new ByLabel(labelText, false, true));
return input.findElementImmediate(By.xpath(".."));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WCheckBoxExample_Test method testFindByLabelId.
/**
* Test that ByLabel works for CheckBoxes by label id.
*/
@Test
public void testFindByLabelId() {
// Launch the web browser to the LDE
WebDriver driver = getDriver();
WContainer container = (WContainer) getUi();
WFieldLayout layout = (WFieldLayout) container.getChildAt(0);
WField field = (WField) layout.getChildAt(0);
String labelId = field.getLabel().getId();
String componentId = field.getField().getId();
WebElement checkBox = driver.findElement(new ByLabel(labelId));
Assert.assertNotNull("Unable to find checkbox by labelId", checkBox);
Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.
the class WMultiSelectPairTestingExample_Test method testComponentProperties.
@Test
public void testComponentProperties() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWMultiSelectPairWebElement interactive = getExampleNoSelection();
SeleniumWMultiSelectPairWebElement disabled = getExampleDisabledWithSelection();
SeleniumWMultiSelectPairWebElement readOnly = getExampleReadOnlyWithSelection();
// isEnabled
Assert.assertTrue(interactive.isEnabled());
Assert.assertFalse(disabled.isEnabled());
Assert.assertFalse(readOnly.isEnabled());
// read-only
Assert.assertFalse(interactive.isReadOnly());
Assert.assertFalse(disabled.isReadOnly());
Assert.assertTrue(readOnly.isReadOnly());
// mandatory
Assert.assertFalse(interactive.isMandatory());
Assert.assertFalse(disabled.isMandatory());
Assert.assertFalse(readOnly.isMandatory());
SeleniumWMultiSelectPairWebElement msp = driver.findWMultiSelectPair(new ByLabel("Mandatory", false));
Assert.assertTrue(msp.isMandatory());
// hidden
Assert.assertTrue(interactive.isDisplayed());
Assert.assertTrue(disabled.isDisplayed());
Assert.assertTrue(readOnly.isDisplayed());
msp = driver.findWMultiSelectPair(new ByLabel("Hidden", false));
Assert.assertFalse(msp.isDisplayed());
}
Aggregations