Search in sources :

Example 11 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class AjaxWDropdownExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Region and suburb drop-downs should be blank to begin with
    Assert.assertTrue("Region drop-down should be empty", !driver.getPageSource().contains("Woden"));
    Assert.assertTrue("Suburb drop-down should be empty", !driver.getPageSource().contains("Torrens"));
    // Select "ACT" from State dropdown
    driver.findElement(byWComponentPath("WDropdown[0]")).click();
    driver.findElement(byWComponentPath("WDropdown[0]", "ACT")).click();
    // Select "Woden" from Region dropdown
    Assert.assertTrue("Region drop-down should contain 'Woden'", driver.getPageSource().contains("Woden"));
    Assert.assertTrue("Suburb drop-down should be empty", !driver.getPageSource().contains("Torrens"));
    driver.findElement(byWComponentPath("WDropdown[1]")).click();
    driver.findElement(byWComponentPath("WDropdown[1]", "Woden")).click();
    // Select "Torrens" from Suburb dropdown
    Assert.assertTrue("Suburb drop-down should contain 'Torrens'", driver.getPageSource().contains("Torrens"));
    driver.findElement(byWComponentPath("WDropdown[2]")).click();
    driver.findElement(byWComponentPath("WDropdown[2]", "Torrens")).click();
    // No server-side interaction for last dropdown
    Assert.assertTrue("Incorrect suburb selection on client", driver.findElement(byWComponentPath("WDropdown[2]", "Torrens")).isSelected());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 12 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class AppPreferenceParameterExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Note: When deployed to portal, the parameter "portlet.wcomponents-examples.example.preferred.state" will be used.
    String preferenceParam = Config.getInstance().getString("example.preferred.state");
    Assert.assertTrue("Incorrect default selection", driver.findElement(byWComponentPath("WDropdown", preferenceParam)).isSelected());
    driver.findElement(byWComponentPath("WDropdown")).click();
    driver.findElement(byWComponentPath("WDropdown", "")).click();
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertTrue("Incorrect default selection", driver.findElement(byWComponentPath("WDropdown", preferenceParam)).isSelected());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 13 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class AutoReFocusRepeaterExample_Test method testAutoReFocusWRadioButtons.

@Test
public void testAutoReFocusWRadioButtons() {
    SeleniumWComponentsWebDriver driver = getDriver();
    String[] paths = { ROOT_PATH + "[0]/WRadioButtonTriggerActionExample/WRadioButton", ROOT_PATH + "[1]/WRadioButtonTriggerActionExample/WRadioButton" };
    for (String path : paths) {
        driver.findWRadioButton(byWComponentPath(path)).getInputField().click();
        Assert.assertEquals("Incorrect focus", driver.findWRadioButton(byWComponentPath(path)).getActiveId(), driver.switchTo(true).activeElement().getAttribute("id"));
    }
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 14 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class CheckBoxExample_Test method testSelectedCheckBox.

@Test
public void testSelectedCheckBox() {
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertTrue("Second checkbox should be selected", driver.findWCheckBox(byWComponentPath("WCheckBox[1]")).isSelected());
    Assert.assertTrue("Second checkbox should be enabled", driver.findWCheckBox(byWComponentPath("WCheckBox[1]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 15 with SeleniumWComponentsWebDriver

use of com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver in project wcomponents by BorderTech.

the class EntryFieldExample_Test method testDefaultSubmit.

@Test
public void testDefaultSubmit() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Need to scroll the button into view, otherwise Selenium won't click it.
    driver.findWTextArea(byWComponentPath("WTextArea")).getInputField().sendKeys(" ");
    driver.findElement(byWComponentPath("WButton")).click();
    String text = driver.findWTextArea(byWComponentPath("WTextArea")).getValue();
    Assert.assertEquals("Incorrect text value", "Text 1 = blah blah" + "\nText 2 = abc" + "\nText 3 = abc" + "\nText 4 = " + "\nNumeric 1 = " + "\nNumeric 2 = " + "\nNumeric 3 = " + "\nEmail = " + "\nDrop 1 = One" + "\nMulti1 = " + "\nMulti2 = " + "\nMultiCb = " + "\nCheckboxes =" + "\n", text);
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) 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