Search in sources :

Example 6 with SeleniumWComponentsWebDriver

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

the class WCheckBoxSelectExample_Test method testIsSelected.

@Test
public void testIsSelected() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWCheckBoxSelectWebElement interactive = driver.findWCheckBoxSelect(new ByLabel("One selection was made", false));
    SeleniumWCheckBoxSelectWebElement readOnly = driver.findWCheckBoxSelect(new ByLabel("One selection was made (read only)", false));
    // by index
    Assert.assertTrue(interactive.isSelected(0));
    Assert.assertFalse(interactive.isSelected(1));
    Assert.assertTrue(readOnly.isSelected(0));
    // only one option so anything else is no selected.
    Assert.assertFalse(readOnly.isSelected(1));
    // by text
    String labelText = "Outside Australia";
    Assert.assertTrue(interactive.isSelected(labelText));
    Assert.assertFalse(interactive.isSelected("Australian Capital Territory"));
    Assert.assertTrue(readOnly.isSelected(labelText));
    Assert.assertFalse(readOnly.isSelected("Australian Capital Territory"));
    // by option
    Assert.assertTrue(interactive.isSelected(interactive.getOption(0)));
    Assert.assertFalse(interactive.isSelected(interactive.getOption(1)));
    Assert.assertTrue(readOnly.isSelected(readOnly.getOption(0)));
    // cannot test for false in read only mode
    // disabled always false
    SeleniumWCheckBoxSelectWebElement disabled = driver.findWCheckBoxSelect(new ByLabel("Disabled with many selections and COLUMN layout", false));
    int i = 0;
    for (WebElement option : disabled.getOptions()) {
        Assert.assertFalse(disabled.isSelected(option));
        Assert.assertFalse(disabled.isSelected(i++));
        Assert.assertFalse(disabled.isSelected(option.getText()));
    }
}
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 7 with SeleniumWComponentsWebDriver

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

the class WLabelExample_Test method testGetByLabelComplexPartial.

@Test
public void testGetByLabelComplexPartial() {
    String labelText = "one or more";
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WCheckBoxSelect[1]"));
    SeleniumWComponentWebElement actual = driver.findElement(new ByLabel(labelText, true));
    Assert.assertEquals(expected.getAttribute("id"), actual.getAttribute("id"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWComponentWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 8 with SeleniumWComponentsWebDriver

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

the class WLabelExample_Test method testGetComponentComplex.

@Test
public void testGetComponentComplex() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWLabelWebElement label = driver.findWLabel(byWComponentPath("WLabel[7]"));
    SeleniumWComponentWebElement expected = driver.findElement(byWComponentPath("WCheckBoxSelect[1]"));
    Assert.assertEquals(expected.getAttribute("id"), label.getLabelledComponent().getAttribute("id"));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWLabelWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWLabelWebElement) SeleniumWComponentWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWComponentWebElement) Test(org.junit.Test)

Example 9 with SeleniumWComponentsWebDriver

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

the class WMessagesExample_Test method testMessageBoxTypes.

@Test
public void testMessageBoxTypes() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWMessagesWebElement messages = driver.findWMessages(byWComponentPath("WMessages[0]"));
    List<SeleniumWMessageBoxWebElement> messageBoxes = messages.getMessageBoxes();
    Assert.assertEquals(4, messageBoxes.size());
    // first one is expected to be an error box
    Assert.assertTrue(messageBoxes.get(0).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_ERROR_CLASS_NAME));
    Assert.assertTrue(messageBoxes.get(1).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_WARNING_CLASS_NAME));
    Assert.assertTrue(messageBoxes.get(2).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_INFO_CLASS_NAME));
    Assert.assertTrue(messageBoxes.get(3).getAttribute("class").contains(SeleniumWMessageBoxWebElement.TYPE_SUCCESS_CLASS_NAME));
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWMessagesWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessagesWebElement) SeleniumWMessageBoxWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWMessageBoxWebElement) Test(org.junit.Test)

Example 10 with SeleniumWComponentsWebDriver

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

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