Selenium服务器无法连接到主机,未指定显示 - OLD:无法启动新的浏览器会话

I'm using Selenium server (2.39.0) on centOs server 6.5 (redhat) developing tests in PHP, using phpUnit (i installed phpunit by pear as well)

but everytime i get this error:

Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': 
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser
Caused by
RuntimeException: 
Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': 
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser

this is the test that i'm trying to execute:

<?php

require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class Example extends PHPUnit_Extensions_SeleniumTestCase
{
   function setUp()
  {
    $this->setBrowser("*firefox");
    $this->setBrowserUrl("http://www.google.com/");
  }

  function testMyTestCase()
  {
    $this->open("/");
    $this->type("q", "selenium rc");
    $this->click("btnG");
    $this->waitForPageToLoad("30000");
    $this->assertTrue($this->isTextPresent("Results * for selenium rc"));
  }
}
?>

i'm trying also to run the script using :

phpunit --configuration conf.xml example.php

where in conf.xml i've got:

<browser name="Firefox" browser="*firefox" host="IPHOST" port="4444" timeout="30000" />

but i receive the same error

and the door 4444 is free:

netstat -anp | grep 4444

gives:

tcp        0      0 :::4444                     :::*                        LISTEN 

what am i doing wrong?

EDIT:

@sircapsalot: do you mean to change the script?

anyway i don't know if i'm going to the right direction but i changed something: first of all the script is different:

<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{
  protected function setUp()
  {
    $this->setBrowser('firefox');
    $this->setBrowserUrl('http://www.example.com/');
  }

  public function testTitle()
  {
    $this->url('http://www.example.com/');
    $this->assertEquals('Example WWW page', $this->title());
  }
}
?>

and i installed Xvfb so now i don't have the error that selenium has failed to start new browser session, but i'm having another error

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

and i already tried with:

Xvfb :99 -ac -screen 0 1280x1024x24 &

and:

export DISPLAY=:99
查看全部
dqpfl2508589
dqpfl2508589
2014/02/14 16:04
  • selenium
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复