use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WMultiSelectPairTestingExample_Test method testComponentProperties.
@Test
public void testComponentProperties() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWMultiSelectPairWebElement interactive = getExampleNoSelection();
SeleniumWMultiSelectPairWebElement disabled = getExampleDisabledWithSelection();
SeleniumWMultiSelectPairWebElement readOnly = getExampleReadOnlyWithSelection();
// isEnabled
Assert.assertTrue(interactive.isEnabled());
Assert.assertFalse(disabled.isEnabled());
Assert.assertFalse(readOnly.isEnabled());
// read-only
Assert.assertFalse(interactive.isReadOnly());
Assert.assertFalse(disabled.isReadOnly());
Assert.assertTrue(readOnly.isReadOnly());
// mandatory
Assert.assertFalse(interactive.isMandatory());
Assert.assertFalse(disabled.isMandatory());
Assert.assertFalse(readOnly.isMandatory());
SeleniumWMultiSelectPairWebElement msp = driver.findWMultiSelectPair(new ByLabel("Mandatory", false));
Assert.assertTrue(msp.isMandatory());
// hidden
Assert.assertTrue(interactive.isDisplayed());
Assert.assertTrue(disabled.isDisplayed());
Assert.assertTrue(readOnly.isDisplayed());
msp = driver.findWMultiSelectPair(new ByLabel("Hidden", false));
Assert.assertFalse(msp.isDisplayed());
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WRadioButtonSubmitOnChangeExample_Test method testExample.
@Test
public void testExample() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
// Select "ACT"
driver.findWRadioButton(byWComponentPath("WRadioButton", "ACT")).click();
// Should have round-tripped, check server and client-side states
Assert.assertTrue("Incorrect state selection on server", driver.getPageSource().contains("the heart of the nation!"));
Assert.assertTrue("Incorrect state selection on client", driver.findWRadioButton(byWComponentPath("WRadioButton", "ACT")).isSelected());
Assert.assertEquals("", driver.findWDropdown(byWComponentPath("WDropdown")).getValue());
// Select "City" from Region dropdown (no round trip)
// click the dropdown to open the options
driver.findWDropdown(byWComponentPath("WDropdown")).click();
driver.findElement(byWComponentPath("WDropdown", "City")).click();
Assert.assertEquals("City", driver.findWDropdown(byWComponentPath("WDropdown")).getValue());
// Select "NSW"
driver.findWRadioButton(byWComponentPath("WRadioButton", "NSW")).click();
// Should have round-tripped, check server and client-side states
Assert.assertFalse("Incorrect state selection on server", driver.getPageSource().contains("the heart of the nation!"));
Assert.assertTrue("Incorrect state selection on client", driver.findWRadioButton(byWComponentPath("WRadioButton", "NSW")).isSelected());
Assert.assertEquals("", driver.findWDropdown(byWComponentPath("WDropdown")).getValue());
// Select "Hunter" from Region dropdown (no round trip)
// click the dropdown to open the options
driver.findWDropdown(byWComponentPath("WDropdown")).click();
driver.findElement(byWComponentPath("WDropdown", "Hunter")).click();
Assert.assertEquals("Hunter", driver.findWDropdown(byWComponentPath("WDropdown")).getValue());
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WRadioButtonTriggerActionExample_Test method testExample.
@Test
public void testExample() {
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
// "Lunch" should be initially selected
Assert.assertTrue("Lunch should be selected by default", driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).isSelected());
// Select "Breakfast"
driver.findWRadioButton(byWComponentPath("WRadioButton[0]")).click();
Assert.assertTrue("Should have submitted 'Breakfast' to server", getMessageText().startsWith("Breakfast selected"));
// Select "Lunch"
driver.findWRadioButton(byWComponentPath("WRadioButton[1]")).click();
Assert.assertTrue("Should have submitted 'Lunch' to server", getMessageText().startsWith("Lunch selected"));
// Select "Dinner"
driver.findWRadioButton(byWComponentPath("WRadioButton[2]")).click();
Assert.assertTrue("Should have submitted 'Dinner' to server", getMessageText().startsWith("Dinner selected"));
// A round-trip should not trigger the action to update the message text (which includes a timestamp).
String oldText = getMessageText();
Assert.assertEquals("Action should not have been fired", oldText, getMessageText());
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testDeselect.
@Test
public void testDeselect() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement cbs = getExampleWithSelections();
// by option
WebElement option = cbs.getOption(0);
Assert.assertTrue(cbs.isSelected(option));
cbs.deselect(option);
Assert.assertFalse("Option should not selected", cbs.isSelected(option));
// by index
// not 0 as we used that already, not that it matters
int idx = 1;
Assert.assertTrue(cbs.isSelected(idx));
cbs.deselect(idx);
Assert.assertFalse("Option at index 'idx' should not be selected", cbs.isSelected(idx));
// by label
String labelText = "South Australia";
Assert.assertTrue(cbs.isSelected(labelText));
cbs.deselect(labelText);
Assert.assertFalse("Option labelled '" + labelText + "' should not be selected", cbs.isSelected(labelText));
// Deselecting an unselected option should not change the selection
cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
// an unselected option in this example
idx = 1;
Assert.assertFalse(cbs.isSelected(idx));
cbs.deselect(idx);
Assert.assertFalse("Option should still not be selected", cbs.isSelected(idx));
// readOnly does nothing
cbs = getExampleWithReadOnlySelection();
Assert.assertTrue(cbs.isSelected(0));
cbs.deselect(0);
getDriver().waitForPageReady();
Assert.assertTrue(cbs.isSelected(0));
}
use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.
the class WCheckBoxSelectExample_Test method testSelect.
@Test
public void testSelect() {
SeleniumWComponentsWebDriver driver = getDriver();
SeleniumWCheckBoxSelectWebElement cbs = getExampleNoSelections();
// by option
WebElement option = cbs.getOption(0);
Assert.assertFalse(cbs.isSelected(option));
cbs.select(option);
Assert.assertTrue("Option should be selected", cbs.isSelected(option));
// by index
// not 0 as we used that already, not that it matters
int idx = 1;
Assert.assertFalse(cbs.isSelected(idx));
cbs.select(idx);
Assert.assertTrue("Option at index 'idx' should be selected", cbs.isSelected(idx));
// by label
String labelText = "South Australia";
Assert.assertFalse(cbs.isSelected(labelText));
cbs.select(labelText);
Assert.assertTrue("Option labelled '" + labelText + "' should be selected", cbs.isSelected(labelText));
// Selecting a selected option should not change the selection
cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
// the selected option in this example
idx = 0;
Assert.assertTrue(cbs.isSelected(idx));
cbs.select(idx);
Assert.assertTrue("Option should still be selected", cbs.isSelected(idx));
// select disabled does nothing
cbs = getDisabledExample();
Assert.assertFalse(cbs.isSelected(0));
cbs.select(0);
getDriver().waitForPageReady();
Assert.assertFalse(cbs.isSelected(0));
// readOnly does nothing
cbs = getExampleWithReadOnlySelection();
Assert.assertTrue(cbs.isSelected(0));
cbs.select(0);
getDriver().waitForPageReady();
Assert.assertTrue(cbs.isSelected(0));
}
Aggregations