Selenium 无法在无头模式下运行firefox

Selenium 无法在无头模式下运行firefox,selenium,phpunit,headless-browser,Selenium,Phpunit,Headless Browser,根据以无头模式启动selenium服务器的文档,我应该在特定的Firefox配置文件下使用xvfb运行包装器启动服务器。 这可以通过以下命令完成: DISPLAY=:1 xvfb运行java-jar selenium-server.jar-firefoxProfileTemplate/home/ronline/.mozilla/firefox/aqiycn5z.selenium 一旦系统确认selenium服务器已启动并运行 我调用phpunit脚本来执行一组基本测试 phpunit-log

根据以无头模式启动selenium服务器的文档,我应该在特定的Firefox配置文件下使用xvfb运行包装器启动服务器。 这可以通过以下命令完成: DISPLAY=:1 xvfb运行java-jar selenium-server.jar-firefoxProfileTemplate/home/ronline/.mozilla/firefox/aqiycn5z.selenium

一旦系统确认selenium服务器已启动并运行 我调用phpunit脚本来执行一组基本测试 phpunit-log tap test.log test.php

但是执行冻结了关于启动firefox的selenium服务器输出 17:50:33.300信息-正在准备Firefox配置文件。。。 17:50:36.376信息-启动Firefox。。。

Firefox无头模式应该是开箱即用的。 为了完成这项工作,是否需要安装其他驱动程序

安装详情: firefox-版本Mozilla firefox 38.0 PHPUnit 4.6.6 Ubuntu LTS 12.04

test.php的内容:

<?php
class EditUser extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*firefox /usr/lib/firefox/firefox");
    $this->setBrowserUrl("http://www.google.com");
  }

  public function testMyTestCase()
  {
    $this->open("/");
  }
}
?>

显然,selenium服务器仍然不支持Firefox38.0。解决方案是安装Firefox 34.0并将selenium服务器指向其二进制可执行文件:

$this->setBrowser("*firefox /opt/firefox/firefox-34/firefox-bin");
另一个选项是从单元测试文件中删除setBrowser方法,并将下面的xml片段注入phpunit xml配置文件

<selenium>
<browsername="Firefox"
browser="*firefox /opt/firefox/firefox-34/firefox-bin" 
    host="localhost" 
    port="4444"
    timeout="30000"/>
</selenium>