I want to use fluent wait with selenium in scala. However I am not able to convert the below code into Scala. Please help me out.
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function<WebDriver, WebElement>()
{
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
});
When I use it in Scala, I get
@BrianMcCutchon - Hi. When I use this code in Scala, it gets converted to the following,
val wait = new FluentWait[WebDriver](driver).withTimeout(30, SECONDS).pollingEvery(5, SECONDS).ignoring(classOf[Nothing])
val foo = wait.until(new Nothing() {
def apply(driver: WebDriver): WebElement = driver.findElement(By.id("foo"))
})
In this code, val wait is not resolved. Moreover, Nothing seems meaningless
I'm not talking about that Selenium's FluentWait here. For a generic fluent api in Java, it should have a default value, shouldn't it? In that case, the named parameter in Scala looks better to me. For example,
the
ignoring
argument is ignored and will get the default value ofclassOf[NoSuchElementException]
.