无法在无头模式下运行Firefox

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

一旦我得到系统确认硒服务器启动并运行,我打电话给我的phpunit脚本执行一组基本测试phpunit --log-tap test.log test.php

但septic冻结与硒服务器输出有关启动Firefox 17:50:33.300 INFO - Preparing Firefox profile... 17:50:36.376 INFO - Launching Firefox...

Firefox无头模式应该可以运行。 为了完成这项工作,是否需要安装额外的驱动程序?

安装细节: firefox --version 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("/");
  }
}
?>

显然,Firefox 38.0仍然不被selenium服务器支持。 解决方案是安装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> 
链接地址: http://www.djcxy.com/p/57521.html

上一篇: Can't run firefox in headless mode

下一篇: Problems while installing WWW::Mechanize::Firefox