Search in sources :

Example 1 with SeleniumWComponentsWebDriver

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

the class WMultiSelectPairTestingExample_Test method testGetOptions.

@Test
public void testGetOptions() {
    SeleniumWComponentsWebDriver driver = getDriver();
    int expected = SHAPES.length;
    // get options should get a single ArrayList containing all of the same options as in SHAPES
    Assert.assertEquals(expected, getExampleNoSelection().getOptions().size());
    Assert.assertEquals(expected, getExampleWithSelection().getOptions().size());
    Assert.assertEquals(expected, getExampleReadOnlyWithSelection().getOptions().size());
    Assert.assertEquals(expected, getExampleDisabledWithSelection().getOptions().size());
    Assert.assertEquals(expected, getExampleWithSomeSelection().getOptions().size());
    // read-only with no selection has no options
    Assert.assertTrue(CollectionUtils.isEmpty(getExampleRadOnlyNoSelection().getOptions()));
    // make sure we are not erroring when we have no options
    SeleniumWMultiSelectPairWebElement msp = driver.findWMultiSelectPair(new ByLabel("No options", false));
    Assert.assertTrue(CollectionUtils.isEmpty(msp.getOptions()));
}
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 2 with SeleniumWComponentsWebDriver

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

the class WRadioButtonSelectExample_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    // Select NT and submit
    driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Northern Territory")).click();
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertTrue("Northern Territory should be selected", driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Northern Territory")).isSelected());
    Assert.assertTrue("Incorrect selection text", driver.getPageSource().contains("The selected item is: Northern Territory"));
    // Select WA and submit
    driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Western Australia")).click();
    driver.findElement(byWComponentPath("WButton")).click();
    Assert.assertTrue("Western Australia should be selected", driver.findElement(byWComponentPath("WRadioButtonSelect[0]", "Western Australia")).isSelected());
    Assert.assertTrue("Incorrect selection text", driver.getPageSource().contains("The selected item is: Western Australia"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 3 with SeleniumWComponentsWebDriver

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

the class WCheckBoxSelectExample_Test method testGetSelected.

@Test
public void testGetSelected() {
    SeleniumWComponentsWebDriver driver = getDriver();
    // use item with default selection
    Assert.assertEquals(9, getExampleWithSelections().getSelected().size());
    // read only with selection
    Assert.assertEquals(9, getExampleWithReadOnlySelection().getSelected().size());
    // no selection
    Assert.assertTrue(CollectionUtils.isEmpty(getExampleNoSelections().getSelected()));
    // read-only, no selection
    Assert.assertTrue(CollectionUtils.isEmpty(getReadOnlyNoSelection().getSelected()));
    // single selection
    SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
    Assert.assertEquals(1, cbs.getSelected().size());
    // read-only one selection
    cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made (read only)", false));
    Assert.assertEquals(1, cbs.getSelected().size());
    // disabled always empty
    cbs = driver.findWCheckBoxSelect(new ByLabel("Disabled with many selections and COLUMN layout", false));
    Assert.assertTrue(CollectionUtils.isEmpty(cbs.getSelected()));
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 4 with SeleniumWComponentsWebDriver

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

the class WCheckBoxSelectExample_Test method testComponentLevelBooleanProperties.

@Test
public void testComponentLevelBooleanProperties() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWCheckBoxSelectWebElement interactive = getExampleNoSelections();
    SeleniumWCheckBoxSelectWebElement readOnly = getExampleWithReadOnlySelection();
    SeleniumWCheckBoxSelectWebElement disabled = getDisabledExample();
    // read-only
    Assert.assertFalse(interactive.isReadOnly());
    Assert.assertTrue(readOnly.isReadOnly());
    Assert.assertFalse(disabled.isReadOnly());
    // enabled
    Assert.assertTrue(interactive.isEnabled());
    Assert.assertFalse(readOnly.isEnabled());
    Assert.assertFalse(disabled.isEnabled());
    // mandatory
    Assert.assertFalse(interactive.isMandatory());
    Assert.assertFalse(readOnly.isMandatory());
    Assert.assertFalse(disabled.isMandatory());
    SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("A selection is required", true));
    Assert.assertTrue(cbs.isMandatory());
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 5 with SeleniumWComponentsWebDriver

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

the class WCheckBoxSelectExample_Test method testClick.

@Test
public void testClick() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWCheckBoxSelectWebElement cbs = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
    // by option
    // the selected option
    WebElement option = cbs.getOption(0);
    boolean selected = cbs.isSelected(option);
    cbs.clickNoWait(option);
    Assert.assertEquals("Option selection should have changed.", !selected, cbs.isSelected(option));
    cbs.clickNoWait(option);
    Assert.assertEquals("Option selection should have changed back.", selected, cbs.isSelected(option));
    // by label
    String labelText = "New South Wales";
    selected = cbs.isSelected(labelText);
    cbs.clickNoWait(labelText);
    Assert.assertEquals("Option with label '" + labelText + "' selection should have changed.", !selected, cbs.isSelected(labelText));
    cbs.clickNoWait(labelText);
    Assert.assertEquals("Option with label '" + labelText + "' selection should have changed back.", selected, cbs.isSelected(labelText));
    // by index
    int idx = 3;
    selected = cbs.isSelected(idx);
    cbs.clickNoWait(idx);
    Assert.assertEquals("Option with index '" + String.valueOf(idx) + "' selection should have changed.", !selected, cbs.isSelected(idx));
    cbs.clickNoWait(idx);
    Assert.assertEquals("Option with index '" + String.valueOf(idx) + "' selection should have changed back.", selected, cbs.isSelected(idx));
    // disabled does nothing
    cbs = getDisabledExample();
    Assert.assertFalse(cbs.isSelected(0));
    cbs.clickNoWait(0);
    getDriver().waitForPageReady();
    Assert.assertFalse(cbs.isSelected(0));
    // readOnly does nothing
    cbs = getExampleWithReadOnlySelection();
    Assert.assertTrue(cbs.isSelected(0));
    cbs.clickNoWait(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