0

I get an error saying 'Cannot make a static reference to the non-static method until(Function) from the type Wait' when I use the wait method for the visibility of the date.

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;

public class ch1 {

    static WebDriver driver;

    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", "C://testing/chromedriver_win32/chromedriver.exe");
        driver = new ChromeDriver();
        try{
             driver.get("https://www.via.com");
          driver.findElement(By.xpath("//*[@id='wzrk-cancel']")).click();

        }

   finally{

            driver.manage().timeouts().implicitlyWait(5000, TimeUnit.MILLISECONDS);

            driver.findElement(By.xpath("//input[@class='ui-autocomplete-input']")).sendKeys("BLR");
            driver.findElement(By.xpath("//*[@id='round-trip-panel']/div[3]/div/div")).click();
           WebElement date = driver.findElement(By.xpath("//*[@id='depart-cal']/div[3]/div[2]/div[5]/div[text()='19']"));
           Wait.until(ExpectedConditions.visibilityOf(date));
            date.click();

        }

    }

}
seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Gaurav Thantry
  • 753
  • 13
  • 30
  • Possible duplicate of [Cannot make a static reference to the non-static method](http://stackoverflow.com/questions/4969171/cannot-make-a-static-reference-to-the-non-static-method) – SomeJavaGuy Apr 18 '17 at 09:45
  • I saw that first. But that didn't help. – Gaurav Thantry Apr 18 '17 at 09:48
  • But the `until` method in `Wait` class is not even static, even more, from what I see the `Wait` class is an interface. – Shadov Apr 18 '17 at 09:51
  • 2
    You need an instance of a concrete implementation of `Wait` to call an instance method; you can't just call it through the type name if it isn't static. – Lew Bloch Apr 18 '17 at 10:10
  • 1
    before calling `Wait.Until` try creating actual object of `WebDriverWait` class as follows : `WebDriverWait Wait = new WebDriverWait(driver,20);` – Kushal Bhalaik Apr 18 '17 at 11:49
  • Thanks a lot Khushal. That didn't strike me. I had actually initialized the object wait in the beginning, but deleted it by mistake while deleting some code. Anyways thank you. – Gaurav Thantry Apr 18 '17 at 12:40

0 Answers0