Selenide中的“无法访问com.google.common.base.Predicate”

时间:2018-07-19 13:21:49

标签: maven selenium guava selenide

我是Selenide的新手,所以我尝试关注此视频:https://vimeo.com/107647158在8:05-部分

$("#ires li.g").shouldHave

下划线带有"Cannot access com.google.common.base.Predicate"错误。

我尝试了一些Google,发现了这个:What is the fix for class file for com.google.common.base.predicate not found?,它指向https://github.com/google/guava页面。

我将依赖项添加到pom:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company.myFirstSelenideTest</groupId>
  <artifactId>myFirstSelenideTest</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>metadataTestonDPU</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.codeborne</groupId>
      <artifactId>selenide</artifactId>
      <version>4.12.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>25.1-jre</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <fork>true</fork>
          <executable>C:\Program Files\Java\jdk1.8.0_131\bin\javac</executable>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

但是它不能解决我的问题。我还检查了%JAVA_HOME%和JDK / JRE的路径,看起来还不错。我错过了什么?

2 个答案:

答案 0 :(得分:1)

哦,鸭子方法...

我在顶部添加了import com.google.common.base.Predicate;,并在红色Predicate部分添加了IntelliJ IDEA,并提供了将其添加到类路径的提示

对不起,愚蠢的问题

答案 1 :(得分:0)

我在谓词和收集方面遇到了同样的问题,然后在下面添加并起作用

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava-base</artifactId>
    <version>r03</version>
</dependency>
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava-collections</artifactId>
    <version>r03</version>
</dependency>