Search in sources :

Example 21 with SeleniumWComponentsWebDriver

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

the class InfoDump_Test method testExample.

@Test
public void testExample() {
    // Launch the web browser to the LDE
    SeleniumWComponentsWebDriver driver = getDriver();
    Assert.assertEquals("Incorrect default text", "", driver.findWTextArea(byWComponentPath("WTextArea")).getText());
    driver.findElement(byWComponentPath("WButton[1]")).click();
    String text = driver.findWTextArea(byWComponentPath("WTextArea")).getText();
    Assert.assertTrue("Text should contain dump info", text.contains("WEnvironment"));
    UIContext uic = getUserContextForSession();
    UIContextHolder.pushContext(uic);
    try {
        Environment env = getUi().getEnvironment();
        Assert.assertTrue("Incorrect AppId", text.contains("AppId: " + env.getAppId()));
    } finally {
        UIContextHolder.popContext();
    }
    driver.findElement(byWComponentPath("WButton[0]")).click();
    Assert.assertEquals("Text should have been cleared", "", driver.findWTextArea(byWComponentPath("WTextArea")).getText());
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) UIContext(com.github.bordertech.wcomponents.UIContext) Environment(com.github.bordertech.wcomponents.Environment) Test(org.junit.Test)

Example 22 with SeleniumWComponentsWebDriver

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

the class SimplePaginationTableWithSelectablesExample_Test method testActionConstraintsAcrossPagesWithoutRefresh.

@Test
public void testActionConstraintsAcrossPagesWithoutRefresh() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWTableWebElement wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='1']")).click();
    wTableWebElement.getNextPageButton().click();
    driver.waitForPageReady();
    Assert.assertTrue("Select and delete buttons should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled());
    Assert.assertFalse("Edit button should be disabled", driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
    // Needs to be added after ajax/refresh to prevent StaleElementReferenceException
    wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='5']")).click();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='6']")).click();
    Assert.assertFalse("Select button should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement.getPreviousPageButton().click();
    driver.waitForPageReady();
    Assert.assertFalse("Select button should be disabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    Assert.assertTrue("Select button should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    wTableWebElement.getLastPageButton().click();
    Assert.assertFalse("Select and Edit Buttons should be disabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
    Assert.assertTrue("Delete button should be enabled", driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled());
    driver.clearUserContext();
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWTableWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement) Test(org.junit.Test)

Example 23 with SeleniumWComponentsWebDriver

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

the class SimplePaginationTableWithSelectablesExample_Test method testButtonsDisabledOnLoad.

@Test
public void testButtonsDisabledOnLoad() {
    SeleniumWComponentsWebDriver driver = getDriver();
    // List<SeleniumWComponentWebElement> buttons = driver.findElement(byWComponentPath("WButton"));
    Assert.assertFalse("Buttons should be disabled on initial load", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
    SeleniumWTableWebElement wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[role='row']")).click();
    Assert.assertTrue("Buttons should be enabled", driver.findElement(byWComponentPath("WButton[1]")).isEnabled());
    driver.clearUserContext();
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWTableWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement) Test(org.junit.Test)

Example 24 with SeleniumWComponentsWebDriver

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

the class SimplePaginationTableWithSelectablesExample_Test method testActionConstraintsAcrossPagesWithRefresh.

@Test
public void testActionConstraintsAcrossPagesWithRefresh() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWTableWebElement wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='1']")).click();
    wTableWebElement.getNextPageButton().click();
    driver.waitForPageReady();
    driver.findElement(byWComponentPath(REFRESH_BUTTON)).click();
    Assert.assertTrue("Select and delete buttons should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled());
    Assert.assertFalse("Edit button should be disabled", driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
    // Needs to be added after each refresh to prevent StaleElementReferenceException
    wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='5']")).click();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='6']")).click();
    Assert.assertFalse("Select button should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement.getPreviousPageButton().click();
    driver.waitForPageReady();
    driver.findElement(byWComponentPath(REFRESH_BUTTON)).click();
    Assert.assertFalse("Select button should be disabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement = getTable();
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    Assert.assertTrue("Select button should be enabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
    wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='0']")).click();
    wTableWebElement.getLastPageButton().click();
    driver.findElement(byWComponentPath(REFRESH_BUTTON)).click();
    Assert.assertFalse("Select and Edit Buttons should be disabled", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
    Assert.assertTrue("Delete button should be enabled", driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled());
    driver.clearUserContext();
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWTableWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement) Test(org.junit.Test)

Example 25 with SeleniumWComponentsWebDriver

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

the class SimplePaginationTableWithSelectablesExample_Test method testActionConstraintsOnSinglePage.

@Test
public void testActionConstraintsOnSinglePage() {
    SeleniumWComponentsWebDriver driver = getDriver();
    SeleniumWTableWebElement wTableWebElement = getTable();
    for (int i = 0; i < 5; i++) {
        if (i == 0) {
            Assert.assertFalse("Buttons should be disabled when nothing is selected", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
        }
        if (i == 1) {
            Assert.assertTrue("All buttons should be enabled with one item selected", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled() && driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
        }
        if (i > 1) {
            Assert.assertFalse("Edit button should be disabled with more than one item selected", driver.findElement(byWComponentPath(EDIT_BUTTON)).isEnabled());
            Assert.assertTrue("Delete button should be enabled with more than one item selected", driver.findElement(byWComponentPath(DELETE_BUTTON)).isEnabled());
        }
        if ((i > 0) && (i < 4)) {
            Assert.assertTrue("Select button should be enabled with 1 to 3 items selected", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
        }
        if (i >= 4) {
            Assert.assertFalse("Select button should be disabled with 4 or more items selected", driver.findElement(byWComponentPath(SELECT_BUTTON)).isEnabled());
        }
        wTableWebElement.getTable().findElement(By.cssSelector("tr[data-wc-rowindex='" + i + "']")).click();
    }
    driver.clearUserContext();
}
Also used : SeleniumWComponentsWebDriver(com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver) SeleniumWTableWebElement(com.github.bordertech.wcomponents.test.selenium.element.SeleniumWTableWebElement) 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