我想在应用程序中使用 Selenium,但我在使用 CircleCI 时遇到了一些问题。
我在 lib/ 文件夹中有 3 个 jar 文件:client-combined-3.14.0.jar、htmlunit-driver-2.32.1-jar-with-dependencies.jar 和 core.jar。
前 2 个 jar 用于 Selenium 库,第三个是用于控制的处理语言核心 jar。
这是我的 .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
这是我的 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>
在 CircleCI 上,所有 3 个 jar 都已正确安装。更具体地说,这是mvn install
运行时消息的一部分(上面只是从 maven 存储库下载的一堆):
[信息] 安装 /home/circleci/repo/lib/client-combined-3.14.0.jar 到 /home/circleci/.m2/repository/com/openqa/selenium/3.14.0/selenium-3.14.0.jar
[INFO] 安装 /tmp/mvninstall8216458170018038185.pom 到 /home/circleci/.m2/repository/com/openqa/selenium/3.14.0/selenium-3.14.0.pom
[INFO] --------- -------------------------------------------------- -------------
[信息] 构建成功
[信息] ----------------------------- -------------------------------------------------------
[INFO] 总时间:1.993 s
[INFO] 完成于:2018-08-18T23:00:14Z
[INFO] ------------------------------------------- -----------------------------------------
这是安装受控处理 jar 时消息的一部分:
[信息]
[信息] -----------------------------------------
[INFO] Buildingniche-finder 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]-- -------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-文件(默认-cli)@niche-finder ---
[INFO] 将 /home/circleci/repo/lib/core.jar 安装到 /home/circleci/.m2/repository/processing/core/3.3.7/core- 3.3.7.jar
[INFO] 安装 /tmp/mvninstall6601326226754451883.pom 到 /home/circleci/.m2/repository/processing/core/3.3.7/core-3.3.7.pom
[INFO] ------ -------------------------------------------------- ----------------
[信息] 构建成功
[信息] --------------------------------------------- -------------------------
[INFO] 总时间:0.472 s
[INFO] 完成时间:2018-08-18T23:00:18Z
[INFO ] ------------------------------------------------- ----------------------
但是,mvn test
运行的时候,会出现这个错误:
[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]
似乎没有正确安装 2 个硒罐,但处理罐安装得很好。
那么这是 Selenium 方面的错误吗?或者我做错了什么?
请注意,目前我只想解决 Selenium 中的依赖关系,而不是实际在 CircleCI 上运行 Selenium 服务器。