Search code examples
phpseleniumselenium-rc

Selenium RC and PHP for beginners


I am running a ubuntu server with apache/php/mysql. I want to use selenium on one of my php projects. Basically, I want a setup where I can more or less copy paste code from the Firefox Selenium IDE (format set to php) into my php project, like this:

<?php

require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

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

  public function testMyTestCase()
  {
    $this->type("q", "stack overflow");
    $this->click("link=2");
    $this->waitForPageToLoad("30000");
    $this->click("btnG");
    $this->waitForPageToLoad("30000");
    $this->type("q", "stack overflow php");
    $this->click("btnG");
    $this->waitForPageToLoad("30000");
  }
}
?>

I have tried to figure out how to do this in PHP using Selenium RC, but the documentation is confusing and outdated.

I would be very grateful for instructions for beginners on how to get started with PHP and Selenium RC.

Thank you very much.

EDIT:

Thanks for the feedback. I have got Selenium up and running on Ubuntu/firefox and it is obvious that this is not what I am looking for. The fact that it runs a java server and is dependent on a full blown browser makes it anything than lightweight.

If anyone knows a similar solution where you can just load a php library to interact with dom/html, please tell me.


Solution

  • I haven't done much with Selenium, but my understanding is that if you only have Selenium IDE, there is no way to do more than run it in your browser - the different language outputs are essentially irrelevant.

    If you want to incorporate Selenium into your program, in any language, you need Selenium RC.