I just installed the Selenium JAR file, and I copied a small program off the Internet to test if everything was fine. I ran into this issue and the Internet did not give a concrete solution. The following program is what I copied.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
import java.time.Duration;
public class sample {
public static void main(String args[]) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
try {
driver.get("https://google.com/ncr");
driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("//a/h3")));
System.out.println(firstResult.getAttribute("textContent"));
} finally {
driver.quit();
}
}
}
I get an error saying "the constructor webdriverwait(webdriver duration) is undefined" even though I imported the correct files. How can I fix it?