use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WCheckBoxTriggerActionExample_Test method testExample.
@Test
public void testExample() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
WCheckBoxTriggerActionExample ui = (WCheckBoxTriggerActionExample) getUi();
// Select "Breakfast"
driver.findWCheckBox(byWComponent(ui.getBreakfastCheckBox())).click();
Assert.assertEquals("Should have submitted 'Breakfast' to server", "Breakfast selected", getMessageText());
// Select "Lunch"
driver.findWCheckBox(byWComponent(ui.getLunchCheckBox())).click();
Assert.assertEquals("Should have submitted 'Lunch' to server", "Lunch selected", getMessageText());
// Select "Dinner"
driver.findWCheckBox(byWComponent(ui.getDinnerCheckBox())).click();
Assert.assertEquals("Should have submitted 'Dinner' to server", "Dinner selected", getMessageText());
// De-select "Lunch"
driver.findWCheckBox(byWComponent(ui.getLunchCheckBox())).click();
Assert.assertEquals("Should have submitted 'Lunch' to server", "Lunch unselected", getMessageText());
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WDialogExample_Test method testModalDialogSearch.
@Test
public void testModalDialogSearch() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
WDialogExample example = (WDialogExample) getUi();
final WButton testButton = example.getModalButton();
// Display the modal dialog
driver.findElement(byWComponent(testButton)).click();
driver.findWTextField(byWComponentPath("WDialogExample$SelectPersonPanel/WTextField[0]")).sendKeys("First");
driver.findWTextField(byWComponentPath("WDialogExample$SelectPersonPanel/WTextField[1]")).sendKeys("Last");
driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WButton[1]")).click();
driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WRadioButtonSelect", "Last, First")).click();
driver.findElement(byWComponentPath("WDialogExample$SelectPersonPanel/WButton[1]")).click();
String message = driver.findElementImmediate(byWComponentPath("WMessageBox")).getText();
Assert.assertTrue("Incorrect message text", message.contains("Selected: Last, First"));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WDropdownOptionsExample_Test method testExampleSubmitOnChange.
/**
* submit on change test.
*/
@Test
public void testExampleSubmitOnChange() {
WDropdownOptionsExample example = (WDropdownOptionsExample) getUi();
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
WDropdown.DropdownType type = WDropdown.DropdownType.NATIVE;
configureDropDown(driver, type, 4);
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.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WDropdownSpecialCharHandlingExample_Test method testExample.
@Test
public void testExample() {
WDropdownSpecialCharHandlingExample example = (WDropdownSpecialCharHandlingExample) 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());
Assert.assertEquals("Incorrect text field text", (option == null ? "" : option), driver.findWTextField(byWComponentPath("WTextField")).getValue());
}
} finally {
UIContextHolder.popContext();
}
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WDropdownTriggerActionExample_Test method testExample.
@Test
public void testExample() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
WDropdownTriggerActionExample ui = (WDropdownTriggerActionExample) getUi();
// Select "ACT" from State dropdown
driver.findElement(byWComponent(ui.getStateDropdown(), "ACT")).click();
Assert.assertTrue("Incorrect region selection on client", driver.findElement(byWComponent(ui.getRegionDropdown(), "")).isSelected());
// Context is required for in-JVM calls to work.
// This is generally not a good test, as it relies on the JVM not on the servlet.
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
// Should have round-tripped, check server and client-side states
Assert.assertEquals("Incorrect state selection on server", "ACT", ui.getStateDropdown().getSelected());
Assert.assertTrue("Incorrect state selection on client", driver.findElement(byWComponent(ui.getStateDropdown(), "ACT")).isSelected());
// Select "Woden" from Region dropdown
driver.findElement(byWComponent(ui.getRegionDropdown(), "Woden")).click();
// Should have round-tripped, check server and client-side states
Assert.assertEquals("Incorrect region selection on server", "Woden", ui.getRegionDropdown().getSelected());
Assert.assertTrue("Incorrect region selection on client", driver.findElement(byWComponent(ui.getRegionDropdown(), "Woden")).isSelected());
// Select "Torrens" from Suburb dropdown (no round trip)
driver.findElement(byWComponent(ui.getSuburbDropdown(), "Torrens")).click();
Assert.assertTrue("Incorrect suburb selection on client", driver.findElement(byWComponent(ui.getSuburbDropdown(), "Torrens")).isSelected());
// Select "VIC" from the State dropdown
driver.findElement(byWComponent(ui.getStateDropdown(), "VIC")).click();
Assert.assertTrue("Incorrect region selection on client", driver.findElement(byWComponent(ui.getRegionDropdown(), "")).isSelected());
// Select "Melbourne" from Region dropdown
driver.findElement(byWComponent(ui.getRegionDropdown(), "Melbourne")).click();
// Select "Torrens" from Suburb dropdown (no round trip)
driver.findElement(byWComponent(ui.getSuburbDropdown(), "Blackburn")).click();
Assert.assertTrue("Incorrect suburb selection on client", driver.findElement(byWComponent(ui.getSuburbDropdown(), "Blackburn")).isSelected());
UIContextHolder.popContext();
}
Aggregations