Page 1 of 1

Selenium export to PHP

Posted: Thu Apr 16, 2009 2:56 am
by jaoudestudios
I have created a small script using the Selenium IDE and exported it to PHP.

Now I want to run the simple test via the command line not the IDE. I have tried quite a few tutorials online but none worked. I noticed that at the top the generated PHP includes a SeleniumTestCase.php in the PHPUnit extensions directory. So I install PHPUnit but I still am having problems.

This is my script...

Code: Select all

<?php
 
require_once '../../resources/phpunit/PHPUnit-3.3.9/PHPUnit/Extensions/SeleniumTestCase.php';
 
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://192.168.2.2:8084/index/login");
  }
 
  function testMyTestCase()
  {
    $this->open("/index/login");
    $this->type("email", "*****@*******.com");
    $this->type("password", "******");
    $this->click("submit");
    $this->waitForPageToLoad("30000");
        $this->assertTrue($this->isTextPresent("Errror"));
  }
}
 
?>
 
As you can see it is very simple, I dont understand why it is so difficult to get this to work.

I would be grateful for any help.

Re: Selenium export to PHP

Posted: Mon Apr 20, 2009 8:31 am
by tanja
What does this script verify?

Re: Selenium export to PHP

Posted: Mon Apr 20, 2009 10:12 am
by jaoudestudios
$this->open("/index/login");
$this->type("email", "*****@*******.com");
$this->type("password", "******");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Error"));
Its attempting a login failure and then looking for the word "Error" in the page.