Search in sources :

Example 26 with SeleniumWComponentsWebDriver

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

Example 27 with SeleniumWComponentsWebDriver

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

Example 28 with SeleniumWComponentsWebDriver

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

Example 29 with SeleniumWComponentsWebDriver

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

Example 30 with SeleniumWComponentsWebDriver

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