Differences between revisions 12 and 13
Revision 12 as of 2007-09-10 14:33:33
Size: 4858
Editor: guest-86
Comment:
Revision 13 as of 2007-09-14 16:19:44
Size: 5720
Editor: dslb-084-059-025-133
Comment:
Deletions are marked like this. Additions are marked like this.
Line 50: Line 50:
You must have java runtime installed and the Testing_Selenium package. Following an excerpt from the Selenium documentation: Install the following:

=== Selenium Java Server ===
The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 1.5.0 or higher in order to start. To use this package, you need to have selenium-server.jar. You can download selenium-server.jar from http://www.openqa.org/selenium-rc/

=== PHPUnit2 ===

The easiest way to install PHPUnit2 and the Selenium PHP client driver is using PEAR.

==== Insalling PEAR on Microsoft Windows ====

On Windows, go-pear uses stdin for user input, so you must download go-pear first and then run it:

 Note: Since PHP 4.3.0, the PHP CLI binary is named php.exe in the cli/ folder
 of your PHP directory. The CGI is also named php.exe but it sits directly in
 your PHP directory, use the CLI binary instead.
 In PHP 5.0.0+, the PHP CLI binary is php.exe

  > php -r "readfile('http://pear.php.net/go-pear');" > go-pear
  > php -q go-pear


Following an excerpt from the Selenium documentation:

About character encoding (28May07 Markus)

CompleteSearch supports ISO-8859-1 and the multibyte character encoding UTF-8. UTF-8 is the default encoding with the following consequences:

  • The $AC->settings->encoding is 'utf-8' unless overriden in autocomplete_config.php

  • The texts in text.php are saved as UTF-8
  • The css file uses '@charset "utf-8";'
  • We use mb_strtolower (instead of strtolower) with parameter $AC->settings->encoding to enable UTF-8

We do the following depending on the defined encoding:

  • We UTF-8 encode $AC->settings->capitals if $AC->settings->encoding is UTF-8

  • In ajax.php we UTF-8 encode the query string if $AC->settings->encoding is UTF-8 and the charset of content_type is not UTF-8 (means the request is sent as a non-UTF-8 type)

  • We set the page encoding of index.php, options.php and change_options.php according to $AC->settings->encoding (<meta http-equiv="content-type" content="text/html;charset=<?php echo $AC->settings->encoding; ?>">)

  • Texts from text.php are UTF-8 decoded by $AC->get_text() if $AC->settings->encoding is ISO-8859-1

  • We url encode the javascript code in function javascript_rhs (in generate_javascript.php) if $AC->settings->encoding is not UTF-8 (this is not necessary if utf-8 is used)

Note: The form attribute accept-charset

If the form attribute accept-charset is set to "UTF-8" the form variables are UTF-8 encoded before sent to server (even if the page encoding is not UTF-8).

The PHP Apache extension php_mbstring

The use of the mb_strtolower function (and other mb_ functions) requires the extension php_mbstring in php.ini:

In windows:
extension=php_mbstring.dll

or in linux:
extension=php_mbstring.so

(On geek, the mb_... functions were available by default, on Markus' laptop the line above had to be added.)

If this is the first extension you use be sure to have specified the location of the extension with the extension_dir directive.

Testing with Selenium remote control (short: SeleniumRC)

There are two ways to use SeleniumRC:

  • with the Selenium IDE, a firefox extension
  • with test cases written by you in languages like PHP and using the Selenium (proxy) server (written in Java)

Selenium IDE

Testing with the Selenium IDE is the easiest way but only works with firefox, that means no cross browser testing. You have to open the following url with Selenium IDE extension installed in your firefox browser:

chrome://selenium-ide/content/selenium/TestRunner.html?baseURL=http://search.mpi-inf.mpg.de/markus/&test=http://search.mpi-inf.mpg.de/markus/tests/TestSuite.html&auto=true

where baseURL is the location of the web site to test and test is the start location of the test suite, means the code of the tests generated with the Selenium IDE

Selenium server

Install the following:

Selenium Java Server

The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 1.5.0 or higher in order to start. To use this package, you need to have selenium-server.jar. You can download selenium-server.jar from http://www.openqa.org/selenium-rc/

PHPUnit2

The easiest way to install PHPUnit2 and the Selenium PHP client driver is using PEAR.

Insalling PEAR on Microsoft Windows

On Windows, go-pear uses stdin for user input, so you must download go-pear first and then run it:

  • Note: Since PHP 4.3.0, the PHP CLI binary is named php.exe in the cli/ folder of your PHP directory. The CGI is also named php.exe but it sits directly in your PHP directory, use the CLI binary instead. In PHP 5.0.0+, the PHP CLI binary is php.exe

Following an excerpt from the Selenium documentation:

First, make sure you've already started the Java Selenium Server separately in another process. The Selenium Server should remain up and running throughout this process; you shouldn't need to start/stop it each time you use the Client Driver. (Though, of course, if you need to start and stop the server, you certainly can, just by automatically starting it from the command line.)

Once you've installed the PHP Client Driver in one way or another, you'll need to require_once 'Testing/Selenium.php'; to get access to the Testing_Selenium class. (Make sure this path is in your include path!)

Then you can just create a new Testing_Selenium object, which is full of handy methods that handly your Selenium commands. You'll need to initialize the object using the hostname and port of the Selenium Server, the browser string to use with "getNewBrowserSession" (e.g. "*firefox"), and the base URL at which we'll start testing. When you're ready to begin, run the "start" method on your Testing_Selenium object; when it's time to close the browser, use the "stop" method. If one of the methods has an error, Testing_Selenium will throw a Testing_Selenium_Exception, which you can wrap up in a try/catch block if you like.

While we recommend that you use the PHP Client Driver together with a testing framework like PHPUnit, a testing framework is not required; you can use the PHP Client Driver with any program whatsoever to automate tasks in your browser. (Note that there's more than one project called "PHPUnit" out there; we recommend using the version by Sebastian Bergmann available at phpunit.de, the one available at sourceforge.net isn't as mature.)

To use this package, you need to have selenium-server.jar. You can download selenium-server.jar from http://www.openqa.org/selenium-rc/

To Start Selenium RC Server

$java -jar selenium-server.jar

CompleteSearch: completesearch/Markus (last edited 2007-09-25 13:47:12 by guest-214)