Search in sources :

Example 6 with SeleniumWCheckBoxSelectWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement in project wcomponents by BorderTech.

the class WCheckBoxSelectExample_Test method testGetOption.

@Test
public void testGetOption() {
    SeleniumWCheckBoxSelectWebElement interactive = getExampleNoSelections();
    SeleniumWCheckBoxSelectWebElement readOnly = getExampleWithReadOnlySelection();
    // by index
    Assert.assertNotNull(interactive.getOption(0));
    Assert.assertNotNull(readOnly.getOption(0));
    // by label
    Assert.assertNotNull(interactive.getOption("Outside Australia"));
    Assert.assertNotNull(readOnly.getOption("Outside Australia"));
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) Test(org.junit.Test)

Example 7 with SeleniumWCheckBoxSelectWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement in project wcomponents by BorderTech.

the class WCheckBoxSelectExample_Test method testGetInput.

@Test
public void testGetInput() {
    SeleniumWCheckBoxSelectWebElement cbs = getExampleNoSelections();
    // by index
    Assert.assertNotNull(cbs.getInput(0));
    // by label
    Assert.assertNotNull(cbs.getInput("Tasmania"));
    // by option
    WebElement option = cbs.getOption(0);
    Assert.assertNotNull(cbs.getInput(option));
}
Also used : SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWCheckBoxSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement) Test(org.junit.Test)

Example 8 with SeleniumWCheckBoxSelectWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement 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 9 with SeleniumWCheckBoxSelectWebElement

use of com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement 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

SeleniumWCheckBoxSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWCheckBoxSelectWebElement)9 Test (org.junit.Test)9 ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)6 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)6 WebElement (org.openqa.selenium.WebElement)6