首页 > 解决方案 > Jenkins - Java CLASSPATH 未正确加载

问题描述

我正在尝试在 jenkins 代理中运行 selenium java 类。

但是 CLASSPATH 对于 java 程序没有按预期工作。jar 文件在selenium/target/classes目录内。它可以在我的 Windows 桌面上运行,但不能在服务器上运行。

org/openqa/selenium/chrome/ChromeOptions问题已selenium-chrome-driver-2.26.0.jar在 Windows 中解决。但它没有在linux环境中加载。

任何建议都会有所帮助。

                environment {
                    CLASSPATH = ".:google-collections-1.0.jar:selenium-chrome-driver-2.26.0.jar:selenium-server-standalone-3.13.0.jar"
                }

                steps {
                    dir("selenium/target/classes") {
                        sh 'echo "Selenium test"'
                        catchError {
                            sh 'java demo.selenium.IBanTest'
                        }                       
                    }
                }

错误:

+ java demo.selenium.IBanTest
iBan Selenium Testing
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.addArguments([Ljava/lang/String;)Lorg/openqa/selenium/chrome/ChromeOptions;
    at demo.selenium.IBanTest.setup(IBanTest.java:34)
    at demo.selenium.IBanTest.main(IBanTest.java:22)

标签: javaseleniumjenkins

解决方案


推荐阅读