Search in sources :

Example 1 with SeleniumWRadioButtonSelectWebElement

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

the class WRadioButtonSelectExample_Test method testSelect.

@Test
public void testSelect() {
    SeleniumWRadioButtonSelectWebElement rbs = getExampleNoSelection();
    // idx
    Assert.assertFalse(rbs.isSelected(0));
    rbs.select(0);
    Assert.assertTrue(rbs.isSelected(0));
    rbs.select(1);
    Assert.assertFalse(rbs.isSelected(0));
    Assert.assertTrue(rbs.isSelected(1));
    // labelText
    Assert.assertFalse(rbs.isSelected("Outside Australia"));
    rbs.select("Outside Australia");
    Assert.assertTrue(rbs.isSelected("Outside Australia"));
    rbs.select("Victoria");
    Assert.assertFalse(rbs.isSelected("Outside Australia"));
    Assert.assertTrue(rbs.isSelected("Victoria"));
    // option
    WebElement option = rbs.getOption(0);
    Assert.assertFalse(rbs.isSelected(option));
    rbs.select(option);
    Assert.assertTrue(rbs.isSelected(option));
    WebElement option2 = rbs.getOption(1);
    Assert.assertFalse(rbs.isSelected(option2));
    rbs.select(option2);
    Assert.assertTrue(rbs.isSelected(option2));
    Assert.assertFalse(rbs.isSelected(option));
    // selecting a selected option does nothing
    rbs = getExampleWithSelection();
    Assert.assertTrue(rbs.isSelected(0));
    rbs.select(0);
    getDriver().waitForPageReady();
    Assert.assertTrue(rbs.isSelected(0));
    // disabled does nothing
    rbs = getDisabledExample();
    Assert.assertFalse(rbs.isSelected(0));
    rbs.select(0);
    Assert.assertFalse(rbs.isSelected(0));
    rbs.select(1);
    Assert.assertFalse(rbs.isSelected(0));
    Assert.assertFalse(rbs.isSelected(1));
    // read-only does nothing
    rbs = getReadOnlyExampleWithSelection();
    Assert.assertTrue(rbs.isSelected(0));
    // cannot select outside of selection.
    rbs.select(0);
    Assert.assertTrue(rbs.isSelected(0));
}
Also used : SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) Test(org.junit.Test)

Example 2 with SeleniumWRadioButtonSelectWebElement

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

the class WRadioButtonSelectExample_Test method testGetInput.

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

Example 3 with SeleniumWRadioButtonSelectWebElement

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

the class WRadioButtonSelectExample_Test method testIsSelected.

@Test
public void testIsSelected() {
    SeleniumWRadioButtonSelectWebElement rbs = getExampleWithSelection();
    // by index
    Assert.assertTrue(rbs.isSelected(0));
    Assert.assertFalse(rbs.isSelected(1));
    // by labelText
    Assert.assertTrue(rbs.isSelected("Outside Australia"));
    Assert.assertFalse(rbs.isSelected("Victoria"));
    // by option
    WebElement option = rbs.getOption(0);
    Assert.assertTrue(rbs.isSelected(option));
    option = rbs.getOption(3);
    Assert.assertFalse(rbs.isSelected(option));
    // read only
    rbs = getReadOnlyExampleWithSelection();
    Assert.assertTrue(rbs.isSelected(0));
    Assert.assertFalse(rbs.isSelected(1));
    Assert.assertTrue(rbs.isSelected("Outside Australia"));
    Assert.assertFalse(rbs.isSelected("Victoria"));
    option = rbs.getOption(0);
    Assert.assertTrue(rbs.isSelected(option));
    // disabled - never selected
    rbs = getDisabledExample();
    // looks selected - this is the default selection but disabled is always false
    Assert.assertFalse(rbs.isSelected(0));
    Assert.assertFalse(rbs.isSelected(1));
    // by labelText
    Assert.assertFalse(rbs.isSelected("Outside Australia"));
    Assert.assertFalse(rbs.isSelected("Victoria"));
    // by option
    option = rbs.getOption(0);
    Assert.assertFalse(rbs.isSelected(option));
    option = rbs.getOption(3);
    Assert.assertFalse(rbs.isSelected(option));
}
Also used : SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) Test(org.junit.Test)

Example 4 with SeleniumWRadioButtonSelectWebElement

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

the class WRadioButtonSelectExample_Test method testClick.

@Test
public void testClick() {
    SeleniumWRadioButtonSelectWebElement rbs = getExampleNoSelection();
    // idx
    Assert.assertFalse(rbs.isSelected(0));
    rbs.clickNoWait(0);
    Assert.assertTrue(rbs.isSelected(0));
    rbs.clickNoWait(1);
    Assert.assertFalse(rbs.isSelected(0));
    Assert.assertTrue(rbs.isSelected(1));
    // labelText
    Assert.assertFalse(rbs.isSelected("Outside Australia"));
    rbs.clickNoWait("Outside Australia");
    Assert.assertTrue(rbs.isSelected("Outside Australia"));
    rbs.clickNoWait("Victoria");
    Assert.assertFalse(rbs.isSelected("Outside Australia"));
    Assert.assertTrue(rbs.isSelected("Victoria"));
    // option
    WebElement option = rbs.getOption(0);
    Assert.assertFalse(rbs.isSelected(option));
    rbs.clickNoWait(option);
    Assert.assertTrue(rbs.isSelected(option));
    WebElement option2 = rbs.getOption(1);
    Assert.assertFalse(rbs.isSelected(option2));
    rbs.clickNoWait(option2);
    Assert.assertTrue(rbs.isSelected(option2));
    Assert.assertFalse(rbs.isSelected(option));
    // clicking a selected option does nothing
    rbs = getExampleWithSelection();
    Assert.assertTrue(rbs.isSelected(0));
    rbs.clickNoWait(0);
    getDriver().waitForPageReady();
    Assert.assertTrue(rbs.isSelected(0));
    // disabled does nothing
    rbs = getDisabledExample();
    Assert.assertFalse(rbs.isSelected(0));
    rbs.clickNoWait(0);
    Assert.assertFalse(rbs.isSelected(0));
    rbs.clickNoWait(1);
    Assert.assertFalse(rbs.isSelected(0));
    Assert.assertFalse(rbs.isSelected(1));
    // read-only does nothing
    rbs = getReadOnlyExampleWithSelection();
    Assert.assertTrue(rbs.isSelected(0));
    // cannot select outside of selection.
    rbs.clickNoWait(0);
    Assert.assertTrue(rbs.isSelected(0));
}
Also used : SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) WebElement(org.openqa.selenium.WebElement) SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) Test(org.junit.Test)

Example 5 with SeleniumWRadioButtonSelectWebElement

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

the class WRadioButtonSelectExample_Test method testComponentLevelProperties.

@Test
public void testComponentLevelProperties() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWRadioButtonSelectWebElement interactive = getExampleNoSelection();
    SeleniumWRadioButtonSelectWebElement disabled = getDisabledExample();
    SeleniumWRadioButtonSelectWebElement readOnly = getReadOnlyExampleWithSelection();
    // isReadOnly
    Assert.assertFalse(interactive.isReadOnly());
    Assert.assertFalse(disabled.isReadOnly());
    Assert.assertTrue(readOnly.isReadOnly());
    // isDisabled
    Assert.assertTrue(interactive.isEnabled());
    Assert.assertFalse(disabled.isEnabled());
    Assert.assertFalse(readOnly.isEnabled());
    // isMandatory
    Assert.assertFalse(interactive.isMandatory());
    Assert.assertFalse(readOnly.isMandatory());
    Assert.assertFalse(disabled.isMandatory());
    SeleniumWRadioButtonSelectWebElement cbs = driver.findWRadioButtonSelect(new ByLabel("Mandatory selection", false));
    Assert.assertTrue(cbs.isMandatory());
}
Also used : SeleniumWRadioButtonSelectWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Aggregations

SeleniumWRadioButtonSelectWebElement (com.github.bordertech.wcomponents.test.selenium.element.SeleniumWRadioButtonSelectWebElement)6 Test (org.junit.Test)6 WebElement (org.openqa.selenium.WebElement)4 ByLabel (com.github.bordertech.wcomponents.test.selenium.ByLabel)1 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)1