Search in sources :

Example 46 with SeleniumWComponentsWebDriver

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

the class AutoReFocusExample_Test method testAutoRefocusWButton.

@Test
public void testAutoRefocusWButton() {
    SeleniumWComponentsWebDriver driver = getDriver();
    String path = "TextDuplicator/WButton";
    driver.findElement(byWComponentPath(path)).click();
    Assert.assertEquals("Incorrect focus", driver.findElement(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 47 with SeleniumWComponentsWebDriver

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

the class AutoReFocusExample_Test method testRefocusWDropdown.

@Test
public void testRefocusWDropdown() {
    SeleniumWComponentsWebDriver driver = getDriver();
    String path = "WDropdownSubmitOnChangeExample/WDropdown[0]";
    driver.findWDropdown(byWComponentPath(path)).click();
    UIContext uic = getUserContextForSession();
    UIContextHolder.pushContext(uic);
    try {
        // The dropdowns in the example need something to be selected to trigger the submit
        WComponent comp = TreeUtil.findWComponent(getUi(), path.split("/")).getComponent();
        if (comp instanceof WDropdown) {
            WDropdown dropdown = (WDropdown) comp;
            driver.findElement(byWComponentPath(path, dropdown.getOptions().get(1))).click();
        }
    } finally {
        UIContextHolder.popContext();
    }
    Assert.assertEquals("Incorrect focus", driver.findWDropdown(byWComponentPath(path)).getActiveId(), driver.switchTo(true).activeElement().getAttribute("id"));
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WDropdown(com.github.bordertech.wcomponents.WDropdown) UIContext(com.github.bordertech.wcomponents.UIContext) Test(org.junit.Test)

Example 48 with SeleniumWComponentsWebDriver

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

the class AutoReFocusRepeaterExample_Test method testAutoReFocusWDropdowns.

@Test
public void testAutoReFocusWDropdowns() {
    SeleniumWComponentsWebDriver driver = getDriver();
    String[] paths = { ROOT_PATH + "[0]/AutoReFocusExample/WDropdown", ROOT_PATH + "[1]/AutoReFocusExample/WDropdown" };
    for (String path : paths) {
        driver.findWDropdown(byWComponentPath(path)).getInputField().click();
        UIContext uic = getUserContextForSession();
        UIContextHolder.pushContext(uic);
        try {
            // The dropdowns in the example need something to be selected to trigger the submit
            WComponent comp = TreeUtil.findWComponent(getUi(), path.split("/"), false).getComponent();
            if (comp instanceof WDropdown) {
                WDropdown dropdown = (WDropdown) comp;
                driver.findElement(byWComponentPath(path, dropdown.getOptions().get(1))).click();
            }
        } finally {
            UIContextHolder.popContext();
        }
        Assert.assertEquals("Incorrect focus", driver.findWDropdown(byWComponentPath(path)).getActiveId(), driver.switchTo(true).activeElement().getAttribute("id"));
    }
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) WDropdown(com.github.bordertech.wcomponents.WDropdown) UIContext(com.github.bordertech.wcomponents.UIContext) Test(org.junit.Test)

Example 49 with SeleniumWComponentsWebDriver

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

the class CheckBoxExample_Test method testDisabledCheckBox.

@Test
public void testDisabledCheckBox() {
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertFalse("Third checkbox should be unselected", driver.findWCheckBox(byWComponentPath("WCheckBox[2]")).isSelected());
    Assert.assertFalse("Third checkbox should be disabled", driver.findWCheckBox(byWComponentPath("WCheckBox[2]")).isEnabled());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) Test(org.junit.Test)

Example 50 with SeleniumWComponentsWebDriver

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

the class CheckBoxExample_Test method testExample.

@Test
public void testExample() {
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertFalse("First checkbox should be unselected", driver.findWCheckBox(byWComponentPath("WCheckBox[0]")).isSelected());
    Assert.assertTrue("First checkbox should be enabled", driver.findWCheckBox(byWComponentPath("WCheckBox[0]")).isEnabled());
}
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