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"));
}
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);
}
}
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);
}
}
Aggregations