硒错误:没有指定显示 [英] Selenium Error: no display specified

查看:139
本文介绍了硒错误:没有指定显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了selenium-server-standalone-2.42.2.jar在一个debian的虚拟文件夹中安装了Firefox 29.0


并尝试运行以下脚本,该脚本是目录中唯一的文件phpunit:

pre $ < ;?php
class TestLogin extends PHPUnit_Extensions_Selenium2TestCase {

public function setUp()
{
$ this-> setHost('localhost');
$ this-> setPort(4444);
$ this-> setBrowser('firefox');
$ this-> setBrowserUrl('http:// debian-vm / phpUnitTutorial');


public function testHasLoginForm()
{
$ this-> url('index.php');

$ username = $ this-> byName('username');
$ password = $ this-> byName('password');

$ this-> assertEquals('',$ username-> value());
$ this-> assertEquals('',$ password-> value());




$ b我得到以下错误:

  1)TestLogin :: testHasLoginForm 
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:无法在45000 ms后连接到端口7055上的主机
127.0.0.1。 Firefox控制台输出:
错误:未指定显示
错误:未指定显示

这是什么意思?



我有几个线程红色,显然我不得不做以下我试过:

1)在命令行中键入

  export PATH =:0; 

结果:我得到同样的错误。

< 2)我已经安装了vnc4server,并获得debian-vm:1作为应用程序,然后设置 export PATH = debian-vm:1 运行realvnc并在查看器(工作)我得到了同样的问题。

解决方案您收到此错误,因为您没有设置 DISPLAY 变量。这是一个指导如何在无头机器上执行测试。



您必须安装和浏览器优先:

  apt-get install xvfb 
apt-get install firefox-mozilla-build

然后启动Xvfb:

  Xvfb& 

set DISPLAY 并启动Selenium: p>

  export DISPLAY = localhost:0.0 
java -jar selenium-server-standalone-2.44.0.jar

然后您就可以运行您的测试。


I've installed selenium-server-standalone-2.42.2.jar in a debian virtual box

and installed Firefox 29.0

and trying to run the following script with phpunit which is the only file in the directory:

<?php
class TestLogin extends PHPUnit_Extensions_Selenium2TestCase{

    public function setUp()
    {
            $this->setHost('localhost');
            $this->setPort(4444);
            $this->setBrowser('firefox');
            $this->setBrowserUrl('http://debian-vm/phpUnitTutorial');
    }

    public function testHasLoginForm()
    {
            $this->url('index.php');

            $username = $this->byName('username');
            $password = $this->byName('password');

            $this->assertEquals('', $username->value());
            $this->assertEquals('', $password->value());
    }
}

I get the following error:

1) TestLogin::testHasLoginForm
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to connect to host
127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
Error: no display specified

What does this mean?

I've red several threads and apparently I had to do the following which I tried:

1)to type this in the command shell

export PATH=:0;

Result: I got the same error.

2) I've installed vnc4server and getting debian-vm:1 as a application I then set export PATH=debian-vm:1 run it with realvnc and in the viewer (which works) I got the same problem.

解决方案

You receive this error, because you have not set the DISPLAY variable. Here is a guide how to perform the test on a headless machine.

You have to install Xvfb and a browser first:

apt-get install xvfb
apt-get install firefox-mozilla-build

then start Xvfb:

Xvfb &

set DISPLAY and start Selenium:

export DISPLAY=localhost:0.0
java -jar selenium-server-standalone-2.44.0.jar

and then you will be able to run your tests.

这篇关于硒错误:没有指定显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆