在Eclipse中运行时没有任何问题,但是当我尝试在Jenkins中运行ANT构建时,我得到以下内容:
java.lang.IllegalStateException: 驱动程序可执行文件不存在:C:\ Program Files (x86)\ Jenkins \ jobs \更新InforTAP 建立\工作空间\ lib中\ geckodriver0-19.exe
Image capture of file info exe存在于该确切目录中,并且权限已设置为777.在第三方服务器中运行的测试工作正常。这似乎表明这是使用Jenkins在本地运行的唯一问题。
以下是数据输出:(请注意,我已删除“ANT_BUILDS”)
之前:C:\ Program Files(x86)\ Jenkins \ jobs \ Update InforTAP Build \ workspace \ ANT_BUILDS浏览器
位置:lib \ geckodriver0-19.exe
之后:C:\ Program Files(x86)\ Jenkins \ jobs \ Update InforTAP 建立\工作空间\ lib中\ geckodriver0-19.exe
lib目录在这里: C:\ Program Files(x86)\ Jenkins \ jobs \ Update InforTAP Build \ workspace \ lib \
ANT构建文件位于: C:\ Program Files(x86)\ Jenkins \ jobs \ Update InforTAP Build \ workspace \ ANT_BUILDS \
final FirefoxOptions firefoxOptions = new FirefoxOptions();
ensureOneDriverInstance(Browser.GEKODRIVER_EXE_NAME);
System.setProperty("webdriver.gecko.driver", Browser.getDriverExeLocation(Browser.FIREFOX));
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
firefoxOptions.addPreference("browser.popups.showPopupBlocker", false);
firefoxOptions.addPreference("security.sandbox.content.level", 5);
driver = new FirefoxDriver(firefoxOptions);
public static String getDriverExeLocation(final Browser browserType) {
String currentWorkingDirectory = null;
String browserLocation = null;
public static final String GEKODRIVER_EXE_NAME = "geckodriver0-19.exe";
public static final String GEKODRIVER_EXE_LOCATION = "lib\\\\" + GEKODRIVER_EXE_NAME;
browserLocation = GEKODRIVER_EXE_LOCATION;
currentWorkingDirectory = UtilsFile.getCurrentDirectory();
System.out.println("before :" + currentWorkingDirectory);
System.out.println("browser location: " + browserLocation);
if ((currentWorkingDirectory != null) && currentWorkingDirectory.contains("ANT_BUILDS")) {
if (browserLocation != null) {
System.setProperty("user.dir", currentWorkingDirectory.replaceAll("ANT_BUILDS", ""));
browserLocation = currentWorkingDirectory.replaceAll("ANT_BUILDS", browserLocation);
}
}
System.out.println("after :" + browserLocation);
return browserLocation;
}
这是ANT BUILD文件
<property name="RELEASE_ROOT" value="workspace/" />
<property name="BASE_ROOT" value="${basedir}/workspace/" />
<property name="SRC" value="${RELEASE_ROOT}/src" /> <!-- Change it to your source folder -->
<property name="LIB" value="${RELEASE_ROOT}/lib" /> <!-- Change it to your lib folder -->
<property name="SELENIUM.LIB" value="${RELEASE_ROOT}" /> <!-- Change it to your lib folder -->
<property name="BIN" value="${RELEASE_ROOT}/bin1" /> <!-- Change it to your binary folder where you need to gerate the compiled binary file -->
<property name="REPORT" value="${RELEASE_ROOT}/reports/ANT" /> <!-- Change it to your output report folder -->
<property environment="env" />
<property name="CATALINA_HOME.LIB" location="${env.CATALINA_HOME}/lib"/>
<property name="CATALINA_HOME.BIN" location="${env.CATALINA_HOME}/bin"/>
<import file="${CATALINA_HOME.BIN}/catalina-tasks.xml"/>
<fileset dir="${SELENIUM.LIB}" id="http.jars">
<include name="lib/httpclient*.jar" />
<include name="lib/httpcore*.jar" />
</fileset>
<fileset dir="${CATALINA_HOME.LIB}" id="CATALINA_HOME.jars">
<include name="servlet-api.jar" />
<include name="**/*.jar" />
</fileset>
<fileset dir="${SELENIUM.LIB}" id="SELENIUM.jars">
<include name="lib/*.jar" />
</fileset>
<path id="test.classpath"> <!-- Creating a classpath for use while compiling -->
<fileset refid="http.jars" />
<fileset refid="CATALINA_HOME.jars" />
<fileset refid="SELENIUM.jars" />
<pathelement location="${BIN}" />
</path>
<target name="init"> <!-- Initialization target which deletes and recreates the binary folder.-->
<delete dir="${BIN}" />
<mkdir dir="${BIN}" />
</target>
<target name="compile" depends="init"> <!-- Target for compiling the source folder -->
<javac includeantruntime="false" source="1.8" srcdir="${SRC}" fork="true" destdir="${BIN}" encoding="UTF-8" >
<classpath>
<fileset refid="http.jars" />
<fileset refid="CATALINA_HOME.jars" />
<fileset refid="SELENIUM.jars" />
<pathelement location="${BIN}" />
</classpath>
</javac>
</target>
<target name="run-regression"> <!-- Target to run test in batches. -->
<delete dir="${REPORT}" />
<mkdir dir="${REPORT}" />
<mkdir dir="${REPORT}/xml" />
<junit printsummary="yes" haltonfailure="no">
<jvmarg value="-Duser.dir=${BASE_ROOT}"/> <!-- has to be absolute path echo the path to see what we have so far-->
<classpath>
<pathelement path="${BIN}" />
<fileset refid="CATALINA_HOME.jars" />
<fileset refid="SELENIUM.jars" />
</classpath>
<test name="com.infor.infortap.tomcatpa.testsuite.TestSuiteRegressionInternalAdmin" haltonfailure="no" todir="${REPORT}/xml" outfile="TEST-result">
<formatter type="xml" />
</test>
</junit>
<junitreport todir="${REPORT}">
<fileset dir="${REPORT}/xml">
<include name="TEST*.xml" />
</fileset>
<report format="frames" styledir="${RELEASE_ROOT}/reports/report-formats" todir="${REPORT}/html" />
</junitreport>
</target>
<target name="compile-and-run-regression-internal-admin" depends="compile, run-regression"/>
答案 0 :(得分:0)
答案是创建一个Jenkins主目录而不是尝试使用默认设置。 Create a Jenkins Home Directory
我也使用userID登录Windows服务而不是选择第一个选项以允许Windows服务使用当前会话。