Selenium installation in php

We would be using selenium client API developed by Facebook. The API documentation is available at https://facebook.github.io/php-webdriver/ The API is similar to the one in Java. We would be using PHPUnit as a testing framework to write the Selenium tests.
  • Install PHP with WAMP.
  • Download and start Selenium server
  • Install Selenium client package provided by Facebook

Installation of WAMP

After installation of WAMP, you need to update the PATH variable to include the PHP directory .( e.g. “C:\wamp64\bin\php\php7.0.10”) Below command can be used to see which ini file is being used by PHP.
 
php –ini

Below command can be used to view the php info
 
php -n -c /conf -r’phpinfo();’

Below command is used to view which modules have been loaded by php
 
php -m

You can find out where the PHP is installed using below command in windows.
 
where php.exe

Download and start Selenium server

We also need the Selenium standalone server to be running before we start automating browsers. You can download and start the server using below command.
 
java -jar selenium-standalone-server.jar

Install Selenium client package provided by Facebook

Create composer.json file with below contents in your working directory.
 
{
    “require-dev”: {
    “phpunit/phpunit”: “*”,
    “facebook/webdriver”: “dev-master”
    }
    }
https://packagist.org/ is the package manager for PHP just like how we have a NPM for Node.js Then download composer.phar file from below location. https://getcomposer.org/composer.phar Then execute below command to install all required libraries.
 
php composer.phar install

Before you execute above command, you will have to enable PHP’s openssl extension. Otherwise, you will get below error. The openssl extension is required for SSL/TLS protection but is not available. All library files are downloaded and stored in vendor directory as shown in below image. directory-layout-in-php-selenium directory-layout-in-php-selenium In next lesson, we will see how to create a simple selenium test file and execute it.

Web development and Automation testing

solutions delivered!!