Example usage for org.openqa.selenium WebElement findElements

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

Introduction

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

Prototype

@Override
List<WebElement> findElements(By by);

Source Link

Document

Find all elements within the current context using the given mechanism.

Usage

From source file:com.cognifide.qa.bb.aem.ui.AemDialog.java

License:Apache License

private List<WebElement> getAllTabs() {
    bobcatWait.withTimeout(Timeouts.BIG)
            .until(ExpectedConditions.visibilityOfElementLocated(DIALOG_XPATH_COMPILED));
    WebElement dialog = webDriver.findElement(DIALOG_XPATH_COMPILED);
    return dialog.findElements(
            By.cssSelector("div.x-tab-panel-header span.x-tab-strip-inner span.x-tab-strip-text"));
}

From source file:com.cognifide.qa.bb.expectedconditions.CommonExpectedConditions.java

License:Apache License

/**
 * Check if element located by specified By locator exists in DOM in an
 * element's context/*w  ww .  jav a  2s.  c  o  m*/
 *
 * @param scope scope in which element will be searched for
 * @param locator {@link By} locator of the searched element
 * @return false if element does not exist or WebDriver is null
 */
public static ExpectedCondition<Boolean> scopedElementLocatedByNotPresent(final WebElement scope,
        final By locator) {
    return driver -> scope.findElements(locator).isEmpty();
}

From source file:com.cognifide.qa.bb.expectedconditions.CommonExpectedConditions.java

License:Apache License

/**
 * List of WebElements found in provided scope using provided locator is
 * constant//ww  w .j a va  2s. com
 *
 * @param element WebElement to set scope for elements finder
 * @param byElement By selector
 * @return true if list of WebElements is the same after one second
 */
public static ExpectedCondition<Boolean> listSizeIsConstant(final WebElement element, final By byElement) {
    return driver -> {
        int before = element.findElements(byElement).size();
        BobcatWait.sleep(1);
        int after = element.findElements(byElement).size();
        return before == after;
    };
}

From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java

License:Apache License

/**
 * Checks the condition list for the given values.
 * @param checked All the conditions that are checked
 * @param unchecked All the conditions that are in the list but not checked
 *///from w ww  .ja v a 2s .co m
public void verifyConditions(String[] checked, String[] unchecked) {

    WebElement conditionList = driver.findElementByClassName(IndexPage.CONDITION_LIST);
    List<WebElement> conditions = conditionList.findElements(By.tagName("div"));
    Assert.assertEquals(conditions.size(), checked.length + unchecked.length);
    verifyConditions(conditions, checked, true);
    verifyConditions(conditions, unchecked, false);
}

From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java

License:Apache License

public void checkConditions(boolean check, String... conditionTexts) {
    WebElement conditionList = driver.findElementByClassName(IndexPage.CONDITION_LIST);
    List<WebElement> conditions = conditionList.findElements(By.tagName("div"));

    for (String conditionText : conditionTexts) {
        WebElement condition = getCondition(conditions, conditionText, true);
        WebElement conditionCheckBox = condition.findElement(By.className(IndexPage.CONDITION_CHECK_BOX));
        if (conditionCheckBox.isSelected() != check) {
            conditionCheckBox.click();//from ww w .  j  a  v  a2 s  .  c om
        }
    }
}

From source file:com.comcast.dawg.house.LoginPageIT.java

License:Apache License

/**
 * @author Kevin Pearson/*  w  w w  .  j  av a2s .  co  m*/
 * @throws IOException
 */
@Test(description = "Tests if a user can input a user name and click enter to log in", groups = "uitest")
public void testLogin() throws IOException {
    String user = "integrationuser";

    RemoteWebDriver driver = drivers.get();
    driver.get(TestServers.getHouse());
    loginWithUserName(driver, user);
    String expectedNewPageUrl = TestServers.getHouse() + user + "/";
    Assert.assertEquals(driver.getCurrentUrl(), expectedNewPageUrl);
    WebElement userInfo = driver.findElementByClassName(IndexPage.USER_SECTION_CLASS);
    List<WebElement> spans = userInfo.findElements(By.tagName(Tag.SPAN.toString()));
    Assert.assertFalse(spans.isEmpty());
    WebElement userDisplaySpan = spans.get(0); // the first span should show the user name
    Assert.assertEquals(userDisplaySpan.getText(), user);
}

From source file:com.comcast.dawg.house.pages.IndexPage.java

License:Apache License

/**
 * Provides all the list of STB check box element displayed.
 *
 * @return  list of bulk checkbox displayed
 *///from   w  w  w .j  a  v a  2  s.  c  o  m
public List<WebElement> getAllStbCheckboxesInFilteredTable() {
    WebElement filterTableElement = driver.findElementByXPath(FILTERED_TABLE_DIV_ELEMENT_XPATH);

    return filterTableElement.findElements(By.xpath(BULK_CHECKBOX_INPUT_IDENTIFIER));
}

From source file:com.comcast.dawg.house.pages.ModelPage.java

License:Apache License

/**
 * Return the list of capabilities already available on loaded model overlay.
 *
 * @return  the list of capabilities.//ww  w  .  ja va  2s .c  om
 */
public List<String> getAllCapabilityNamesOnAlreadyLoadedModelOverlay() {
    List<String> capabilityList = new ArrayList<String>();
    WebElement capabilityListDiv = driver.findElement(By.id(CAPABILITY_LIST_DIV_ID));

    for (WebElement divCapability : capabilityListDiv.findElements(By.tagName(DIV_TAG_NAME))) {
        capabilityList.add(divCapability.getText());
    }

    return capabilityList;
}

From source file:com.continuuity.test.page.CreatePage.ClustertemplatesInstancePage.java

License:Apache License

public Map<String, ServiceConstraint> getServiceConstraints() {
    Map<String, ServiceConstraint> serviceConstraints = Maps.newHashMap();
    WebElement table = globalDriver.findElement(CONSTRAINT_TABLE);
    WebElement tbody = table.findElement(Constants.TBODY);
    List<WebElement> entries = tbody.findElements(Constants.TR);
    for (WebElement entry : entries) {
        List<WebElement> cols = entry.findElements(Constants.TD);

        WebElement selectElement = cols.get(0).findElement(CONTRAINT_SERVICE);
        String service = new Select(selectElement).getFirstSelectedOption().getAttribute(Constants.TEXT);

        Set<String> requiredHardwaretypes = getRequiredTypes(cols.get(1), SERVICE_HARDWARETYPE);
        if (requiredHardwaretypes.isEmpty()) {
            requiredHardwaretypes = null;
        }/*from  ww  w  .  j  a v  a 2s.co  m*/

        Set<String> requiredImagetypes = getRequiredTypes(cols.get(2), SERVICE_IMAGETYPE);
        if (requiredImagetypes.isEmpty()) {
            requiredImagetypes = null;
        }

        Integer minCount = getQuantity(cols.get(3), QUANTITY_MIN);
        Integer maxCount = getQuantity(cols.get(4), QUANTITY_MAX);

        serviceConstraints.put(service, new ServiceConstraint(requiredHardwaretypes, requiredImagetypes,
                minCount, maxCount, null, null));
    }
    return serviceConstraints;
}

From source file:com.continuuity.test.page.CreatePage.ClustertemplatesInstancePage.java

License:Apache License

private Set<Set<String>> getLayoutConstraint(By group, By entry) {
    Set<Set<String>> constraints = Sets.newHashSet();
    for (WebElement groupElement : globalDriver.findElements(group)) {
        Set<String> constraint = Sets.newHashSet();
        for (WebElement element : groupElement.findElements(entry)) {
            constraint.add(element.getAttribute(Constants.INNER_HTML));
        }/*from ww  w  .  j av a 2s .c om*/
        if (!constraint.isEmpty()) {
            constraints.add(constraint);
        }
    }
    return constraints;
}