Selenium export to PHP

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Selenium export to PHP

Post 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.
tanja
Forum Commoner
Posts: 35
Joined: Fri Mar 27, 2009 4:49 am

Re: Selenium export to PHP

Post by tanja »

What does this script verify?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Selenium export to PHP

Post 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.
Post Reply