3

When I tried to set up selenium in eclipse, after adding jar files, while running the program , I am getting the below error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Program Files\Selenium\Lib\selenium-server-standalone-3.141.59 (2).jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.eclipse.jetty.http.Http1FieldPreEncoder not in module.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
SAVI S
  • 31
  • 1
  • 2

2 Answers2

2

I had similar issue, the problem i faced was i added the selenium-server-standalone-3.141.59.jar under modulepath instead it should be under classpath

so select classpath via (project -> Properties -> Java Bbuild Path -> Libraries) add the downloaded latest jar

After adding it must be something like this

enter image description here

And an appropriate driver for browser has to be downloaded for me i checked and downloaded the same version of chrome for chrome driver and added in the C:\Program Files\Java

And following is the code that worked fine for me

    public class TestuiAautomation {

        public static void main(String[] args) {

            System.out.println("Jai Ganesha");
            try {
                System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");
                System.out.println(System.getProperty("webdriver.chrome.driver"));
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.addArguments("no-sandbox");
                chromeOptions.addArguments("--test-type");
                chromeOptions.addArguments("disable-extensions");
                chromeOptions.addArguments("--start-maximized");
                WebDriver driver = new ChromeDriver(chromeOptions);
                driver.get("https://www.google.com");
                System.out.println("Google is selected");
            } catch (Exception e) {
                System.err.println(e);
            }

        }

    }

For reference

and check for the browser version and chromedriver version

Parameshwar
  • 856
  • 8
  • 16
0

This error message...

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Program Files\Selenium\Lib\selenium-server-standalone-3.141.59 (2).jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.eclipse.jetty.http.Http1FieldPreEncoder not in module.

...implies that the Java Compiler was unable to compile the program due to InvalidModuleDescriptor.

Possibly your main issue is the incompatibility between the version of the binaries as either you are using Java v9, Java v10 or Java v11.


Solution

Uninstall the existing JDK v9 / Java v10 / JDK v11 and install the latest Java v8, i.e. JDK 8u212

You can find a detailed discussion in Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • +1 for asking a good question, and -1 for suggesting reverting back to an older (pre-modules) version of Java. That's just bad advice :( For "better" solutions, look [here](https://stackoverflow.com/questions/49520858) or [here](https://stackoverflow.com/q/63877831/421195) – paulsm4 Sep 14 '20 at 17:25