fluent-selenium icon indicating copy to clipboard operation
fluent-selenium copied to clipboard

Update README for Java 8 functional interface

Open danizen opened this issue 6 years ago • 2 comments

Since both FluentMatcher and FluentWebElementVistor are single function interfaces, they can be used with Java 8 lambda functions. This is wonderful! kudos.

Please update the README when discussing each of these to provide an example of the lambda equivalent, e.g.

// Note that FluentMatcher is also compatible with Java 8 lambda functions:
listofMatching elements = fwd.inputs(className("bar").filter(
    (FluentWebElement el, int ix) -> true
);

And similarly for FluentWebElementVisitor.

It would also be great to provide a stream of these, but that is more complicated and might break backwards compatibility with Java 7 compilation. I'd argue that this is still worth it - if your user is still using Java 7, they are likely not keeping up with Selenium changes, but since sometimes these must be done because of new browsers, I'll let you guys decide.

danizen avatar May 17 '19 15:05 danizen

Excellent advice!!!

paul-hammant avatar May 19 '19 07:05 paul-hammant

README expanded (with some copy/paste) https://github.com/SeleniumHQ/fluent-selenium/commit/2861012fb5eaed96f63f6b774fef04983101a330

It might be OK to break backwards compatibility wit 5,6,7 now I think - re your stream() thought.

paul-hammant avatar May 19 '19 07:05 paul-hammant