运行 Selenium Java Jenkins master 使用 shell 的代码

Run Selenium Java Code on Jenkins master using shell

我正在尝试使用 shell 命令在 Jenkins 上 运行 一个 Java Selenium 代码。 Java 文件需要 3 个 .jar 个文件才能 运行。我累了,在其他命令中,Javac "*.jar" myfile.java 不起作用。

我正在从存储库中提取代码,主节点是 运行ning RedHat 6。当我 运行 javac myfile.java 时,我收到以下错误消息:

java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ClusterReloadAut.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
                          ^
ClusterReloadAut.java:5: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
                          ^
ClusterReloadAut.java:6: error: package org.openqa.selenium.firefox does not exist
import org.openqa.selenium.firefox.FirefoxDriver;
                                  ^
ClusterReloadAut.java:11: error: cannot access WebDriver
    static WebDriver driver = new FirefoxDriver();
           ^
  bad class file: ./WebDriver.class
    class file contains wrong class: org.openqa.selenium.WebDriver
    Please remove or make sure it appears in the correct subdirectory of the classpath.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Javac 是 java 编译器,java 是用于 运行 java 程序的命令。这可能是原因?

您看到任何错误了吗?

要将您的 myfile.java 编译成 myfile.class(这样您就可以使用 java 命令 运行 它)您需要将 -cp path/to/selenium.jar 添加到 javac 命令。像这样:

javac -cp path/to/selenium.jar myfile.java