157 239n
157 239n

Reputation: 369

Can't install Selenium locally on CircleCI

I wanted to use Selenium inside an application but I am having some problems with CircleCI.

I have 3 jar files inside lib/ folder: client-combined-3.14.0.jar, htmlunit-driver-2.32.1-jar-with-dependencies.jar and core.jar.

The first 2 jars are for the Selenium library and the third one is the Processing language core jar for control.

This is my .circleci/config.yml:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/openjdk:8-jdk

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4
    branches:
      only:
        - develop

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      MAVEN_OPTS: -Xmx3200m

    steps:
      - checkout

      # installing packages
      - run: mvn install:install-file -Dfile="lib/client-combined-3.14.0.jar" -DgroupId="com.openqa" -DartifactId="selenium" -Dversion="3.14.0" -Dpackaging=jar -DgeneratePom=true
      - run: mvn install:install-file -Dfile="lib/htmlunit-driver-2.32.1-jar-with-dependencies.jar" -DgroupId="com.openqa.selenium" -DartifactId="htmlunit" -Dversion="2.32.1" -Dpackaging=jar -DgeneratePom=true
      - run: mvn install:install-file -DgroupId="processing" -DartifactId="core" -Dversion="3.3.7" -Dpackaging=jar -Dfile="lib/core.jar" -DgeneratePom=true

      # run tests!
      - run: echo "Testing"
      - run: mvn test

This is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.157239n</groupId>
    <artifactId>niche-finder</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.1.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>5.1.0</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.1.0</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.openqa</groupId>
            <artifactId>selenium</artifactId>
            <version>3.14.0</version>
        </dependency>
        
        <dependency>
            <groupId>org.openqa.selenium</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.32.1</version>
        </dependency>
        
        <dependency>
            <groupId>processing</groupId>
            <artifactId>core</artifactId>
            <version>3.3.7</version>
        </dependency>
    </dependencies>
    
</project>

On CircleCI, all 3 jars are installed correctly. More specifically, this is the part of the message when mvn install is run (above it is just a bunch of downloads from the maven repository):

[INFO] Installing /home/circleci/repo/lib/client-combined-3.14.0.jar to /home/circleci/.m2/repository/com/openqa/selenium/3.14.0/selenium-3.14.0.jar
[INFO] Installing /tmp/mvninstall8216458170018038185.pom to /home/circleci/.m2/repository/com/openqa/selenium/3.14.0/selenium-3.14.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.993 s
[INFO] Finished at: 2018-08-18T23:00:14Z
[INFO] ------------------------------------------------------------------------

And this is the part of the message when installing the controlled processing jar:

[INFO]
[INFO] --------------------------------------------
[INFO] Building niche-finder 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ niche-finder ---
[INFO] Installing /home/circleci/repo/lib/core.jar to /home/circleci/.m2/repository/processing/core/3.3.7/core-3.3.7.jar
[INFO] Installing /tmp/mvninstall6601326226754451883.pom to /home/circleci/.m2/repository/processing/core/3.3.7/core-3.3.7.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.472 s
[INFO] Finished at: 2018-08-18T23:00:18Z
[INFO] ------------------------------------------------------------------------

However, when mvn test is run, this error occurs:

[ERROR] Failed to execute goal on project niche-finder: Could not resolve dependencies for project com.157239n:niche-finder:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.openqa:selenium:jar:3.14.0, org.openqa.selenium:htmlunit:jar:2.32.1: Could not find artifact org.openqa:selenium:jar:3.14.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

It appears that the 2 selenium jars were not installed correctly but the Processing jar installed just fine.

So is this an error on Selenium side? Or what did I do wrong?

Please note that currently I just want to resolve dependencies in Selenium and not actually running a Selenium server on CircleCI.

Upvotes: 0

Views: 323

Answers (1)

157 239n
157 239n

Reputation: 369

I tried not to rely on jar files downloaded from https://www.seleniumhq.org/ and use the repository directly from this and this from the maven repository at https://mvnrepository.com/artifact/org.seleniumhq.selenium

Then I don't install the local jar file altogether, just install the controlled core.jar and changed part of my pom.xml to

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

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.52.0</version>
</dependency>

Then everything builds just fine.

Upvotes: 0

Related Questions