Search in sources :

Example 6 with SeleniumWComponentWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement 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"));
}
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 SeleniumWComponentWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement 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 8 with SeleniumWComponentWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement 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 9 with SeleniumWComponentWebElement

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

the class WLabelExample_Test method testGetComponentReadOnly.

@Test
public void testGetComponentReadOnly() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWLabelWebElement label = driver.findWLabel(byWComponentPath("WLabel[2]"));
    Assert.assertTrue(label.isReadOnly());
    SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WTextField[2]"));
    Assert.assertEquals(expected.getAttribute("id"), label.getLabelledComponent().getAttribute("id"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWLabelWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement) SeleniumWComponentWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement) Test(org.junit.Test)

Example 10 with SeleniumWComponentWebElement

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

the class SeleniumWComponentsUtil method wrapInputElementWithTypedWebElement.

/**
 * Analyze the input element and attempt to wrap it in the appropriate component-specific subclass. If not component
 * specific subclass can be identified then the element will be wrapped in a SeleniumWComponentWebElement.
 *
 * @param driver the WebDriver.
 * @param element the default Selenium WebElement.
 * @return a subtype of SeleniumWComponentWebElement specific to the element type.
 */
public static SeleniumWComponentInputWebElement wrapInputElementWithTypedWebElement(final WebDriver driver, final WebElement element) {
    String tag = element.getTagName();
    if (tag.equals(SeleniumWComponentInputWebElement.EDITABLE_TAG)) {
        String type = element.getAttribute("type");
        WebElement el = element.findElement(By.xpath(".."));
        switch(type) {
            case SeleniumWCheckBoxWebElement.TYPE:
                return new SeleniumWCheckBoxWebElement(el, driver);
            case SeleniumWTextFieldWebElement.TYPE:
                // Text fields have a wrapping Span, we want to wrap that
                return new SeleniumWTextFieldWebElement(el, driver);
            case SeleniumWEmailFieldWebElement.TYPE:
                return new SeleniumWEmailFieldWebElement(el, driver);
            case SeleniumWRadioButtonWebElement.TYPE:
                return new SeleniumWRadioButtonWebElement(el, driver);
            default:
                return new SeleniumWComponentInputWebElement(el, driver);
        }
    } else if (tag.equals(SeleniumWTextAreaWebElement.TEXTAREA_TAG)) {
        return new SeleniumWTextAreaWebElement(element.findElement(By.xpath("..")), driver);
    } else if (tag.equals(SeleniumWSelectWebElement.SELECT_TAG)) {
        return new SeleniumWSelectWebElement(element.findElement(By.xpath("..")), driver);
    }
    return new SeleniumWComponentInputWebElement(element, driver);
}
Also used : SeleniumWCheckBoxWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement) SeleniumWSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWSelectWebElement) SeleniumWTextAreaWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextAreaWebElement) SeleniumWEmailFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWEmailFieldWebElement) SeleniumWTextFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextFieldWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWTextAreaWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextAreaWebElement) SeleniumWCheckBoxWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement) SeleniumWComponentWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement) SeleniumWDialogWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWDialogWebElement) SeleniumWRadioButtonWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonWebElement) SeleniumWComponentInputWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentInputWebElement) SeleniumWEmailFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWEmailFieldWebElement) SeleniumWSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWSelectWebElement) SeleniumWRadioButtonWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonWebElement) SeleniumWTextFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextFieldWebElement) SeleniumWComponentInputWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentInputWebElement)

Aggregations

SeleniumWComponentWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement)10 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)9 Test (org.junit.Test)9 ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)6 SeleniumWLabelWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement)3 SeleniumWCheckBoxWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement)1 SeleniumWComponentInputWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentInputWebElement)1 SeleniumWDialogWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWDialogWebElement)1 SeleniumWEmailFieldWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWEmailFieldWebElement)1 SeleniumWRadioButtonWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonWebElement)1 SeleniumWSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWSelectWebElement)1 SeleniumWTextAreaWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextAreaWebElement)1 SeleniumWTextFieldWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextFieldWebElement)1 WebElement (org.openqa.selenium.WebElement)1