有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java ANT build无法识别geckodriver可执行文件“驱动程序可执行文件不存在”

在Eclipse中运行时,我没有遇到任何问题,但当我尝试在Jenkins中运行ANT构建时,我得到了以下结果:

java.lang.IllegalStateException: The driver executable does not exist: C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\lib\geckodriver0-19.exe

Image capture of file info exe存在于该确切目录中,权限已设置为777。在第三方服务器中运行的测试工作正常。这似乎表明这是使用Jenkins在本地运行的唯一问题

以下是数据输出:(注意,我已经删除了“ANT_构建”)

before :C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\ANT_BUILDS browser

location: lib\geckodriver0-19.exe

after :C:\Program Files (x86)\Jenkins\jobs\Update InforTAP Build\workspace\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\u 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构建文件

<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) 个答案