使用Xvfb在无头模式下进行Selenium测试

8
我需要在使用Xvfb的无头模式下运行Selenium测试,我的pom.xml文件中包含以下内容:
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <version>1.1</version>

        <executions>
            <execution>
                <id>xvfb</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>xvfb</goal>
                </goals>
                <!-- 
                <configuration>
                    <display>:2</display>
                </configuration>
                    -->
            </execution>

            <execution>
                <id>selenium</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>start-server</goal>
                </goals>
                <configuration>
                    <background>true</background>
                </configuration>
            </execution>
        </executions>
      </plugin>

当我运行mvn integration-test时,无法加载Xvfb,但selenium测试仍在Firefox中运行。我检查了以下内容:
(EE) AIGLX error: dlopen of /usr/X11/lib/dri/swrast_dri.so failed (dlopen(/usr/X11/lib/dri/swrast_dri.so, 5): image not found)
(EE) GLX: could not load software renderer
(EE) XKB: Couldn't open rules file /usr/X11/share/X11/xkb/rules/base
(EE) XKB: No components provided for device Virtual core keyboard

有人知道这是什么意思吗?谢谢。
3个回答

6

在Xvfb命令行中添加“-extension GLX”可能会消除前两个错误。


你是指 +extension GLX 吗? - Ben

4
在 Debian / Ubuntu 中,该软件包为 "libgl1-mesa-dri",如下所示:
apt-get install libgl1-mesa-dri

4
我发现我的设置中缺少mesa驱动程序。
yum install mesa-dri-drivers 

解决了问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接