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

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

Introduction

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

Prototype

public static <T> ExpectedCondition<T> refreshed(final ExpectedCondition<T> condition) 

Source Link

Document

Wrapper for a condition, which allows for elements to update by redrawing.

Usage

From source file:com.mastfrog.selenium.Utils.java

License:Open Source License

/**
 * Wait for a web page component to be refreshed
 * @param by The way to look up the element
 *///from  www .  j  a  va 2s .co  m
public void waitForRefresh(final By by) {
    wait.until(ExpectedConditions.refreshed(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver f) {
            return f.findElement(by);
        }
    }));
}

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);// w  w w .j  a  v  a 2s.  c  o  m

    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);/* ww w .  jav a 2  s  .  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 www  . j  a va  2  s  .c  o  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);/*w  w  w.j  a  v a 2s  . c  o  m*/

    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()));
}