I followed this tutorial https://www.javatpoint.com/selenium-webdriver-installation but I have a problem with the WebDriver class :
Error: Unable to initialize main class First
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
I've put the dependencies as shown in the tutorial. And if I trust the documentation of Selnium API, the WebDriver class is present in the 4.1.3 version.
I don't know if it's because the 4.1.3 version don't have the client-combiden-3.13.0.jar file or something like that... So if you have a solution, I'm in.
I'm on Windows 10, and I use Eclipse IDE version 2021-06 (4.20.0).
And this is my class First :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class First {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
System.setProperty("webdriver.chrome.driver", "/root/drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
// Launch website
driver.navigate().to("http://www.google.com/");
// Click on the search text box and send value
driver.findElement(By.id("lst-ib")).sendKeys("javatpoint tutorials");
// Click on the search button
driver.findElement(By.name("btnK")).click();
}
}
Thank you for your help!
mvn clean, and thenmvn compileto see if classes in that jar loads up. Also try to rebuild the project in the IDE.