Mira
Mira

Reputation: 131

FluentWait function cannot be used in function of Java Class

This maybe a basic question but I am not quite familiar with Java and Selenium Webdriver. I don't know why Eclipse shows Error to change 'Function' as 'Remove type arguments' by Eclipse. I want to use fluentwait as function in my class. Or what is the right way to use it?

public class Process()
   {
    public void Start()
    {
        //function call
        WebElement index = fluentWait(By.xpath("xxx"), driver);
    }   

    //function method
    public WebElement fluentWait(final By locator, WebDriver driver) {
        Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                .withTimeout(30, TimeUnit.SECONDS)
                .pollingEvery(5, TimeUnit.SECONDS)
                .ignoring(NoSuchElementException.class);

        WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
            public WebElement apply(WebDriver driver) {
                return driver.findElement(locator);
            }
        });

        return  foo;
    };
   }

Upvotes: 1

Views: 1556

Answers (1)

blalasaadri
blalasaadri

Reputation: 6218

Looks like you've failed to import com.google.common.base.Function.

Upvotes: 2

Related Questions