1

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?

3 Answers 3

1

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

1
  • I had the same problem and your fix has worked for me as well, although it's weird we have to manually add a library to the classpath once we use Maven to manage our project dependencies. Dec 27, 2018 at 19:02
0

I faced same issue for Predicate & Collect, then added below and it worked

<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>
0

Springfox 3.x removes dependencies on guava and other 3rd party libraries (not zero dep yet! depends on spring plugin and open api libraries for annotations and models) so if you used guava predicates/functions those will need to transition to java 8 function interfaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.