生成错误:找不到org.openqa.selenium.internal.Locatable的类文件

时间:2019-02-14 21:11:41

标签: java maven selenium

我正在使用Selenium和Maven在Eclipse中构建项目,但出现构建错误:找不到org.openqa.selenium.internal.Locatable的类文件。

我正在使用Selenium-Server-Standalone 3.141.59,我注意到它在...下有Locatable类。

org.openqa.selenium.**interactions**.Locatable 

而不是...

org.openqa.selenium.**internal**.Locatable.

这是一个完全不同的类吗?

如何让Eclipse识别该类在那里?

请从我的Pom.xml中找到以下相关依存关系

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.141.59</version>
    </dependency> 

    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>selenide</artifactId>
        <version>2.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.codeborne/phantomjsdriver -->
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.3.0</version>
    </dependency>               

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

2 个答案:

答案 0 :(得分:0)

从依赖项中删除Selenium Server

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.141.59</version>
</dependency>

如果我没记错的话,现在需要Selenium Java中包含的WebDriver。

还包括Selenium API

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>3.141.59</version>
</dependency>

并更新selenidephantomjsdriver

<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>selenide</artifactId>
    <version>5.1.0</version>
</dependency>

<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.4.4</version>
</dependency>

您要引入的selenide的当前版本是2.3,它将引入selenium-java 2.33.0

您要引入的phantomjsdriver的当前版本是1.3.0,它将引入selenium-java 2.53.0

您需要selenide 5.1.0phantomjsdriver 1.4.4

答案 1 :(得分:0)

这是一个春季项目吗?下面是什么解决了我的问题:

<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>selenide</artifactId>
    <version>5.2.4</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>3.141.59</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
    <version>3.141.59</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-support</artifactId>
    <version>3.141.59</version>
</dependency>