0

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.

2

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

15 Comments

I just tried it, same error. I also checked the chrome driver and my chrome browser and it is the same. Where should I download the chromedriver.exe file to? I have it on my desktop
You need to copy the path,and modify"C:\\chromedriver.exe",Change to your path
If you don't know, put it in 'C: \', try it
So I downloaded the chromedriver from the link you sent. It is a zip file, should I extract it and put it in C: or should I leave it in the zip?
extract it, get 'chromedriver.exe'
|
0

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");

2 Comments

I tried this but it did not work. I have a red underline under both the import statements, WebDriver, and ChromeDriver.
You have redline means you have not added selenium jar in project. Please add it in project or add maven dependency

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.