Search code examples
mavenseleniumguavaselenide

"Cannot access com.google.common.base.Predicate" in Selenide


I am new to Selenide and I tried to follow this video: https://vimeo.com/107647158 at 8:05 - part

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

is underlined with "Cannot access com.google.common.base.Predicate" error.

I tried some Google and found this: What is the fix for class file for com.google.common.base.predicate not found? which pointed to https://github.com/google/guava page.

I added dependency to 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>

But it didn't resolve my issue.

I also checked %JAVA_HOME% and path to JDK/JRE and seems to be fine. What I missed?


Solution

  • Oh, duck method...

    I added import com.google.common.base.Predicate; on the top and IntelliJ IDEA posted on red Predicate part with a tip to add it to a classpath

    Sorry for dumb question