Search in sources :

Example 1 with ByWComponent

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

the class ExampleSeleniumTest method testDuplicatorWithGettersWComponentImpl.

/**
 * This test implementation uses ByWComponent to find the HTML controls.
 * This is the easiest approach to use, but requires that the UI being
 * tested has been built with getters for every control, which is not
 * usually practical.
 */
@Test
public void testDuplicatorWithGettersWComponentImpl() {
    // Launch the web browser to the LDE
    WebDriver driver = getDriver();
    // UI components
    WTextField textField = ui.getTextDuplicatorWithGetters().getTextField();
    WButton duplicateButton = ui.getTextDuplicatorWithGetters().getDuplicateButton();
    WButton clearButton = ui.getTextDuplicatorWithGetters().getClearButton();
    // Select the 2nd tab
    driver.findElement(new ByWComponentPath(ui, "WTab[1]")).click();
    // Enter some text and use the duplicate button
    driver.findElement(new ByWComponent(textField)).sendKeys("dummy");
    driver.findElement(new ByWComponent(duplicateButton)).click();
    Assert.assertEquals("Incorrect text field text after duplicate", "dummydummy", driver.findElement(new ByWComponent(textField)).getAttribute("value"));
    // Clear the text
    driver.findElement(new ByWComponent(clearButton)).click();
    Assert.assertEquals("Incorrect text field text after clear", "", driver.findElement(new ByWComponent(textField)).getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) ByWComponentPath(com.github.bordertech.wcomponents.test.selenium.ByWComponentPath) ByWComponent(com.github.bordertech.wcomponents.test.selenium.ByWComponent) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 2 with ByWComponent

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

the class SeleniumWComponentsWebDriver method findElementsImmediate.

/**
 * Find immediate with no polling.
 *
 * @param by the by condition
 * @return the matching element
 */
public List<WebElement> findElementsImmediate(final By by) {
    if (by instanceof ByWComponent) {
        ((ByWComponent) by).setContext(getUserContextForSession());
    }
    try {
        SeleniumWComponentsUtil.configureImmediateImplicitWait(driver);
        List<WebElement> webElements = driver.findElements(by);
        List<WebElement> wrappedList = new ArrayList<>();
        for (WebElement webElement : webElements) {
            wrappedList.add(wrapElement(webElement));
        }
        return wrappedList;
    } finally {
        SeleniumWComponentsUtil.configureImplicitWait(driver);
    }
}
Also used : ByWComponent(com.github.bordertech.wcomponents.test.selenium.ByWComponent) ArrayList(java.util.ArrayList) SeleniumWPhoneNumberFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWPhoneNumberFieldWebElement) SeleniumWMessageBoxWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessageBoxWebElement) SeleniumWTextFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextFieldWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWMultiSelectPairWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement) 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) SeleniumWEmailFieldWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWEmailFieldWebElement) SeleniumWTableWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement) SeleniumWSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWSelectWebElement) SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) SeleniumWMessagesWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessagesWebElement) SeleniumWLabelWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement) SeleniumWTextAreaWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTextAreaWebElement) SeleniumWCheckBoxWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement) SeleniumWMultiDropdownWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement) SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)

Example 3 with ByWComponent

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

the class SeleniumWComponentWebElement method findElementsImmediate.

/**
 * Find immediate with no polling.
 *
 * @param by the by condition
 * @return the matching element
 */
public List<WebElement> findElementsImmediate(final By by) {
    if (by instanceof ByWComponent) {
        ((ByWComponent) by).setContext(getUserContextForSession());
    }
    try {
        SeleniumWComponentsUtil.configureImmediateImplicitWait(driver);
        List<WebElement> webElements = element.findElements(by);
        List<WebElement> wrappedList = new ArrayList<>();
        for (WebElement webElement : webElements) {
            wrappedList.add(wrapElement(webElement));
        }
        return wrappedList;
    } finally {
        SeleniumWComponentsUtil.configureImplicitWait(driver);
    }
}
Also used : ByWComponent(com.github.bordertech.wcomponents.test.selenium.ByWComponent) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement)

Aggregations

ByWComponent (com.github.bordertech.wcomponents.test.selenium.ByWComponent)3 ArrayList (java.util.ArrayList)2 WebElement (org.openqa.selenium.WebElement)2 WButton (com.github.bordertech.wcomponents.WButton)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 ByWComponentPath (com.github.bordertech.wcomponents.test.selenium.ByWComponentPath)1 SeleniumWCheckBoxSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement)1 SeleniumWCheckBoxWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxWebElement)1 SeleniumWComponentWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement)1 SeleniumWDialogWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWDialogWebElement)1 SeleniumWEmailFieldWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWEmailFieldWebElement)1 SeleniumWLabelWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement)1 SeleniumWMessageBoxWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessageBoxWebElement)1 SeleniumWMessagesWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessagesWebElement)1 SeleniumWMultiDropdownWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiDropdownWebElement)1 SeleniumWMultiSelectPairWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement)1 SeleniumWPhoneNumberFieldWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWPhoneNumberFieldWebElement)1 SeleniumWRadioButtonSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)1 SeleniumWRadioButtonWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonWebElement)1 SeleniumWSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWSelectWebElement)1