问题
I am using eclipse 09-2019 with jdk13 and selenium 3.0.1 .jar file.
My Code is:
package package1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Script1
{
public static void main(String[] args)
{
System.out.println("Hii");
System.setProperty("Webdriver.chrome.driver","E:\\Selenium\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.google.com");
}
}
Error:
java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.bsf.BSFManager not in module
回答1:
InvalidModuleDescriptorException
InvalidModuleDescriptorException is thrown when reading a module descriptor and the module descriptor is found to be malformed or otherwise cannot be interpreted as a module descriptor.
InvalidModuleDescriptorException can be raised in either of the following scenarios:
- Issues with the Java project.
- Issues with the Java package with in a Java project.
- Issues with the Java class with in a Java package.
However, as per the discussion in Does Selenium v3.141 support Java 13? it seems the latest version of Selenium still doesn't supports java-13.
Solution
The strategic solution will be to install the latest version of JDK 8u222 and execute the @Tests
Additionally, you also need to replace uppercap W with the lowercap w in the System.setProperty()
line. So, effectively, you need to replace:
System.setProperty("Webdriver.chrome.driver","E:\\Selenium\\chromedriver.exe");
With
System.setProperty("webdriver.chrome.driver","E:\\Selenium\\chromedriver.exe");
Additional Consideration
Additionally, ensure that:
- Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
- Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
来源:https://stackoverflow.com/questions/59171497/java-lang-module-invalidmoduledescriptorexception-provider-class-org-apache-bs