Example usage for org.openqa.selenium By findElements

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

Introduction

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

Prototype

public abstract List<WebElement> findElements(SearchContext context);

Source Link

Document

Find many elements.

Usage

From source file:MobileElement.java

License:Apache License

public List<WebElement> findElements(By by) {
    return by.findElements(this);
}

From source file:com.dukescript.impl.selenium.DomNodeWebElement.java

License:Open Source License

@Override
public List<WebElement> findElements(final By by) {

    try {//  w w w.jav a2 s.  c  o  m
        final CountDownLatch countDownLatch = new CountDownLatch(1);
        RunVal<List<WebElement>> runVal = new RunVal<List<WebElement>>() {
            List<WebElement> result;

            @Override
            public List<WebElement> get() {
                return result;
            }

            @Override
            public void run() {
                result = by.findElements(DomNodeWebElement.this);
                countDownLatch.countDown();
            }
        };
        ctx.execute(runVal);
        countDownLatch.await();
        return runVal.get();
    } catch (InterruptedException ex) {
        Logger.getLogger(WebDriverFX.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:com.dukescript.impl.selenium.DukeScriptBrowser.java

License:Open Source License

@Override
public List<WebElement> findElements(final By by) {
    try {/*from   w ww.  j av  a  2  s  . c o m*/
        final CountDownLatch countDownLatch = new CountDownLatch(1);
        RunVal<List<WebElement>> runVal = new RunVal<List<WebElement>>() {
            List<WebElement> result;

            @Override
            public List<WebElement> get() {
                return result;
            }

            @Override
            public void run() {
                result = by.findElements(DukeScriptBrowser.this);
                countDownLatch.countDown();
            }
        };
        ctx.execute(runVal);
        countDownLatch.await();
        return runVal.get();
    } catch (InterruptedException ex) {
        Logger.getLogger(WebDriverFX.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:com.machinepublishers.jbrowserdriver.Element.java

License:Apache License

/**
 * {@inheritDoc}/*from  w w  w  .  j a v  a  2s. c o m*/
 */
@Override
public List<WebElement> findElements(By by) {
    return by.findElements(this);
}

From source file:com.machinepublishers.jbrowserdriver.ElementServer.java

License:Apache License

/**
 * {@inheritDoc}
 */
@Override
public List findElements(By by) {
    return by.findElements(this);
}

From source file:com.qmetry.qaf.automation.ui.webdriver.ByAny.java

License:Open Source License

@Override
public List<WebElement> findElements(SearchContext context) {
    if (locators.length == 0) {
        return new ArrayList<WebElement>();
    }/* ww w  .j a  v a2 s .c  o  m*/
    List<WebElement> elems = new ArrayList<WebElement>();

    for (String locator : locators) {
        By by = LocatorUtil.getBy(locator);
        elems.addAll(by.findElements(context));
        if (!elems.isEmpty()) {
            break;
        }
    }

    return elems;
}

From source file:com.vaadin.testbench.TestBenchDriverProxy.java

@Override
public List<WebElement> findElements(By arg0) {

    List<WebElement> elements = new ArrayList<WebElement>();

    // We can Wrap It!
    if (arg0 instanceof ByVaadin) {
        elements.addAll(TestBenchElement.wrapElements(arg0.findElements(this), this));
    } else {/*from   w  w w.  j  av a2  s.c  o m*/
        elements.addAll(TestBenchElement.wrapElements(actualDriver.findElements(arg0), this));
    }

    return elements;
}

From source file:com.vaadin.testbench.TestBenchElement.java

@Override
public List<WebElement> findElements(By by) {
    List<WebElement> elements = new ArrayList<>();
    if (by instanceof ByVaadin) {
        elements.addAll(wrapElements(by.findElements(this), getCommandExecutor()));
    } else {/*from   w ww .j  a va2  s  . c o  m*/
        elements.addAll(wrapElements(actualElement.findElements(by), getCommandExecutor()));
    }
    return elements;
}

From source file:jhc.redsniff.webdriver.finders.ByFinder.java

License:Apache License

public static Locator<WebElement, SearchContext> locatorFor(final By by) {
    String byAsString = by.toString();
    Pattern pattern = Pattern.compile("^By\\.(\\w+)\\: (.*?)$");
    Matcher regexMatcher = pattern.matcher(byAsString);
    if (!regexMatcher.matches())
        throw new IllegalArgumentException("didn't match By.xxx: <arg>");

    final String byType = regexMatcher.group(1);
    final String byArg = regexMatcher.group(2);

    if (byType.equals("id"))
        return hasId(byArg);
    else if (byType.equals("name"))
        return hasName(byArg);
    else if (byType.equals("className"))
        return hasCssClass(byArg);
    else if (byType.equals("tagName"))
        return TagNameMatcher.hasTagName(byArg);
    else//from   w ww .  j ava2 s  . c  o m
        return new Locator<WebElement, SearchContext>() {

            @Override
            public void describeLocatorTo(Description description) {
                description.appendText("found " + by.toString());
            }

            @Override
            public CollectionOf<WebElement> findElementsFrom(SearchContext context) {
                return collectionOf(by.findElements(context));
            }

            @Override
            public String nameOfAttributeUsed() {
                return byType;
            }
        };
}

From source file:net.javacrumbs.webview.driver.Browser.java

License:Apache License

@Override
public List<WebElement> findElements(By by) {
    return by.findElements(this);
}