Environment installation by Dima & Alena

We created this instruction for Windows platform as we use it on our workstations. We are not trying to build a powerful web service here, we just trying to figure out how to auto-test web applications. We love Unix too, and if your plan is to configure this on Unix, we expect that you will be able to assemble a similar setup using this post as a guidance.

Table of content

1. Required
	1.1 Java Development Kit (JDK)
	1.2 Ant
	1.3 Selenium
	1.4 Браузер (Firefox, IE)

2. Install to start Java tests
	2.1 TestNG
	2.2 log4j

3. Install to start PHP tests
	3.1 PHP
	3.2 PEAR
	3.3 PHPUnit
	3.4 Testing_Selenium
	3.5 log4php

4. To access our SVN repository
	4.1 TortoiseSVN

5. Additional information
	Why did we install log4?


1. Let’s start with required components

1.1 JDK

Please load it from here and make sure you have selected JDK (not JRE). All you need to do after download is to start the installation.
If you are a regular Java developer, you will most likely see many different versions of Java installed on you machine.  We installed downloaded package into С:\program files\Java\jdk1.6.0_12


Fig. 1 JDK install

Once installation is complete, we need to check that we can execute and compile Java code without specifying its home dir. Please check that the PATH variable set to C:\program files\Java\jdk1.6.0_12\bin. Confirm that the value is exactly as listed here. Close enough is not good enough. Also we have to create (check value) JAVA_HOME = C:\Program Files\Java\jdk1.6.0_12.

Fig. 2 All is looking good (so far)

1.2 Ant

To install Ant, we used the Ant 1.7.1 binaries and this installation manual. We will refer to installation directory as ANT_HOME. It was installed into C:\ant, and for us ANT_HOME = C:\ant. It is important to confirm that the PATH contains ANT_HOME\bin (in our case C:\ant\bin).

There is an assumption that our readers are already familiar with intuitively-obvious OS Windows interface for manipulating PATH.

To test the Ant install, we can execute following command ant to check that everything is ok.

Fig. 3 Validate Ant, install and config

This output indicates a successful install of Ant. We are satisfied with output shown on Fig.3.

1.3 Selenium Grid

We load it from here and unpack into C:\. The Selenium directory as in the archive, is best renamed to ‘selenium’. After the directory rename, we should see C:\selenium and we will refer to it as SELENIUM_HOME.
To validate you can run command – ant -f C:\selenium\build.xml sanity-check.

Fig. 4 Validating Selenium installation

1.4 Firefox*

Firefox can be downloaded here. We would recommend installing it into the default location – С:\Program Files\Mozilla Firefox, or obediently agree with all of the default options/selections during installation.

2. Preparing for Java tests launch

2.1 TestNG

We have chosen to use TestNG version 5.8-jdk15, which can be downloaded from here. It is enough to unpack content of downloaded archive into C:\testng. I will call this folder TESTNG_HOME. As you realised my TESTNG_HOME = C:\testng.

2.2 Log4j

We will load log4j for debugging and analysis of the ‘uncut’ logs of Selenium from Java. Load the unpacked archive into C:\log4j. LOG4J_HOME = C:\log4j.

3. Assembling to run PHP tests

There is a long road to install PHP driver for Selenium. I hope this walkthrough will save you some time. We will install PHP and PEAR. With help of PEAR we will install PHPUnit and finally we will install Testing_Selenium. Let’s begin!

3.1 PHP install

We use version 5.2.8 of PHP for Windows, using the msi-installer. You can load it from here. We prefer to use the msi-installer, because it allows us to configure all extensions, PEAR and even documentation in one quick step. Unlike the zip-package install. We definitely need PEAR and we recommend installing all extensions it offers – 16M. By the way, installer will set all PATH variables required for you too. I installed PHP into C:\php (PHP_HOME=C:\php).

Two points to mention during install:

Fig. 5 We do not need web server to run tests

Рис. 6 Do not forget to install PEAR and extensions

For those of you who does not like installer and likes to control installation process – please unpack archive into C:\php, set PATH and create environment variable PHPRC (PHP Runtime Configuration), which should point to a directory containing PHP configuration file – php.ini (in my case it is also C:\php).

Apr 16th, 2009 by Alena

Note that the curl extension is obligatory for installation. If it’s not installed you’ll see following error at execution of php-test:
P/1.1 400 Bad Request
Connection: close
Server: Jetty(6.0.x)

The presence of php_curl.dll file in C:\php\ext and ‘extension=php_curl.dll’ line in php.ini file confirm that curl extension is installed. Curl library functions are used to solve the problem of PHP Selenium driver and Selenium Grid interaction.

To check our progress at this point, we can run the ‘php –v’ command at command prompt. You should see something similar to Fig. 7.

Fig. 7 Validating PHP install

Comment: later, while running tests, we had to increase value of default_socket_timeout in file php.ini. I have it set to 300 seconds as sometimes SalesForce site is running tooo slooooow.

3.2 PEAR

At this point, we assume that PHP was installed using the msi method and we have included the PEAR support.
If so, we will find a file go-pear.bat. If you execute this batch file, and agree with all prompts, it will install PEAR. At the end of installation you will see a new file created in the PHP_HOME directory: PEAR_ENV.reg. We need to double click on this registry file in order to import necessary environment settings into the Windows registry.

Content of this file PEAR_ENV.reg:

REGEDIT4
[HKEY_CURRENT_USEREnvironment]
"PHP_PEAR_SYSCONF_DIR"="C:\\php"
"PHP_PEAR_INSTALL_DIR"="C:\\php\\pear"
"PHP_PEAR_DOC_DIR"="C:\\php\\docs"
"PHP_PEAR_BIN_DIR"="C:\\php"
"PHP_PEAR_DATA_DIR"="C:\\php\\data"
"PHP_PEAR_PHP_BIN"="C:\\php\\.\\php.exe"
"PHP_PEAR_TEST_DIR"="C:\\php\\tests"

By running command pear version we can validate PEAR install.

C:\>pear version
PEAR Version: 1.7.2
PHP Version: 5.2.8
Zend Engine Version: 2.2.0
Running on: Windows NT PHILKA 5.1 build 2600

3.3 Installing PHPUnit

PHPUnit represents an environment for Unit-tests creation. We will install PHPUnit with PEAR.
Initialising PEAR-channel for install:

C:\>pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded

Deutschland channel is open – we can ‘sail’.

C:\>pear install channel://pear.phpunit.de/PHPUnit
Did not download optional dependencies: pear/Image_GraphViz, pear/Log, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "pear/Image_GraphViz" (version >= 1.2.1)
phpunit/PHPUnit can optionally use package "pear/Log"
phpunit/PHPUnit can optionally use PHP extension "pdo"
phpunit/PHPUnit can optionally use PHP extension "pdo_mysql"
phpunit/PHPUnit can optionally use PHP extension "pdo_sqlite"
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.0)
downloading PHPUnit-3.3.15.tgz ...
Starting to download PHPUnit-3.3.15.tgz (272,118 bytes)
...........................................done: 272,118 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.3.15

3.4 Testing_Selenium

Testing_Selenium is a PHP driver for Selenium RC. A more detailed package description can be obtained from here.
Let’s ‘deodorise’ channel pear.php.net …

C:>\pear channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded

… and now we start the install of Testing_Selenium component!

C:\>pear install channel://pear.php.net/Testing_Selenium-0.4.3
downloading Testing_Selenium-0.4.3.tgz ...
Starting to download Testing_Selenium-0.4.3.tgz (2,417,750 bytes)
...............................................done: 2,41
7,750 bytes
install ok: channel://pear.php.net/Testing_Selenium-0.4.3

March 02th, 2011 by Dima

This PEAR driver ver. 0.4.3 has big problems with driver-server interaction. So we reccommend you to replace downloaded Selenium.php with this.

3.5 log4php

During the selection of the components to use, we thought twice and decided that log4php logging will be more convenient for this exercise. We know that log4php is a younger twin of log4j. You can download log4php here.
If you do not know what an SVN ‘checkout’ operation is, you might like to install one of the SVN clients such as TortoiseSVN (see 4 below), and read its documentation to learn more.

Log4php file structure looks like this:

Fig. 8 log4php – file structure

After install, we must rename directory log4php\trunk\src\main\php into log4php and copy it to PHP_HOME. In this case the directory is C:\php. Once log4php is copied into c:\PHP. We are done!

4. TortoiseSVN**

Tortoise SVN is a convenient SVN client which is available from here. It is integrated into Windows Explorer, and this is the reason we must reboot after its installation. You will need it a bit later to checkout the Recruiting application tests from our SVN repository.

__________________________________________

* – You can use IE. As we expect this is already installed on this Windows platform. For those of you who need an instruction how to use IE instead of Firefox – we will explain before we start running tests.

** – Installation of TortoiseSVN is also not required especially if you have one of standalone or integrated SVN clients . There are plenty of tools which allow to checkout from SVN. Inquisitive minds can point their Browser at http://deepshiftlabs.com/svn/tests/trunk/salesforce/ and get files from out website. Although we don’t expect that you will.

Print this post | Home

14 comments

  1. ALL says:

    “Чтобы проверить, можно выполнить команду – ant -f C:\selenium\build.xml sanity-check” – билд был успешным, но с ошибкой “can’t open C:\Java\jdk1.6.0_16\lib\tzmappings ZoneInfo: C:\Java\jdk1.6.0_16\lib\zi\ZoneInfoMappings”
    Как победить эту ошибку?

  2. Dima says:

    Если у вас действительно существует папка C:\Java\jdk1.6.0_16\lib\zi\, то я предположу, что вы установили не jdk, а jre и потом переименовали папку. В моей версии (jdk1.6.0_10) папка zi и tzmappings по таким путям есть только в jre.

    Я думаю, должна помочь переустановка Java в соответствии с инструкциями выше (кстати, удобно ли иметь Java именно в корне С?).

  3. ALL says:

    Java пришлось туда переместить тк при запуске вашего теста-примера C:\simple_test_java стало ругаться по типу “..неизвестная команда C:\Program” – тут судя по всему не нравился пробел, который находится в “Program files”, после перенесения жавы в папку без пробелов ошибка ушла.

  4. Dima says:

    Хм, странно – я ещё раз проверил, если переменная окружения JAVA_HOME указывает на расположение jdk, всё работает, даже если в пути есть пробелы (C:\Program Files\Java\jdk1.6.0_12).
    Рад, что вам удалось запустить тест.
    Спасибо, что описали своё решение!

  5. Кирилл says:

    Спасибо за материал!

    Только вот не совсем понятно, причём тут curl?

    У меня как раз и валятся тесты со словами HTTP 1.1 400 Bad Request. Как со включённым curl’ом, так и без него. С Selenium RC всё отлично работает и без curl’а. Да и если посмотреть в код Testing_Selenium, то curl там нигде не используется.

    Может быть, в чём-то другом причина??

  6. Dima says:

    Кирилл, попробуйте заменить PEAR\Testing\selenium.php вот этим файлом:
    http://www.deepshiftlabs.com/sel_blog/wp-content/uploads/2009/10/Selenium.zip

    Эта версия драйвера точно умеет и хочет использовать curl )

  7. Кирилл says:

    Dima,

    Запоздалое спасибо! :)

  8. Jimmy says:

    3.3 Установка собственно пакета PHPUnit

    Вот этот пункт уже устанавливается не так, а так: http://www.phpunit.de/manual/current/en/installation.html

  9. Blockhead says:

    А можно всеж по подробней про log4php, в скачанном нету папки PHP(

  10. Blockhead says:

    Pri ustanovke phpUnit oshibka v konsoli:
    No valid packages found
    install failed

  11. bear says:

    Blockhead, спасибо за подсказку – инструкция по установке log4php обновлена.

    По поводу PHPUnit – если использовалась вот эта инструкция , то я не подскажу. Это официальная инструкция PHPUnit, и если она не работает, надо обращаться к разработчикам.

  12. Blockhead says:

    Reshenie po PHPUnit est’ v internete, uvi neznaiu 4to pomoglo (proboval 2-3 sposoba) no v itoge vstalo. Teper’ u menia drugaia problema(
    Ia ee opisal na stranise s zapuskom pervogo testa

  13. fazlul says:

    hi when i try to install Testing_Selenium I get this following error :

    C:\Documents and Settings\FRSTAR>pear install channel://pear.php.net/Testing_Sel
    enium-0.4.3
    SECURITY ERROR: Will not write to C:\DOCUME~1\FRSTAR\LOCALS~1\Temp\pear\cache\85
    6924d025d47bfd07fcf5e1a1e53426rest.cacheid as it is symlinked to C:\DOCUME~1\FRS
    TAR\LOCALS~1\Temp\pear\cache\856924d025d47bfd07fcf5e1a1e53426rest.cacheid – Poss
    ible symlink attack
    install failed

    any help would be appriciated

  14. bear says:

    Never run into this error, but they say this helps:
    “Try to clear C:\bla-bla-bla\Temp\pear\cache\ folder and run command again.”