Testing_Selenium
[ class tree: Testing_Selenium ] [ index: Testing_Selenium ] [ all elements ]

Source for file example.php

Documentation is available at example.php

  1. <?php
  2. error_reporting(E_ALL|E_STRICT);
  3. require_once 'Testing/Selenium.php';
  4. try {
  5.     $selenium = new Testing_Selenium("*firefox""http://pear.php.net/");
  6.     $result $selenium->start();
  7.     $selenium->open("http://pear.php.net/packages.php");
  8.     if ($selenium->getTitle(== "PEAR :: Package Browser :: Top Level"{
  9.         print "equal\n";
  10.     else {
  11.         print "not equal\n";
  12.     }
  13.  
  14.     $selenium->type("q""PEAR");
  15.     $selenium->submit("//form");
  16.     $selenium->waitForPageToLoad(3000);
  17.     if ($selenium->getTitle(== "PEAR :: Search: PEAR"{
  18.         print "equal\n";
  19.     else {
  20.         print "not equal\n";
  21.     }
  22.     $selenium->stop();
  23. catch (Selenium_Exception $e{
  24.     echo $e;
  25. }
  26.  
  27. /* With simpletest */
  28. /*
  29. // To see this example, you need to have Simpletest library.
  30. // You can't run simpletest with E_STRICT
  31. require_once 'Testing/Selenium.php';
  32. require_once 'simpletest/unit_tester.php';
  33. require_once 'simpletest/reporter.php';
  34.  
  35. class Example extends UnitTestCase
  36. {
  37.     function setUp()
  38.     {
  39.         $this->selenium = new Testing_Selenium("*firefox", "http://pear.php.net/");
  40.         $result = $this->selenium->start();
  41.     }
  42.     function tearDown()
  43.     {
  44.         $this->selenium->stop();
  45.     }
  46.  
  47.     function testPEARSearch()
  48.     {
  49.         $this->selenium->open("http://pear.php.net/packages.php");
  50.         $this->assertEqual("PEAR :: Package Browser :: Top Level", $this->selenium->getTitle());
  51.         $this->selenium->type("q", "PEAR");
  52.         $this->selenium->submit("//form");
  53.         $this->selenium->waitForPageToLoad(1000);
  54.         $this->assertEqual("PEAR :: Search: PEAR", $this->selenium->getTitle());
  55.     }
  56. }
  57. $test = new Example();
  58. $test->run(new TextReporter());
  59.  */
  60. /* With PHP_Unit2
  61. // To see this example, you need to have PHPUnit library.
  62. error_reporting(E_ALL|E_STRICT);
  63. require_once 'Testing/Selenium.php';
  64. require_once 'PHPUnit2/Framework/TestCase.php';
  65.  
  66. class Example extends PHPUnit2_Framework_TestCase
  67. {
  68.     function __construct($name)
  69.     {
  70.         parent::__construct($name);
  71.     }
  72.     function setUp()
  73.     {
  74.         $this->selenium = new Testing_Selenium("*firefox", "http://pear.php.net/");
  75.             // XXX pear does not work E_STRICT because of HTTP_Request
  76.             // the options are "curl", "pear", "native"
  77.             // $this->selenium->setDriver("pear");
  78.         $result = $this->selenium->start();
  79.     }
  80.     function tearDown()
  81.     {
  82.         $this->selenium->stop();
  83.     }
  84.  
  85.     function testPEARSearch()
  86.     {
  87.         $this->selenium->open("http://pear.php.net/packages.php");
  88.         $this->assertEquals("PEAR :: Package Browser :: Top Level", $this->selenium->getTitle());
  89.         $this->selenium->type("q", "PEAR");
  90.         $this->selenium->submit("//form");
  91.         $this->selenium->waitForPageToLoad(1000);
  92.         $this->assertEquals("PEAR :: Search: PEAR", $this->selenium->getTitle());
  93.     }
  94. }
  95.  */
  96. ?>

Documentation generated on Mon, 11 Mar 2019 15:40:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.