Example usage for org.openqa.selenium WebElement isDisplayed

List of usage examples for org.openqa.selenium WebElement isDisplayed

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement isDisplayed.

Prototype

boolean isDisplayed();

Source Link

Document

Is this element displayed or not?

Usage

From source file:org.alfresco.po.share.site.discussions.ReplyDirectoryInfo.java

License:Open Source License

/**
 * Method to verify whether edit is displayed
 *
 * @return true if displayed//from   w ww  . j  a v  a  2  s  .c om
 */
public boolean isEditDisplayed() {
    try {
        WebElement editLink = findElement(EDIT_LINK);
        return editLink.isDisplayed();
    } catch (NoSuchElementException nse) {
        logger.info("'Edit' link for reply didn't find on page.");
    }
    return false;
}

From source file:org.alfresco.po.share.site.discussions.ReplyDirectoryInfo.java

License:Open Source License

/**
 * Method to verify whether delete is displayed
 *
 * @return true if displayed/*from  w w w.j a v a2s. c  o m*/
 */
public boolean isDeleteDisplayed() {
    try {
        WebElement editLink = findElement(EDIT_LINK);
        return editLink.isDisplayed();
    } catch (NoSuchElementException nse) {
        logger.info("'Delete' link for reply didn't find on page.");
    }
    return false;
}

From source file:org.alfresco.po.share.site.discussions.TopicDirectoryInfoImpl.java

License:Open Source License

/**
 * Method to verify whether edit topic is displayed
 *
 * @return boolean/*from www  . j a  v a  2s. co  m*/
 */
public boolean isEditTopicDisplayed() {
    try {
        WebElement editLink = findElement(EDIT_TOPIC);
        return editLink.isDisplayed();
    } catch (NoSuchElementException nse) {
    }
    return false;
}

From source file:org.alfresco.po.share.site.discussions.TopicDirectoryInfoImpl.java

License:Open Source License

/**
 * Method to verify whether edit topic is displayed
 *
 * @return boolean//from w w  w  .jav a 2  s  .c  om
 */
public boolean isDeleteTopicDisplayed() {
    try {
        WebElement deleteLink = findElement(DELETE_TOPIC);
        return deleteLink.isDisplayed();
    } catch (NoSuchElementException nse) {
    }
    return false;
}

From source file:org.alfresco.po.share.site.document.AbstractEditProperties.java

License:Open Source License

/**
 * Selects the save button that posts the form.
 *//*from  w  w w  . ja v a 2  s  . c o m*/
public void clickSave() {
    WebElement saveButton = findAndWait(By.cssSelector("button[id$='form-submit-button']"));
    if (saveButton.isDisplayed()) {
        submit(By.cssSelector("button[id$='form-submit-button']"), ElementState.DELETE_FROM_DOM);
        //saveButton.click();
        waitUntilAlert();
    }
}

From source file:org.alfresco.po.share.site.document.CopyOrMoveContentPage.java

License:Open Source License

/**
 * Check if Create Link button is displayed
 *
 * @return boolean/*  www.  j  a va2  s  .c om*/
 */
public boolean isCreateLinkButtonVisible() {
    try {
        WebElement button = driver.findElement(copyCreateLinkButtonCss);
        return button.isDisplayed();
    } catch (NoSuchElementException nse) {
        logger.error("Create Link button is not present", nse);
        return false;
    }
}

From source file:org.alfresco.po.share.site.document.CopyOrMoveContentPage.java

License:Open Source License

/**
 * Check if javascript message about link creation is displayed.
 *
 * @return true if message displayed//  w w  w  . j a  v  a2s.co m
 */
private boolean isMessageDisplayed() {
    try {
        WebElement messageBox = driver.findElement(messageBoxCss);
        messageText = messageBox.getText();
        return messageBox.isDisplayed();
    } catch (NoSuchElementException e) {
        logger.error("Link creation message not displayed");
        throw new NoSuchElementException("Link creation message not displayed", e);
    } catch (StaleElementReferenceException ser) {
        driver.navigate().refresh();
        return isMessageDisplayed();
    }
}

From source file:org.alfresco.po.share.site.document.DetailsPage.java

License:Open Source License

/**
 * Adding a comment to a details by selecting add to prompt the input field,
 * as this is based on a rich editor JavaScript was used to enter the
 * comment./*w w w . ja  va  2  s.  c o m*/
 *
 * @param comment String user comment
 * @return {@link HtmlPage} page response
 */
public HtmlPage addComment(final String comment) {
    WebElement addComment = null;
    WebElement tinymceaddCommentButton = null;

    try {
        addComment = findAndWait(By.cssSelector(ADD_COMMENT_BUTTON));

        if (logger.isTraceEnabled()) {
            logger.trace(String.format("Add Comment panel isDisplayed : %s ", addComment.isDisplayed()));
        }

    } catch (TimeoutException e) {
        try {
            tinymceaddCommentButton = findAndWait(By.cssSelector("button[id$='default-add-submit-button']"));

            if (logger.isTraceEnabled()) {
                logger.trace(String.format("Add Comment panel isDisplayed in tinyMCE editor : %s ",
                        tinymceaddCommentButton.isDisplayed()));
            }

        } catch (TimeoutException te) {
        }
    }

    if ((addComment != null && addComment.isDisplayed())
            || (tinymceaddCommentButton != null && tinymceaddCommentButton.isDisplayed())) {

        // String whichPage = getTitle();
        String addCommentButtonId = null;

        /*
         * Adding comment uses the rich editor to ensure it works on all
         * drivers we are using a js script to click on add comment, enter
         * comment to rich editor and double click on adding comment button
         * to submit.
         */
        String setCommentJs = String.format("tinyMCE.activeEditor.setContent('%s');", comment);
        if (addComment != null) {
            addCommentButtonId = addComment.getAttribute("id");
            String addCommentJs = String.format("document.getElementById('%s').click();", addCommentButtonId);
            executeJavaScript(addCommentJs);
        }

        executeJavaScript(setCommentJs);
        /*
         * As of Alfresco v4.2 the add comment button is enclosed in a span
         * that disables/enables the add comment button hence why we need to
         * know of it to enable the button.
         */
        driver.findElement(By.cssSelector("button[id$='_default-add-submit-button']")).click();
        // check to ensure js completed
        if (isErrorBalloonMessageDisplay()
                || addCommentButtonId != null && findAndWait(By.id(addCommentButtonId)).isDisplayed()) {
            if (logger.isTraceEnabled()) {
                logger.trace("Adding comment JavaScript executed successfully");
            }
        }
    } else {
        throw new PageException("Add comment form has not been rendered in time");
    }

    if (logger.isTraceEnabled()) {
        logger.trace("about to render new page response");
    }
    waitForPageLoad(SECONDS.convert(maxPageLoadingTime, MILLISECONDS));
    return getCurrentPage();
}

From source file:org.alfresco.po.share.site.document.DetailsPage.java

License:Open Source License

/**
 * Verify the share panel is present or not in the page.
 *
 * @return boolean//w  w w  . j a v a 2  s.  c o m
 */
public boolean isSharePanePresent() {
    try {
        WebElement sharePaneElement = driver.findElement(By.xpath(PAGE_SHARE_PANEL));
        return sharePaneElement.isDisplayed();
    } catch (NoSuchElementException exce) {
    }
    return false;

}