title: How to use Selenium's ExpectedCondition with Function.andThen?
body: <p>I don't seem to figure out how to use Selenium 3.7.1's <code>ExpectedCondition</code>s in a chain with <code>Function.andThen</code>. The minimal reduction of the issue the following compilation failure which I hope you don't consider off-topic because it's really tricky and there're no examples or docs giving me any clue:</p>
  <pre><code>WebElement webElement0 = null;
  Function&lt;WebDriver, WebElement&gt; function0 = ExpectedConditions.visibilityOf(webElement0);
  Function&lt;WebDriver, WebElement&gt; function1 = ExpectedConditions.visibilityOf(webElement0).andThen(ExpectedConditions.elementToBeClickable(webElement0));
  </code></pre>
  <p>fails due to</p>
  <pre><code>richtercloud/selenium/and/then/NewMain.java:[25,97] method andThen in interface java.util.function.Function&lt;T,R&gt; cannot be applied to given types;
    required: java.util.function.Function&lt;? super org.openqa.selenium.WebElement,? extends V&gt;
    found: org.openqa.selenium.support.ui.ExpectedCondition&lt;org.openqa.selenium.WebElement&gt;
    reason: cannot infer type-variable(s) V
      (argument mismatch; org.openqa.selenium.support.ui.ExpectedCondition&lt;org.openqa.selenium.WebElement&gt; cannot be converted to java.util.function.Function&lt;? super org.openqa.selenium.WebElement,? extends V&gt;)
  </code></pre>
  <p>Since <code>andThen</code> has the signature <code>public &lt;V&gt; Function&lt;T,V&gt; andThen(Function&lt;? super R,? extends V&gt; after)</code> adding <code>ExpectedConditions.visibilityOf(webElement0).&lt;WebElement&gt;andThen(ExpectedConditions.elementToBeClickable(webElement0));</code> should help, but fails due to</p>
  <pre><code>richtercloud/selenium/and/then/NewMain.java:[20,157] incompatible types: org.openqa.selenium.support.ui.ExpectedCondition&lt;org.openqa.selenium.WebElement&gt; cannot be converted to java.util.function.Function&lt;? super org.openqa.selenium.WebElement,? extends org.openqa.selenium.WebElement&gt;
  </code></pre>
  <p>Why does the <code>Function</code> passed to <code>andThen</code> want to have <code>&lt;? super WebElement, ? extends V&gt;</code> when all other <code>Function</code>s returned from <code>ExpectedConditions</code> use something derived from <code>WebDriver</code> as first and the outcome as seconds argument.</p>
  <p>I'm aware that it's easy to work around this issue. I'd like to broaden my skills to write shorter code which is imo easier to understand.</p>