use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class AutoReFocusRepeaterExample_Test method testAutoReFocusWDropdowns.
@Test
public void testAutoReFocusWDropdowns() {
SeleniumWComponentsWebDriver driver = getDriver();
String[] paths = { ROOT_PATH + "[0]/AutoReFocusExample/WDropdown", ROOT_PATH + "[1]/AutoReFocusExample/WDropdown" };
for (String path : paths) {
driver.findWDropdown(byWComponentPath(path)).getInputField().click();
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
try {
// The dropdowns in the example need something to be selected to trigger the submit
WComponent comp = TreeUtil.findWComponent(getUi(), path.split("/"), false).getComponent();
if (comp instanceof WDropdown) {
WDropdown dropdown = (WDropdown) comp;
driver.findElement(byWComponentPath(path, dropdown.getOptions().get(1))).click();
}
} finally {
UIContextHolder.popContext();
}
Assert.assertEquals("Incorrect focus", driver.findWDropdown(byWComponentPath(path)).getActiveId(), driver.switchTo(true).activeElement().getAttribute("id"));
}
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownOptionsExample_Test method testExampleAjax.
/**
* Ajax test.
*/
@Test
public void testExampleAjax() {
WDropdownOptionsExample example = (WDropdownOptionsExample) getUi();
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
WDropdown.DropdownType type = WDropdown.DropdownType.NATIVE;
configureDropDown(driver, type, 2);
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
try {
WDropdown dropdown = (WDropdown) TreeUtil.findWComponent(example, new String[] { "WDropdown" }).getComponent();
List<?> options = dropdown.getOptions();
for (Object option : options) {
driver.findElement(byWComponent(dropdown, option)).click();
Assert.assertEquals("Incorrect option selected", option, dropdown.getSelected());
Assert.assertEquals("Incorrect text field text", option, driver.findElement(byWComponentPath("WDropdownOptionsExample/WPanel[1]")).getText());
}
} finally {
UIContextHolder.popContext();
}
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownSpaceHandlingExample_Test method testDropdown.
@Test
public void testDropdown() {
WDropdownSpaceHandlingExample example = (WDropdownSpaceHandlingExample) getUi();
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
try {
WDropdown dropdown = (WDropdown) TreeUtil.findWComponent(example, new String[] { "WDropdown" }).getComponent();
List<?> options = dropdown.getOptions();
for (Object option : options) {
driver.findElement(byWComponent(dropdown, option)).click();
driver.findElement(byWComponentPath("WButton")).click();
Assert.assertEquals("Incorrect option selected", option, dropdown.getSelected());
}
} finally {
UIContextHolder.popContext();
}
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testThreeArgOrCondition.
@Test
public void testThreeArgOrCondition() {
builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\" or WDropdown=\"3\")", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testAndOperatorPrecedenceBoth.
/**
* Tests for correct operator precedence when there are ANDs on both sides of the OR: a {@literal &}{@literal &} b
* || c {@literal &}{@literal &} d.
*/
@Test
public void testAndOperatorPrecedenceBoth() {
builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2").or().equals(new WDropdown(), "3").and().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "((WTextField=\"1\" and WTextArea=\"2\") or (WDropdown=\"3\" and WMultiSelect=\"4\"))", builder.build().toString());
}
Aggregations