Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list matching predicate #7

Open
vankeisb opened this issue Aug 2, 2014 · 0 comments
Open

list matching predicate #7

vankeisb opened this issue Aug 2, 2014 · 0 comments

Comments

@vankeisb
Copy link
Member

vankeisb commented Aug 2, 2014

We often need to do some strict matching on lists, like checking that all elements satisfy a condition. For example, you have a String[] as the input and you want an elemList to match a criteria that's using the String[] contents :

String[] expectedTexts = ...
new Findr(...).elemList(...).eval(new Function<Object,List<WebElement>>() {

  Object apply(List<WebElement> input) {
    if (input.size()!=expectedTexts.length) {
      return false
    }

    for (int i=0; i<expectedTexts.length; i++) {
      if (!input.get(i).getText().equals(expectedTexts[i])
        return false
    }
    return true
  }
}

Of course we'd like the check to be arbitrary, like :

f.elemList(...).whereAllMatch(new f(List<WebElement> l, WebElement e, int index)...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant