jrdnangin
jrdnangin

Reputation: 11

How do I setup Selenium WebDriver with Java?

I have a question on how to start using Selenium WebDriver with Java.

Here is my code:

package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MyClass 
{
    public static void main (String[] args)
    {
        WebDriver driver = new ChromeDriver();
        driver.get("http://google.com");
    }
}

I then get the following error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\MrJPG\eclipse-workspace\Project IG Bot\bin
Caused by: java.lang.module.InvalidModuleDescriptorException: Package IGBotPackage not found in module

Does anyone know the solution to this? I have tested adding the external jars from Selenium in both the Modulepath and Classpath. However, both seem to have the same result and error.

Upvotes: 0

Views: 689

Answers (2)

yogesh karkhele
yogesh karkhele

Reputation: 1

Please use Which ChromeDriver version is compatible with which Chrome Browser version? to download right version of chromedriver exe.

Place above exe in any(e.g. D:\) path and use below code: System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://google.com");

Upvotes: 0

Ruyut
Ruyut

Reputation: 181

you need add this

System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");

chromedriver.exe is your chromedriver.exe path //download chromedriver.exe

maybe

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");

Need to be the same as your chrome version if your chrome is '80.0.3987.106'

need at least these are the same '80.0.3987'

Hope that helps you

Upvotes: 1

Related Questions