首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行Firefox的Xvfb和thucydides/Selenium默认路径

运行Firefox的Xvfb和thucydides/Selenium默认路径
EN

Stack Overflow用户
提问于 2014-10-31 17:04:41
回答 1查看 913关注 0票数 1

CI Jenkins正在CentOS无头机器上运行,使用非根用户。

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

代码语言:javascript
复制
export DISPLAY=127.0.0.1:0
Xvfb :0
firefox &

而且它可以工作- Xvfb输出显示一些firefox请求,Firefox输出到控制台。

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

代码语言:javascript
复制
<?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用户和chmoded 777,因此权限不是问题的根源。

代码语言:javascript
复制
export DISPLAY=127.0.0.1:0

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

我想知道Thucydides/Selenium如何定义如何找到要运行的Firefox二进制文件?也许应该在jenkins配置文件中显式地配置它们吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-15 07:28:06

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26679921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档