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.FactorySharePage.java

License:Open Source License

/**
 * Creates the appropriate page object based on the current page the {@link WebDriver} is on.
 *
 * @param driver WebDriver Alfresco unmanned web browser client
 * @return SharePage the page object response
 * @throws PageException/*w w  w .j  a v  a 2s.  c  o m*/
 */
public HtmlPage resolvePage(final WebDriver driver) throws PageException {
    // Determine if user is logged in if not return login page
    // if (driver.getTitle().toLowerCase().contains(driver.getLanguageValue("login.title")))
    if (driver.getTitle().toLowerCase().contains("login")) {
        return instantiatePage(driver, LoginPage.class);
    } else {
        // Share Error PopUp
        try {
            WebElement errorPrompt = driver.findElement(By.cssSelector(FAILURE_PROMPT));
            if (errorPrompt.isDisplayed()) {
                return instantiatePage(driver, SharePopup.class);
            }
        } catch (NoSuchElementException nse) {
        }

        // Check for Share Dialogue
        try {
            WebElement shareDialogue = driver.findElement(By.cssSelector(SHARE_DIALOGUE));
            if (shareDialogue.isDisplayed() || !driver.findElements(COPY_MOVE_DIALOGUE_SELECTOR).isEmpty()) {
                HtmlPage response = resolveShareDialoguePage(driver);
                if (response != null) {
                    return response;
                }
            }
        } catch (NoSuchElementException n) {
        }

        // Determine what page we're on based on url
        return getPage(driver.getCurrentUrl(), driver);
    }
}

From source file:org.alfresco.po.share.FactorySharePage.java

License:Open Source License

/**
 * Helper method to return right Page for Share Dialogue displayed
 *
 * @return HtmlPage/*w w  w.j  a va  2 s  .  co  m*/
 */
private HtmlPage resolveShareDialoguePage(WebDriver driver) {
    HtmlPage sharePage = null;
    try {
        List<WebElement> dialogues = driver.findElements(By.cssSelector(SHARE_DIALOGUE));
        WebElement dialogue = null;
        for (WebElement e : dialogues) {
            if (e.isDisplayed()) {
                dialogue = e;
                break;
            }
        }
        WebElement copyMoveDialogue = null;
        try {
            copyMoveDialogue = driver.findElements(COPY_MOVE_DIALOGUE_SELECTOR).get(0);
        } catch (Exception e) {
        }
        if (dialogue != null && dialogue.isDisplayed()) {
            String dialogueID = dialogue.getAttribute("id");

            if (dialogueID.contains("createSite")) {
                sharePage = instantiatePage(driver, CreateSitePage.class);
            } else if (dialogueID.contains("createFolder")) {
                sharePage = instantiatePage(driver, NewFolderPage.class);
            } else if (dialogueID.contains("upload")) {
                sharePage = instantiatePage(driver, UploadFilePage.class);
            } else if (dialogueID.contains("taggable-cntrl-picker")) {
                sharePage = instantiatePage(driver, TagPage.class);
            } else if (dialogueID.contains("editDetails") || dialogueID.contains("edit-metadata")) {
                sharePage = instantiatePage(driver, EditDocumentPropertiesPage.class);
            }

            else if (dialogueID.contains("copyMoveTo")) {
                sharePage = instantiatePage(driver, CopyOrMoveContentPage.class);
            }

            else if (dialogueID.contains("historicPropertiesViewer")) {
                sharePage = instantiatePage(driver, ViewPropertiesPage.class);
            }

            // The below dialogeId will be changed once this ACE-1047 issue is fixed.
            else if (dialogueID.contains("configDialog-configDialog_h")) {
                sharePage = instantiatePage(driver, ConfigureSiteNoticeDialogBoxPage.class);
            } else if (copyMoveDialogue != null && (copyMoveDialogue.getText().startsWith("Copy")
                    || copyMoveDialogue.getText().startsWith("Move"))) {
                sharePage = instantiatePage(driver, CopyAndMoveContentFromSearchPage.class);
            } else if (dialogueID.contains("Create New Filter")) {
                sharePage = instantiatePage(driver, CreateNewFilterPopUpPage.class);
            } else if (dialogueID.contains("cloud-folder-title")) {
                sharePage = instantiatePage(driver, DestinationAndAssigneePage.class);
            } else if (dialogueID.contains("changeType")) {
                sharePage = instantiatePage(driver, ChangeTypePage.class);
            } else if (dialogueID.contains("default-aspects")) {
                sharePage = instantiatePage(driver, SelectAspectsPage.class);
            }
            String dialogueText = dialogue.getText();

            if ("Create Site".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CreateSitePage.class);
            } else if ("Edit Site Details".equals(dialogueText)) {
                sharePage = instantiatePage(driver, EditSitePage.class);
            } else if ("Create Model".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CreateNewModelPopUp.class);
            } else if ("Create Custom Type".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CreateNewCustomTypePopUp.class);
            } else if ("Create Aspect".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CreateNewPropertyGroupPopUp.class);
            } else if ("Create Property".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CreateNewPropertyPopUp.class);
            } else if ("Edit Model".equals(dialogueText)) {
                sharePage = instantiatePage(driver, EditModelPopUp.class);
            } else if ("Edit Custom Type".equals(dialogueText)) {
                sharePage = instantiatePage(driver, EditCustomTypePopUp.class);
            } else if ("Edit Aspect".equals(dialogueText)) {
                sharePage = instantiatePage(driver, EditPropertyGroupPopUp.class);
            } else if ("Edit Property".equals(dialogueText)) {
                sharePage = instantiatePage(driver, EditPropertyPopUp.class);
            } else if ("Apply the default layout".equals(dialogueText)) {
                sharePage = instantiatePage(driver, ApplyDefaultLayoutPopUp.class);
            } else if ("Delete Model".equals(dialogueText) || "Delete Custom Type".equals(dialogueText)
                    || "Delete Aspect".equals(dialogueText) || "Delete Property".equals(dialogueText)
                    || "Delete Site".equals(dialogueText)) {
                sharePage = instantiatePage(driver, ConfirmDeletePopUp.class);
            } else if ("Clear the Layout Designer".equals(dialogueText)) {
                sharePage = instantiatePage(driver, ClearFormLayoutPopUp.class);
            } else if ("Import Model".equals(dialogueText)) {
                sharePage = instantiatePage(driver, ImportModelPopUp.class);
            } else if ("Confirm Deletion".equals(dialogueText)) {
                sharePage = instantiatePage(driver, SearchConfirmDeletePage.class);
            } else if ("Copy Failed".equals(dialogueText) || "Move Failed".equals(dialogueText)) {
                sharePage = instantiatePage(driver, CopyOrMoveFailureNotificationPopUp.class);
            } else if ("Request Sent".equals(dialogueText)) {
                sharePage = instantiatePage(driver, ConfirmRequestToJoinPopUp.class);
            }
        }
    } catch (NoSuchElementException nse) {
    }

    return sharePage;
}

From source file:org.alfresco.po.share.GroupsPage.java

License:Open Source License

/**
 * Verify list of users are displayed in Group page
 * //from w w w . j ava 2  s  .c  o m
 * @return Boolean
 */
public boolean hasMembers()

{

    try {
        WebElement element = driver.findElement(By.cssSelector(USER_NAMES));
        if (element.isDisplayed()) {
            return true;
        }

    } catch (NoSuchElementException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to find member in  list", e);
        }
    }
    return false;
}

From source file:org.alfresco.po.share.GroupsPage.java

License:Open Source License

/**
 * Verify that user was added to the group and displayed
 * /*from w  w  w  .ja v a2  s  . c om*/
 * @return Boolean
 */
public boolean isUserDisplayed(String user) {
    try {
        getCurrentPage().render();
        WebElement userElem = driver.findElement(By.xpath(String.format(USER_ADDED, user)));
        if (userElem.isDisplayed()) {
            return true;
        }
    } catch (NoSuchElementException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to find user in list", e);
        }
    }
    return false;

}

From source file:org.alfresco.po.share.InviteToAlfrescoPage.java

License:Open Source License

/**
 * Checks if the invite button is displayed.
 *
 * @return true if button is displayed//from   ww  w. j a v  a 2  s .c  o m
 */
protected boolean isPageLoaded() {
    boolean groupsFrameLoaded = false;
    try {
        WebElement element = findAndWait(INVITE_BUTTON);
        groupsFrameLoaded = element.isDisplayed();
    } catch (NoSuchElementException te) {
    }
    return groupsFrameLoaded;
}

From source file:org.alfresco.po.share.Navigation.java

License:Open Source License

/**
 * Select Manage Custom Models Page: calls appropriate method for AlfrescoVersion and user type
 * // ww  w  . ja v a2  s  .c om
 * @return the HtmlPage
 */
public HtmlPage selectManageCustomModelsPage() {
    String msg = "Unable to select appropriate menu option for manage custom models";

    try {
        //Check if modal is already open
        WebElement cancelBtn = driver
                .findElement(By.cssSelector(".footer .cancellationButton .dijitButtonNode"));
        if (cancelBtn.isDisplayed()) {
            cancelBtn.click();
        }
    } catch (Exception e) {
        //ignore as might not meet the condition
    }
    try {

        if (hasAdminToolsLink()) {
            return selectManageCustomModelsRepoAdmin();
        } else if (hasManageModelsLink()) {
            return selectManageCustomModelsNonAdmin();
        }
    } catch (NoSuchElementException e) {
        throw new PageOperationException(msg, e);
    }
    throw new UnsupportedOperationException(msg);
}

From source file:org.alfresco.po.share.NewUserPage.java

License:Open Source License

/**
 * Checks if the group search button is displayed.
 *
 * @return true if button is displayed/*from  ww  w  . ja  v a2  s .  c o m*/
 */
protected boolean isPageLoaded() {
    boolean groupsFrameLoaded = false;
    boolean pageLoaded = false;
    try {
        WebElement element = driver.findElement(By.cssSelector(GROUP_SEARCH_BUTTON));
        groupsFrameLoaded = element.isDisplayed();

        WebElement button = driver.findElement(By.cssSelector(CREATE_USER));
        pageLoaded = button.isDisplayed();
    } catch (NoSuchElementException te) {
    }
    return groupsFrameLoaded && pageLoaded;
}

From source file:org.alfresco.po.share.Pagination.java

License:Open Source License

/**
 * Checks for next or previous pagination button.
 * and verify if click able.//from  w ww  .  j  a  va  2s  . c om
 * 
 * @param driver {@link WebDriver}
 * @param css the css to find the button
 * @return true if clickable.
 */
public static boolean hasPaginationButton(WebDriver driver, final String css) {
    try {
        WebElement element = driver.findElement(By.cssSelector(PAGINATOR));
        WebElement nextPage = element.findElement(By.cssSelector(css));
        return nextPage.isDisplayed();
    } catch (NoSuchElementException nse) {
    }
    return false;
}

From source file:org.alfresco.po.share.PeopleFinderPage.java

License:Open Source License

/**
 * Checks for people finder help screen on the page.
 * /*from   ww  w .j  av a  2 s  .c o  m*/
 * @return true is splash screen is displayed
 */
protected boolean isHelpScreenDisplayed() {
    boolean screenDisplayed = false;
    try {
        WebElement element = driver.findElement(By.cssSelector("div[id$='default-help']"));
        screenDisplayed = element.isDisplayed();
    } catch (NoSuchElementException te) {
    }
    return screenDisplayed;
}

From source file:org.alfresco.po.share.PeopleFinderPage.java

License:Open Source License

/**
 * Checks if no result message is displayed.
 * //from w  w w . jav a 2  s .  com
 * @return true if the no result message is found
 */
private boolean hasNoResultMessage() {
    boolean noResults = true;
    try {
        // Search for no data message
        WebElement message = driver.findElement(By.cssSelector("tbody.yui-dt-message"));
        noResults = message.isDisplayed();
    } catch (NoSuchElementException te) {
        noResults = false;
    }
    return noResults;
}