首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用Hudson运行Selenium测试- "Error: no display specified“

尝试使用Hudson运行Selenium测试- "Error: no display specified“
EN

Stack Overflow用户
提问于 2010-06-16 23:47:55
回答 4查看 7.6K关注 0票数 2

我试图在Hudson执行Selenium测试时让它们工作,但到目前为止我还没有成功。Hudson运行在Ubuntu上,Selenium无法打开display。

我用来启动构建的命令是:

代码语言:javascript
复制
mvn clean selenium:xvfb install

错误日志:

代码语言:javascript
复制
[INFO] [selenium:xvfb {execution: default-cli}]
[INFO] Starting Xvfb...
[INFO] Using display: :20
[INFO] Using Xauthority file: /tmp/Xvfb4467650583214148352.Xauthority
Deleting: /tmp/Xvfb4467650583214148352.Xauthority
xauth:  creating new authority file /tmp/Xvfb4467650583214148352.Xauthority
Created dir: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/selenium
Launching Xvfb
Waiting for Xvfb...
[INFO] Redirecting output to: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/selenium/xvfb.log
Xvfb started
...
[INFO] [selenium:start-server {execution: start}]
Launching Selenium Server
Waiting for Selenium Server...
[INFO] Including display properties from: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/selenium/display.properties
[INFO] Redirecting output to: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/selenium/server.log
[INFO] User extensions: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/selenium/user-extensions.js
Selenium Server started
[INFO] [selenium:selenese {execution: run-selenium}]
[INFO] Results will go to: /var/lib/hudson/jobs/Selenium/workspace/selenium/target/results-firefox-suite.html
...
<~30 seconds pause>
...
Error: no display specified
...

pom.xml:

代码语言:javascript
复制
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
    <execution>
        <id>start</id>
        <phase>pre-integration-test</phase>
        <goals>
            <goal>start-server</goal>
        </goals>
        <configuration>
            <logOutput>true</logOutput>
            <background>true</background>
            <port>5123</port>
        </configuration>
    </execution>

    <execution>
        <id>run-selenium</id>
        <phase>integration-test</phase>
        <goals>
            <goal>selenese</goal>
        </goals>
    </execution>

    <execution>
        <id>stop</id>
        <phase>post-integration-test</phase>
        <goals>
            <goal>stop-server</goal>
        </goals>
    </execution>

</executions>
<configuration>
    <browser>*firefox</browser>
    <suite>src/test/selenium/suite.html</suite>
    <startURL>http://localhost:${env.port}</startURL>
</configuration>

我还试图通过添加xvfb的执行来使其正常工作,但也失败了。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-06-17 00:29:39

您需要在无头模式下运行Selenium启动的浏览器,这样它们就不会试图打开显示。这里有一个很好的blog post,有更多的细节。

票数 4
EN

Stack Overflow用户

发布于 2013-07-30 05:18:17

如果您不能选择无头测试,则可以在无头模式下运行测试,您只需指定一个显示即可。

为了快速测试,可以尝试在终端中使用xhost +禁用xhost访问控制。

通过在终端中键入env并记下分配给display变量的数字,找出您的显示设置。例如DISPLAY:1.0

接下来,您需要在Hudson/Jenkins中设置display变量。导航到Jenkins登录页,然后单击Manage Jenkins>Manage Nodes>Master>Configure。选中环境变量复选框,然后在名称框中设置DISPLAY,并将值设置为类似于我们的示例:1.0的值。

票数 1
EN

Stack Overflow用户

发布于 2010-06-17 14:04:02

嗯,也可以将Selenium服务器(实际上我认为是Selenium RC )设置到Hudson机器(尽管这需要X),并使用它来运行测试。似乎Maven selenium插件也接受port value和all,所以这应该会使它连接到RC并启动您需要的浏览器。

但这种无头模式可能更适合您的需求。

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

https://stackoverflow.com/questions/3054913

复制
相关文章

相似问题

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