Search in sources :

Example 31 with SeleniumWComponentsWebDriver

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());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWMultiSelectPairWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 32 with SeleniumWComponentsWebDriver

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());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 33 with SeleniumWComponentsWebDriver

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());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 34 with SeleniumWComponentsWebDriver

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));
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WebElement(org.openqa.selenium.WebElement) SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 35 with SeleniumWComponentsWebDriver

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));
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WebElement(org.openqa.selenium.WebElement) SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Aggregations

SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)63 Test (org.junit.Test)62 ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)16 UIContext (com.github.bordertech.wcomponents.UIContext)9 SeleniumWComponentWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement)9 WDropdown (com.github.bordertech.wcomponents.WDropdown)6 SeleniumWCheckBoxSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement)6 WebElement (org.openqa.selenium.WebElement)5 SeleniumWTableWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement)4 SeleniumWLabelWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement)3 SeleniumWMessagesWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessagesWebElement)3 WButton (com.github.bordertech.wcomponents.WButton)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 SeleniumWMessageBoxWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessageBoxWebElement)2 SeleniumWMultiSelectPairWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMultiSelectPairWebElement)2 Environment (com.github.bordertech.wcomponents.Environment)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 SeleniumWRadioButtonSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)1 File (java.io.File)1 Date (java.util.Date)1