views:

690

answers:

2

Hi there.

I have just started using Selenium-RC with PHPUnit in order to perform some web-based tests. Initially I set it up on Windows 7 using this guide - http://jodyt.com/2009/03/selenium-rc-and-php/ - and it worked fine.

I could create a .php file test and run it with phpunit.

However, I have been asked to get this running locally on Ubuntu 8.04. So I downloaded and unzipped the selenium-rc server to ~/selenium and it works fine by issuing 'java -jar selenium-server.jar'.

Now, when I change directory to where my php test files are, I get the following error(s) from the window where selenium-server is running:

 15:26:58.317 INFO - Got result: ERROR Server Exception: sessionId led to start
 new browser session: Error while launching browser doesn't exist; perhaps this 
 session was already stopped? on session led to start new browser session: 
 Error while launching browser

 15:26:58.323 INFO - Command request: testComplete[, ] on session led to start 
 new browser session: Error while launching browser

 15:26:58.323 INFO - Got result: OK on session led to start new browser       
 session: Error while launching browser

I am trying to do all this through Putty connections to the Ubuntu machine with X11 Forwarding on.

Any ideas what is going wrong?

A: 

Sure.

<?php

require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class SomeTest extends PHPUnit_Extensions_SeleniumTestCase
{
  private $licence;

  function setUp()
  {
    $this->setBrowser('*firefox');
    $this->setBrowserUrl("http://blah");
  }

function getLicence()
{
    return $this->licence;  
}

function setLicence($licence)
{
    $this->licence = $licence;  
}

function isStarted($element)
{
    return  $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/started.gif']");
}

function isStopped($element)
{
    return  $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/stopped.gif']");  
}

function isDisabled($element)
{
    return  $this->isElementPresent("//form[@id='".$element."']/ul/li[2]/img[@src='images/disabled.gif']"); 
}

function testStatusPage()
{
    $this->open("/blah/");

    // 
    $this->setLicence('NA');

    // 
    $this->assertEquals($this->getLicence(), $this->getText("//div[@id='S1']/fieldset[1]/dl/dd"));

    // Verify certain services are running
    $this->assertTrue($this->isStarted('a'));
    $this->assertTrue($this->isStarted('b'));
    $this->assertTrue($this->isDisabled('c'));
    $this->assertTrue($this->isDisabled('d'));
    $this->assertTrue($this->isStopped('e'));
    $this->assertTrue($this->isStarted('f'));
    $this->assertTrue($this->isStarted('g'));
    $this->assertTrue($this->isStarted('h'));
    $this->assertTrue($this->isStarted('i'));
}
}
?>

Apologies for the formatting. I also created an even simpler one that just checked the title of Google front page was 'Google' and it just said

Fatal error: Call to undefined method SimpleTest::assertTitle()

So I thought it wasn't finding the header file properly but I did a 'find' and it was found in

/usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php

I'm fairly lost.

tombh
+1  A: 

Solved. Installed newer version of Java. Thanks go to this page - http://clearspace.openqa.org/thread/14502

tombh