Example usage for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

Introduction

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

Prototype

public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is present on the DOM of a page.

Usage

From source file:org.joinfaces.example.view.HiCCPage.java

License:Apache License

public HiCCPage waitLoad() {
    new WebDriverWait(webDriver, 10000).until(ExpectedConditions.presenceOfElementLocated(getHiCCDivBy()));

    return this;
}

From source file:org.joinfaces.example.view.WelcomeConverterPage.java

License:Apache License

public WelcomeConverterPage waitLoad() {
    new WebDriverWait(webDriver, 10000).until(ExpectedConditions.presenceOfElementLocated(getOutputTextBy()));

    return this;
}

From source file:org.jtalks.tests.jcommune.webdriver.action.Topics.java

License:Open Source License

@Step
public static void editPost(Topic topic, Post postToEdit) {
    openRequiredTopic(topic);/*from  w  ww.  ja va2  s  .  c om*/

    postPage.clickEditInPostContainingString(postToEdit.getPostContent());
    try {
        (new WebDriverWait(driver, 40)).until(ExpectedConditions.refreshed(
                ExpectedConditions.presenceOfElementLocated(By.xpath(TopicPage.backButtonOnEditFormSel))));
    } catch (TimeoutException e) {
        info("Edit post method failed by timeout after button [edit] was clicked.");
        throw e;
    }
    String newPostContent = randomAlphanumeric(100);
    topicPage.editPostMessageBody(newPostContent);
    topicPage.clickAnswerToTopicButton();
    for (int i = 0; i < topic.getPosts().size(); i++) {
        if (topic.getPosts().get(i).getPostContent().equals(postToEdit.getPostContent())) {
            topic.getPosts().get(i).setPostContent(newPostContent);
            break;
        }
    }
    (new WebDriverWait(driver, 20)).until(ExpectedConditions.visibilityOf(postPage.getFirstPost()));
}

From source file:org.jtalks.tests.jcommune.webdriver.action.Topics.java

License:Open Source License

@Step
public static void moveTopic(Topic topic) {
    openRequiredTopic(topic);//from   w w w.j  a  va 2s.c o  m
    postPage.openMoveTopicEditorDialog();
    String newBranchName = moveTopicEditor.chooseBranchIndex(0);
    moveTopicEditor.clickConfirmMoveButton();
    info("Waiting for the page being refreshed and move performed successfully");
    try {
        (new WebDriverWait(driver, 40))
                .until(ExpectedConditions.refreshed(ExpectedConditions.presenceOfElementLocated(By
                        .xpath(PostPage.branchNameSel + "[contains(text(),'" + newBranchName.trim() + "')]"))));
    } catch (TimeoutException e) {
        info("Move method failed by timeout after button [move] was clicked.");
        throw e;
    }
    topic.withBranch(newBranchName);
}

From source file:org.jtalks.tests.jcommune.webdriver.action.Topics.java

License:Open Source License

@Step
public static void moveTopic(Topic topic, String newBranchName) {
    openRequiredTopic(topic);//from   w  w  w .j a va  2 s  .  co m
    postPage.openMoveTopicEditorDialog();
    moveTopicEditor.chooseBranch(newBranchName);
    moveTopicEditor.clickConfirmMoveButton();
    info("Waiting for the page being refreshed and move performed successfully");
    try {
        (new WebDriverWait(driver, 40))
                .until(ExpectedConditions.refreshed(ExpectedConditions.presenceOfElementLocated(By
                        .xpath(PostPage.branchNameSel + "[contains(text(),'" + newBranchName.trim() + "')]"))));
    } catch (TimeoutException e) {
        info("Move method failed by timeout after button [move] was clicked.");
        throw e;
    }
    topic.withBranch(newBranchName);
}

From source file:org.jtalks.tests.jcommune.webdriver.action.Topics.java

License:Open Source License

public static void editCodeReviewComment(CodeReview codeReview, CodeReviewComment codeReviewComment) {
    openRequiredTopic(codeReview);/*from w  ww .  ja v a 2s . c om*/

    postPage.clickEditInCodeReviewCommentContainingString(codeReviewComment.getPostContent());
    try {
        (new WebDriverWait(driver, 20)).until(ExpectedConditions.refreshed(
                ExpectedConditions.presenceOfElementLocated(By.xpath(PostPage.codeReviewCommentTextFieldSel))));
    } catch (TimeoutException e) {
        info("Edit post method failed by timeout after button [edit] was clicked.");
        throw e;
    }
    String newCommentContent = randomAlphanumeric(100);
    postPage.editCodeReviewCommentBody(newCommentContent);
    postPage.clickOkButtonInEditComment();
    for (int i = 0; i < codeReview.getComments().size(); i++) {
        if (codeReview.getComments().get(i).getPostContent().equals(codeReviewComment.getPostContent())) {
            codeReview.getComments().get(i).setPostContent(newCommentContent);
            break;
        }
    }
    (new WebDriverWait(driver, 20)).until(ExpectedConditions.visibilityOf(postPage.getFirstPost()));
}

From source file:org.keycloak.quickstart.ArquillianAngular2Test.java

License:Apache License

private void waitNg2Init() {
    try {/*  w  w w.j  av  a2  s  . c o m*/
        Graphene.waitModel().withTimeout(60, TimeUnit.SECONDS)
                .until(ExpectedConditions.presenceOfElementLocated(By.id("accountBtn")));
    } catch (TimeoutException e) {
        debugTest(e);
        fail();
    }
}

From source file:org.kie.smoke.wb.selenium.util.Waits.java

License:Apache License

public static WebElement elementPresent(WebDriver driver, By locator, int timeoutSeconds) {
    WebElement elementPresent = new WebDriverWait(driver, timeoutSeconds)
            .until(ExpectedConditions.presenceOfElementLocated(locator));
    return elementPresent;
}

From source file:org.kie.wb.selenium.util.Waits.java

License:Apache License

public static WebElement elementPresent(By locator, int timeoutSeconds) {
    WebElement elementPresent = new WebDriverWait(GrapheneUtil.getDriver(), timeoutSeconds)
            .until(ExpectedConditions.presenceOfElementLocated(locator));
    return elementPresent;
}

From source file:org.kurento.room.test.RoomTest.java

License:Open Source License

protected WebElement findElement(String label, WebDriver browser, String id) {
    try {//from   w  ww . jav a2  s.  co  m
        return (new WebDriverWait(browser, TEST_TIMEOUT, FIND_LATENCY))
                .until(ExpectedConditions.presenceOfElementLocated(By.id(id)));
    } catch (org.openqa.selenium.TimeoutException e) {
        log.warn("Timeout when waiting for element {} to exist in browser {}", id, label);
        try {
            WebElement elem = browser.findElement(By.id(id));
            log.info("Additional findElement call was able to locate {} in browser {}", id, label);
            return elem;
        } catch (NoSuchElementException e1) {
            log.debug("Additional findElement call couldn't locate {} in browser {} ({})", id, label,
                    e1.getMessage());
            throw new NoSuchElementException("Element with id='" + id + "' not found after " + TEST_TIMEOUT
                    + " seconds in browser " + label);
        }
    }
}