有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

启动层初始化期间发生eclipse错误:无法使用Selenium和java派生模块描述符错误

当我尝试在eclipse中设置selenium时,在添加jar文件后,在运行程序时,我得到了以下错误:

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.

共 (1) 个答案

  1. # 1 楼答案

    我也有类似的问题,我面临的问题是我添加了selenium-server-standalone-3.141.59。jar在modulepath下,而应该在classpath下

    因此,通过(项目->;属性->;Java Bbuild路径->;库)选择类路径 添加下载的最新版本jar

    加进去以后一定是这样

    enter image description here

    必须为我下载一个合适的浏览器驱动程序。我检查并下载了相同版本的chrome for chromedriver,并添加到C:\Program Files\Java中

    下面的代码对我来说很好

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

    对于reference

    并检查浏览器版本和chromedriver版本