Search in sources :

Example 16 with ByLabel

use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.

the class WLabelExample_Test method testGetByLabelReadOnlyPartial.

@Test
public void testGetByLabelReadOnlyPartial() {
    String labelText = "for a read only";
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WTextField[2]"));
    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 17 with ByLabel

use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.

the class WLabelExample_Test method testGetByLabelSimplePartial.

@Test
public void testGetByLabelSimplePartial() {
    String labelText = "Normal input";
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WTextField[0]"));
    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 18 with ByLabel

use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.

the class WRadioButtonSelectExample_Test method testGetOptions.

@Test
public void testGetOptions() {
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertEquals(9, getExampleNoSelection().getOptions().size());
    Assert.assertEquals(9, getDisabledExample().getOptions().size());
    Assert.assertTrue(CollectionUtils.isEmpty(getReadOnlyExampleNoSelection().getOptions()));
    // interactive but no options
    Assert.assertTrue(CollectionUtils.isEmpty(driver.findWRadioButtonSelect(new ByLabel("Select from no options", false)).getOptions()));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 19 with ByLabel

use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.

the class WCheckBoxExample_Test method testFindByLabelTextPartial.

/**
 * Test that ByLabel works for CheckBoxes by label text partial match.
 */
@Test
public void testFindByLabelTextPartial() {
    // Launch the web browser to the LDE
    WebDriver driver = getDriver();
    // Case sensitive match on partial text.
    List<WebElement> checkBoxes = driver.findElements(new ByLabel("check box", true));
    Assert.assertNotNull("Unable to find checkboxes by label text partial match", checkBoxes);
    Assert.assertEquals("Incorrect number of check boxes found by partial text match", 5, checkBoxes.size());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 20 with ByLabel

use of com.github.bordertech.wcomponents.test.selenium.ByLabel in project wcomponents by BorderTech.

the class WCheckBoxExample_Test method testFindByLabelTextExact.

/**
 * Test that ByLabel works for CheckBoxes by label text exact match.
 */
@Test
public void testFindByLabelTextExact() {
    // 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 labelText = field.getLabel().getText();
    String componentId = field.getField().getId();
    WebElement checkBox = driver.findElement(new ByLabel(labelText, false));
    Assert.assertNotNull("Unable to find checkbox by label text", 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)

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