Maven错误:找不到模块:org.openqa.selenium.chrome

时间:2019-11-16 13:47:16

标签: java maven selenium module

我一直试图将Selenium添加到我的module-info.java文件中,但是当我使用maven编译时,出现以下错误:

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:jlink (default-cli) on project SIT: Error: Unable to execute mojo: Compilation failure: 
[ERROR] module-info.java:[19,37] module not found: org.openqa.selenium.chrome
[ERROR] module-info.java:[20,37] module not found: org.openqa.selenium.core
[ERROR] module-info.java:[21,37] module not found: org.openqa.selenium.firefox
[ERROR] module-info.java:[22,37] module not found: org.openqa.selenium.ie
[ERROR] module-info.java:[23,37] module not found: org.openqa.selenium.remote

但是删除了module-info.java文件后,maven编译成功。

这是我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>SIT</groupId>
    <artifactId>SIT</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>SIT</name>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.3</version>
                <configuration>
                    <stripDebug>true</stripDebug>
                    <compress>2</compress>
                    <noHeaderFiles>true</noHeaderFiles>
                    <noManPages>true</noManPages>
                    <launcher>sit</launcher>
                    <jlinkImageName>sit</jlinkImageName>
                    <jlinkZipName>sit</jlinkZipName>
                    <mainClass>hellofx/org.openjfx.MainApp</mainClass>
                    <mainClass>application.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.simpleframework/simple-xml -->
        <dependency>
            <groupId>org.simpleframework</groupId>
            <artifactId>simple-xml</artifactId>
            <version>2.7.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.0.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>4.0.9</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.12.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>11.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>11.0.2</version>
        </dependency>
    </dependencies>
</project>

还有我的module-info.java文件:

module sit {
    exports view;
    exports application;
    exports Test;
    exports model;

    requires com.google.common;
    requires extentreports;
    requires java.desktop;
    requires java.naming;
    requires java.prefs;
    requires java.xml;
    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.graphics;
    requires org.apache.commons.io;
    requires org.jsoup;
    requires org.openqa.selenium.chrome;
    requires org.openqa.selenium.core;
    requires org.openqa.selenium.firefox;
    requires org.openqa.selenium.ie;
    requires org.openqa.selenium.remote;
    requires org.testng;
    requires simple.xml;
}

我使用OpenJDK v11.0.2和OpenJFX。任何帮助将不胜感激。

编辑

我尝试用下面的子依赖关系替换pom.xml中的selenium-java依赖关系:

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-chrome-driver</artifactId>
    <version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-ie-driver -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-ie-driver</artifactId>
    <version>3.141.59</version>
</dependency>

虽然它仍然无法正常工作。

0 个答案:

没有答案