-1

Is there any chance and need to use something like below ?

Could you show examples how to use function thats accepts Consumer WebElement ?

private static void methodThatAcceptsConsumer (Consumer<WebElement> consumer) {
    //something here
}
javabeginer
  • 1
  • 1
  • 6

1 Answers1

0

Consumer is an interface. You can implement it as a real class, a named nested class or as lambda.

Explicit implementation as class

class MyWebElementConsumer implements Consumer<WebElement> {
  @Override
  public void accept(final WebElement element) {
    // do something with element
  }
}

methodThatAcceptsConsumer(new MyWebElementConsumer());

Pass a lambda

methodThatAcceptsConsumer(element -> {/* do something with element */});
knittl
  • 246,190
  • 53
  • 318
  • 364