我是詹金斯的新手。
我在Java项目中有以下样本的selenium代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SampTest
{
public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.google.com");
System.out.println(driver.getTitle());
driver.quit();
}
}
这很有效。
我在Jenkins中配置如下: 使用名称创建一个新项目。 在高级选项中,将Workspace添加为" D:\ UD \ ProgrammingSamples \ Selenium \ SeleniumPractice \ src" 在构建部分,我使用了执行Windows批处理命令,如" javac SampTest.java | java SampTest" (基本上我不知道在这里使用什么。有人可以在这帮助我。)
当我构建项目时,我现在看到一条错误消息:
Started by user anonymous
Building in workspace D:\UD\ProgrammingSamples\Selenium\SeleniumPractice\src
[src] $ cmd /c call C:\Users\user\AppData\Local\Temp\hudson578216989100659838.bat
D:\UD\ProgrammingSamples\Selenium\SeleniumPractice\src>javac SampTest.java | java SampTest
java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" SampTest.java:1: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^
SampTest.java:2: error: package org.openqa.selenium.firefox does not exist
import org.openqa.selenium.firefox.FirefoxDriver;
^
SampTest.java:8: error: cannot find symbol
WebDriver driver=new FirefoxDriver();
^
symbol: class WebDriver
location: class SampTest
SampTest.java:8: error: cannot find symbol
WebDriver driver=new FirefoxDriver();
^
symbol: class FirefoxDriver
location: class SampTest
4 errors
D:\UD\ProgrammingSamples\Selenium\SeleniumPractice\src>exit 1
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE