Example usage for org.openqa.selenium WebElement isEnabled

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

Introduction

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

Prototype

boolean isEnabled();

Source Link

Document

Is the element currently enabled or not?

Usage

From source file:org.alfresco.po.share.search.CopyOrMoveFailureNotificationPopUp.java

License:Open Source License

/**
 * Select "ok".//from  www  .  j  a  v  a  2  s  .c om
 * 
 * @param action
 * @return - HtmlPage
 */
public HtmlPage selectOk() {
    try {
        WebElement selectok = driver.findElement(OK_BUTTON);

        if (selectok.isEnabled() && selectok.isDisplayed()) {
            selectok.click();
            return factoryPage.getPage(driver);
        }

        throw new PageException("Ok Button found, but is not enabled");
    } catch (TimeoutException e) {
        logger.error(" : " + "Not able to find Ok Button");
        throw new PageException("Not able to find Ok Button", e);
    }
}

From source file:org.alfresco.po.share.search.CreateNewFilterPopUpPage.java

License:Open Source License

/**
 * Select Site name from drop down.//  www. ja  v  a2  s . c  o  m
 *
 * @param siteName String
 * @return CreateNewFilterPopUpPage
 */
public CreateNewFilterPopUpPage selectSiteNameAndSave(String siteName) {

    PageUtils.checkMandatoryParam("siteName", siteName);
    try {
        // Find the select control
        WebElement selectControl = findAndWait(SITE_DD_CTRL);
        // WebElement selectCancel = findAndWait(CANCEL_SITE);

        selectControl.click();

        // Find the pop up menu
        WebElement popupMenu = findAndWait(SITE_POP_UP);

        // Get the pop up menu items
        List<WebElement> menuItems = popupMenu.findElements(POP_UP_SITES_DD);

        // Iterate pop up menu items
        for (WebElement menuItem : menuItems) {
            if (menuItem.getText().equalsIgnoreCase(siteName)) {
                menuItem.click();
                WebElement selectSave = findAndWait(SAVE_SITE);
                if (selectSave.isDisplayed() && selectSave.isEnabled()) {
                    selectSave.click();
                }
                return this;

            }
        }

    } catch (NoSuchElementException ne) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to select the site from drop down" + ne);
        }
    } catch (TimeoutException e) {
        if (logger.isTraceEnabled()) {
            logger.trace("Unable to select the site from drop down" + e.getMessage());
        }
    }

    throw new PageOperationException("Unable to select the sitefrom drop down");
}

From source file:org.alfresco.po.share.search.FacetedSearchBulkActions.java

License:Open Source License

/**
 * Checks if Options menu item is displayed.
 * /* w w w  . j av  a  2  s.  c  o  m*/
 * @return true if visible
 */
public boolean isSelectOptionEnabled(BulkSelectCheckBox option) {
    try {
        clickSelectDropDownMenu();
        if (isSelectMenuEnabled()) {
            WebElement bulkSelect = driver.findElement(By.cssSelector(option.getOption()));
            return bulkSelect.isEnabled();
        }
    } catch (NoSuchElementException nse) {
        if (logger.isTraceEnabled()) {
            logger.trace("Option is not present. ", nse);
        }
    }
    return false;
}

From source file:org.alfresco.po.share.site.AddGroupsPage.java

License:Open Source License

/**
 * @param groupDisplayName String//from   w ww  .j  a v  a2s. c om
 * @return AddGroupsPage
 */
public AddGroupsPage addGroupToSite(String groupDisplayName) {
    if (StringUtils.isEmpty(groupDisplayName)) {
        throw new IllegalArgumentException("Enter value of group Display Name");
    }
    try {
        List<WebElement> searchResultRows = driver.findElements(By.cssSelector(SEARCH_RESULT_ROW));
        for (WebElement row : searchResultRows) {
            String resultGroupName = row.findElement(By.cssSelector(GROUP_DISPLAY_NAME)).getText();
            if (groupDisplayName.equals(resultGroupName)) {
                WebElement addButton = row.findElement(By.cssSelector(ADD_BUTTON));
                if (addButton.isEnabled()) {
                    addButton.click();
                    return factoryPage.instantiatePage(driver, AddGroupsPage.class);
                } else {
                    throw new PageException("Group is already added");
                }
            }
        }
    } catch (TimeoutException toe) {
        throw new PageOperationException("Not visible Element:" + SEARCH_RESULT_ROW, toe);
    }
    throw new PageException("Group does not exist!!");
}

From source file:org.alfresco.po.share.site.AddGroupsPage.java

License:Open Source License

public void clickAddGroupsButton() {
    try {/*from w w  w .j  a  v a  2s.c  o  m*/

        WebElement addGroupsButton = findAndWait(By.cssSelector(ADD_GROUP));
        if (addGroupsButton.isEnabled()) {
            addGroupsButton.click();
            waitUntilAlert();
        } else {
            throw new PageOperationException("Add Group is disabled!!");
        }
    } catch (TimeoutException nse) {
        throw new PageOperationException("Not found element is : " + ADD_GROUP, nse);
    }
}

From source file:org.alfresco.po.share.site.AddGroupsPage.java

License:Open Source License

/**
 * @param groupDisplayName String/*from   w  w  w.j a  v a2 s .c o  m*/
 * @return boolean
 */
public boolean isGroupAdded(String groupDisplayName) {
    try {
        searchGroup(groupDisplayName);
        List<WebElement> searchResultRows = findAndWaitForElements(By.cssSelector(SEARCH_RESULT_ROW));
        for (WebElement row : searchResultRows) {
            String resultGroupName = row.findElement(By.cssSelector(GROUP_DISPLAY_NAME)).getText();
            if (groupDisplayName.equals(resultGroupName)) {
                WebElement addButton = driver.findElement(By.cssSelector(ADD_BUTTON));
                if (!addButton.isEnabled()) {
                    return true;
                }
            }
        }
    } catch (NoSuchElementException nse) {
        throw new PageOperationException("Group not found", nse);
    }
    return false;
}

From source file:org.alfresco.po.share.site.AddGroupsPage.java

License:Open Source License

/**
 * @return boolean//from  w w w .  ja va2 s  .c om
 */
public boolean isAddGroupsButtonEnabled() {
    try {
        WebElement inviteButton = driver.findElement(By.cssSelector(ADD_GROUP));
        return inviteButton.isDisplayed() && inviteButton.isEnabled();
    } catch (NoSuchElementException e) {
        throw new PageException("Not found Element:" + ADD_GROUP, e);
    }
}

From source file:org.alfresco.po.share.site.AddGroupsPage.java

License:Open Source License

private boolean isSmThEnabledFor(String userName, String smthXpath) {
    By smthElement = By.xpath(String.format(smthXpath, userName));
    try {/* ww  w  . j  av  a  2  s. c  o  m*/
        WebElement addButton = findAndWait(smthElement, 2000);
        return addButton.isDisplayed() && addButton.isEnabled();
    } catch (TimeoutException e) {
        throw new PageException("Not found Element:" + smthElement, e);
    }
}

From source file:org.alfresco.po.share.site.contentrule.FolderRulesPage.java

License:Open Source License

private boolean isLinkCreateRuleAvailable() {
    WebElement linkCreateRule = findAndWait(LINK_CREATE_RULE_PAGE_SELECTOR);
    return (linkCreateRule.isDisplayed() && linkCreateRule.isEnabled());
}

From source file:org.alfresco.po.share.site.contentrule.FolderRulesPage.java

License:Open Source License

private boolean isLinkToRuleSetAvailable() {
    WebElement linkToRuleSet = findAndWait(LINK_TO_RULE_SET_SELECTOR);
    return (linkToRuleSet.isDisplayed() && linkToRuleSet.isEnabled());
}