Q&A ForumCategory: Seleniumgetting-error-when-we-use-explicitly-wait-method
yogesh asked 4 months ago

Exception in thread \”main\” java.lang.Error: Unresolved compilation problem:
The method until(Function<? super WebDriver,V>) in the type FluentWait<WebDriver> is not applicable for the arguments (ExpectedCondition<WebElement>) at Myproject/selenium.Demo.main(Demo.java:20)   Here is the program:
package selenium;
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.WebDriverWait;
public class Demo {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
System.setProperty(\"webdriver.chrome.driver\",\"c:\\\\users\\\\yogesha\\\\selenium\\\\chromedriver.exe\");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
Thread.sleep(5000);
WebElement username=driver.findElement(By.xpath(\"//input[@aria-label=\\\"Email or phone\\\"]\"));
WebDriverWait wait=new WebDriverWait(driver,10);wait.until(ExpectedConditions.visibilityOf(username));
}
}

Print Friendly, PDF & Email
1 Answers
Shekhar SharmaShekhar Sharma Staff answered 4 months ago

Hi Yogesh,

There are lot of mistakes in your code. I have reformatted it. Just change the chromedriver path in the below code and try again to run it. You are also not opening any application in the browser. Add ‘driver.get(“your application url”) in your code and try again. let me know if you face any other issue.


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.WebDriverWait;
public class testingpool {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"/chromedriver");
WebDriver driver=new ChromeDriver();
driver.get("https://www.google.com");
driver.manage().window().maximize();
Thread.sleep(5000);
WebElement username=driver.findElement(By.xpath("//input[@aria-label='Email or phone']"));
WebDriverWait wait=new WebDriverWait(driver,10);
wait.until(ExpectedConditions.visibilityOf(username));
}

}

Print Friendly, PDF & Email
Your Answer

1 + 8 =