Example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait.

Prototype

public WebDriverWait(WebDriver driver, Duration timeout) 

Source Link

Document

Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.

Usage

From source file:com.codenvy.ide.pageObjects.NewProxyObjects.java

License:Open Source License

/**
 * Insert the Endpoint URL/*from  w w w  . ja va 2 s  .  com*/
 * @param endpointURL URL of the endpoint
 * @throws Exception
 */
public void insertEndpointURL(String endpointURL) throws Exception {
    try {
        endpointURLElement.sendKeys(endpointURL);
    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, 10);
        wait.until(ExpectedConditions.textToBePresentInElement(endpointURLElement, endpointURL));
    } catch (NoSuchElementException e) {
        log.error("Endpoint URL field element not found", e);
    } /* catch (Exception e) {
        throw (e);
      }*/
}

From source file:com.codenvy.ide.test.AboutDialogOpen.java

License:Open Source License

/**
 * Select the WSO2 Developer Studio menu
 *
 * @throws Exception/*  www.ja  v  a  2 s  . c  o  m*/
 */
public void selectWSO2DevStudioMenu() throws Exception {

    try {
        wso2DevStudioAction.click();
        wso2AboutAction.click();
        wso2AboutActionClick.click();
        wso2AboutActionClose.click();

    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, GWTIDConstants.WAITING_TIME_CONSTANT);
        wait.until(ExpectedConditions.elementToBeClickable(wso2DevStudioAction));
        wait.until(ExpectedConditions.elementToBeClickable(wso2AboutAction));
        wait.until(ExpectedConditions.elementToBeClickable(wso2AboutActionClick));

    } catch (Exception e) {
        logger.error("An exception was thrown in running the UI test on About dialog", e);
    }

}

From source file:com.codenvy.ide.test.NewWSO2AppServerProjectCreation.java

License:Open Source License

/**
 * tests the WSO2 App Server project creation UI
 *
 * @throws Exception//from   w  w w  .jav a 2 s.  co m
 */
public void createNewWSO2AppServerProject() {

    try {
        for (int projectTypeOrder = 1; projectTypeOrder <= GWTIDConstants.noOfAppServerProjects; projectTypeOrder++) {
            wso2FileMenu.click();
            wso2NewOption.click();
            wso2NewProjectOption.click();
            wso2NewProjectCategoriesList.click();
            String dynamicProjectXpath = GWTIDConstants.WSO2_NEW_PROJECT_TYPE_XPATH + "div[" + projectTypeOrder
                    + "]";
            wso2NewProject = driver.findElement(By.xpath(dynamicProjectXpath));
            wso2NewProject.click();
            String projectType = driver.findElement(By.xpath(dynamicProjectXpath)).getText();
            if (projectType.equals(GWTIDConstants.JAX_RS_PROJECT_TYPE)) { // because the x path for the project type might change
                enterJAXRSProjectDetails();
            } else if (projectType.equals(GWTIDConstants.JAX_WS_PROJECT_TYPE)) {
                enterJAXWSProjectDetails();
            } else if (projectType.equals(GWTIDConstants.WEB_APP_PROJECT_TYPE)) {
                enterWebAppProjectDetails();
            }
        }

    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, GWTIDConstants.WAITING_TIME_CONSTANT);
        wait.until(ExpectedConditions.elementToBeClickable(wso2FileMenu));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewOption));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectOption));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectCategoriesList));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProject));
    } catch (Exception e) {
        logger.error("An exception was thrown in running the UI test on App server Project creation", e);
    }
}

From source file:com.codenvy.ide.test.NewWSO2AppServerProjectCreation.java

License:Open Source License

/**
 * tests the JAX RS Project creation wizard
 */// w ww .ja  va  2 s .  c o m
public void enterJAXRSProjectDetails() {
    try {
        wso2NewProjectName.sendKeys(GWTIDConstants.TEST_JAXRS_PROJECT_NAME);
        wso2NewProjectDescrption.sendKeys(GWTIDConstants.TEST_PROJECT_DESCRIPTION);
        wso2NewProjectNextButton.click();
        wso2NewProjectArtifactId.sendKeys(GWTIDConstants.TEST_PROJECT_ARTIFACT_ID);
        wso2NewProjectGroupId.sendKeys(GWTIDConstants.TEST_PROJECT_GROUP_ID);
        wso2NewProjectVersionId.sendKeys(GWTIDConstants.TEST_PROJECT_VERSION_ID);
        wso2NewProjectCreateButton.click();
    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, GWTIDConstants.WAITING_TIME_CONSTANT);
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectName));
        wait.until(ExpectedConditions.elementToBeSelected(wso2NewProjectDescrption));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectNextButton));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectArtifactId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectGroupId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectVersionId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectCreateButton));
    } catch (Exception e) {
        logger.error("An exception was thrown in running the UI test on JAX RS Project creation", e);
    }
}

From source file:com.codenvy.ide.test.NewWSO2AppServerProjectCreation.java

License:Open Source License

/**
 * tests the JAX WS Project creation wizard
 *///from w  w  w . j a  va 2s . com
public void enterJAXWSProjectDetails() {
    try {
        wso2NewProjectName.sendKeys(GWTIDConstants.TEST_JAXWS_PROJECT_NAME);
        wso2NewProjectDescrption.sendKeys(GWTIDConstants.TEST_PROJECT_DESCRIPTION);
        wso2NewProjectNextButton.click();
        wso2NewProjectArtifactId.sendKeys(GWTIDConstants.TEST_PROJECT_ARTIFACT_ID);
        wso2NewProjectGroupId.sendKeys(GWTIDConstants.TEST_PROJECT_GROUP_ID);
        wso2NewProjectVersionId.sendKeys(GWTIDConstants.TEST_PROJECT_VERSION_ID);
        wso2NewProjectCreateButton.click();
    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, GWTIDConstants.WAITING_TIME_CONSTANT);
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectName));
        wait.until(ExpectedConditions.elementToBeSelected(wso2NewProjectDescrption));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectNextButton));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectArtifactId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectGroupId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectVersionId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectCreateButton));
    } catch (Exception e) {
        logger.error("An exception was thrown in running the UI test on JAX WS Project creation", e);
    }
}

From source file:com.codenvy.ide.test.NewWSO2AppServerProjectCreation.java

License:Open Source License

/**
 * tests the Web App Project creation wizard
 *//*  ww w. j a v  a  2s .  c o  m*/
public void enterWebAppProjectDetails() {
    try {
        wso2NewProjectName.sendKeys(GWTIDConstants.TEST_WEBAPP_PROJECT_NAME);
        wso2NewProjectDescrption.sendKeys(GWTIDConstants.TEST_PROJECT_DESCRIPTION);
        wso2NewProjectNextButton.click();
        wso2NewProjectArtifactId.sendKeys(GWTIDConstants.TEST_PROJECT_ARTIFACT_ID);
        wso2NewProjectGroupId.sendKeys(GWTIDConstants.TEST_PROJECT_GROUP_ID);
        wso2NewProjectVersionId.sendKeys(GWTIDConstants.TEST_PROJECT_VERSION_ID);
        wso2NewProjectCreateButton.click();
    } catch (TimeoutException toe) {
        WebDriverWait wait = new WebDriverWait(driver, GWTIDConstants.WAITING_TIME_CONSTANT);
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectName));
        wait.until(ExpectedConditions.elementToBeSelected(wso2NewProjectDescrption));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectNextButton));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectArtifactId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectGroupId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectVersionId));
        wait.until(ExpectedConditions.elementToBeClickable(wso2NewProjectCreateButton));
    } catch (Exception e) {
        logger.error("An exception was thrown in running the UI test on Web Application Project creation", e);
    }
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Wait for element./*from w ww . ja va  2s. com*/
 * 
 * @param by the by
 * @return the web element
 */
protected WebElement waitForElement(final By by) {

    WebElement element = null;
    LogUtil.log("WaitForElement : + " + this.getTimeStamp(), LogLevel.HIGH);
    for (int i = 0; i < 3; i++) {
        try {
            element = new WebDriverWait(driver, TestUtils.timeout).until(new ExpectedCondition<WebElement>() {

                public WebElement apply(WebDriver d) {

                    return d.findElement(by);
                }
            });
        } catch (Exception e) {
            TestLogger.logMsg("Wait waitForElement : + " + this.getTimeStamp());
        }
    }
    LogUtil.log("Done waitForElement : + " + this.getTimeStamp(), LogLevel.HIGH);
    return element;
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Wait for visibility.//from   w  w w  . j  av a  2 s.co  m
 * 
 * @param element the element
 */
@SuppressWarnings("unused")
protected void waitForVisibility(WebElement element) {

    LogUtil.log("Start waitForVisibility :  " + this.getTimeStamp(), LogLevel.HIGH);
    for (int i = 0; i < 3; i++) {
        try {
            WebElement myDynamicElement = (new WebDriverWait(driver, TestUtils.timeout))
                    .until(ExpectedConditions.visibilityOf(element));
        } catch (Exception e) {
            TestLogger.logMsg("Wait waitForVisibility : + " + this.getTimeStamp());
        }
    }
    LogUtil.log("Done waitForVisibility : " + this.getTimeStamp(), LogLevel.HIGH);
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Wait for element presence./*from   w  w  w. jav  a 2 s .c  om*/
 * 
 * @param element the element
 */
@SuppressWarnings("unused")
protected void waitForElementPresence(String element) {

    LogUtil.log("Start waitForElementPresence : " + this.getTimeStamp(), LogLevel.HIGH);
    for (int i = 0; i < 3; i++) {
        try {
            WebElement myDynamicElement = (new WebDriverWait(driver, TestUtils.timeout))
                    .until(ExpectedConditions.elementToBeClickable(By.id(element)));
        } catch (Exception e) {
            LogUtil.log("Wait waitForElementPresence : + " + this.getTimeStamp(), LogLevel.HIGH);
        }
    }
    LogUtil.log("Done waitForElementPresence : " + this.getTimeStamp(), LogLevel.HIGH);
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Wait for element presence./*from   w w w.  ja  v  a  2s .c o  m*/
 * 
 * @param by the by
 */
@SuppressWarnings("unused")
protected void waitForElementPresence(final By by) {

    LogUtil.log("Start waitForElementPresence : + " + this.getTimeStamp(), LogLevel.HIGH);
    for (int i = 0; i < 3; i++) {
        try {
            WebElement myDynamicElement = (new WebDriverWait(driver, TestUtils.timeout))
                    .until(ExpectedConditions.elementToBeClickable(by));
        } catch (Exception e) {
            LogUtil.log("Wait waitForElementPresence : + " + this.getTimeStamp(), LogLevel.HIGH);
        }
    }
    LogUtil.log("Done waitForElementPresence : + " + this.getTimeStamp(), LogLevel.HIGH);
}