Xvfb和修昔底德/Selenium运行Firefox的默认路径



CI Jenkins在非root用户的情况下运行在CentOS无头计算机上。

Xvfb packege已安装,当我尝试"How can I specify a display?"中的提示时?,即在控制台中手动设置

export DISPLAY=127.0.0.1:0
Xvfb :0
firefox &

它工作起来了——Xvfb输出显示一些firefox请求,firefox输出到控制台。

当我从maven运行同样的东西时,什么都不会发生。请查看我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>somegrouppegas</groupId>
    <artifactId>pegas</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>pegas</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <thucydides.version>0.9.273</thucydides.version>
        <thucydides.jbehave.version>0.9.273</thucydides.jbehave.version>
        <webdriver.driver>firefox</webdriver.driver>
        <actualVersion>0.9.7.1-BETA</actualVersion>
    </properties>
    <dependencies>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-core</artifactId>
            <version>${thucydides.version}</version>
        </dependency>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-junit</artifactId>
            <version>${thucydides.version}</version>
        </dependency>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-jbehave-plugin</artifactId>
            <version>${thucydides.jbehave.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.lambdaj</groupId>
            <artifactId>lambdaj</artifactId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ftpserver</groupId>
            <artifactId>ftpserver-core</artifactId>
            <version>1.0.6</version>
        </dependency>
        <dependency>
            <groupId>com.javadocmd</groupId>
            <artifactId>simplelatlng</artifactId>
            <version>RELEASE</version>
        </dependency>
        <!--<dependency>
            <groupId>com.github.arachnidium</groupId>
            <artifactId>arachnidium-app-model</artifactId>
            <version>${actualVersion}</version>
        </dependency>  -->
    </dependencies>
    <build>
        <plugins>
            <!--
            XMInd plugin is not needed right now; it will be added after it will be improved
            <plugin>
                <groupId>mavenplugintest</groupId>
                <artifactId>mavenplugintest</artifactId>
                <version>1.0-SNAPSHOT</version>
                <configuration>
                    <xmindpath>parse.xmind</xmindpath>
                </configuration>
                <executions>
                    <execution>
                        <id>generateStoriesFromXMind</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>generateStoriesFromXMind</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generateXMindFromTestResults</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>generateXMindFromTestResults</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin> -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <forkCount>0</forkCount>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <forkCount>0</forkCount>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/Test*.java</include>
                        <include>**/When*.java</include>
                        <include>**/*TestSuite.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <!--<compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments> -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9</version>
            </plugin>
            <plugin>
                <groupId>net.thucydides.maven.plugins</groupId>
                <artifactId>maven-thucydides-plugin</artifactId>
                <version>${thucydides.version}</version>
                <executions>
                    <execution>
                        <id>thucydides-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>maven2</id>
            <activation>
                <file>
                    <missing>${basedir}</missing>
                </file>
            </activation>
            <reporting>
                <plugins>
                    <plugin>
                        <groupId>net.thucydides.maven.plugins</groupId>
                        <artifactId>maven-thucydides-plugin</artifactId>
                        <version>${thucydides.version}</version>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
        <profile>
            <id>jenkins</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>selenium-maven-plugin</artifactId>
                        <version>2.3</version>
                        <executions>
                            <execution>
                                <id>xvfb</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>xvfb</goal>
                                </goals>
                                <configuration>
                                    <display>:0</display>
                                </configuration>
                            </execution>
                            <execution>
                                <id>start</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start-server</goal>
                                </goals>
                                <configuration>
                                    <background>true</background>
                                    <logOutput>true</logOutput>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop-server</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>maven3</id>
            <activation>
                <file>
                    <exists>${basedir}</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>3.2</version>
                        <configuration>
                            <reportPlugins>
                                <plugin>
                                    <groupId>net.thucydides.maven.plugins</groupId>
                                    <artifactId>maven-thucydides-plugin</artifactId>
                                    <version>${thucydides.version}</version>
                                </plugin>
                            </reportPlugins>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

firefox和Xvfb实用程序是为jenkins-linux用户和chmoded777选择的,因此权限不是问题的根源。

export DISPLAY=127.0.0.1:0

设置为预生成操作。Xvfb应该由maven selenium插件启动,它是根据mavn输出和自己的Xvfb日志启动的。

我想知道修昔底德/Selenium是如何定义如何找到要运行的Firefox二进制文件的?也许它们应该以某种方式在jenkins配置文件中显式配置?

事实上,我无法以我喜欢的方式解决这个问题,因为尽管有DISPLAY变量的任何组合,将文件和二进制文件归因于jenkins用户并返回到root,但不可能从maven插件配置中运行Xvfb。然而,Xvfb-Jenkins插件运行良好!如果对我来说更完美,因为我不再需要不同的mvn配置文件来在本地机器和CI上运行(插件的Xvfb运行存储为jenkins配置文件),

最新更新