Search in sources :

Example 6 with ByLabel

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"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWComponentWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 7 with ByLabel

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());
}
Also used : SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 8 with ByLabel

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(".."));
}
Also used : SystemException(com.github.bordertech.wcomponents.util.SystemException) WebElement(org.openqa.selenium.WebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel)

Example 9 with ByLabel

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"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WContainer(com.github.bordertech.wcomponents.WContainer) WField(com.github.bordertech.wcomponents.WField) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WebElement(org.openqa.selenium.WebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 10 with ByLabel

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());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWMultiSelectPairWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Aggregations

ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)20 Test (org.junit.Test)19 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)16 WebElement (org.openqa.selenium.WebElement)8 SeleniumWCheckBoxSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement)6 SeleniumWComponentWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement)6 WebDriver (org.openqa.selenium.WebDriver)3 WContainer (com.github.bordertech.wcomponents.WContainer)2 WField (com.github.bordertech.wcomponents.WField)2 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)2 SeleniumWMultiSelectPairWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement)2 SeleniumWRadioButtonSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1