emieza / selenium-php

Selenium example with PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Selenium tests with PHP

Installation

You need to have installed:

References:

General procedure

Install dependencies:

$ sudo apt install php-curl php-mbstring php-xml

Install composer from here: https://getcomposer.org/download/

Clone repo and download packages:

$ git clone https://github.com/emieza/selenium-php
$ cd selenium-php
$ composer install

Shell 1: web server

Start webapp in port 8000 in an independent shell:

$ cd src
$ php -S 0.0.0.0:8000

Shell 2: start geckodriver

Start geckodriver (by default listens in port 4444) in another shell:

$ geckodriver

Shell 3: execute tests

Run the Selenium basic tests (in a 3rd shell):

$ php test1.php

Or run all tests in tests folder (done with phpunit):

$ vendor/bin/phpunit tests

Troubleshooting

If the test errors do not appear, open your php.ini file (usually /etc/php/X.Y/cli/php.ini) and check the variable zend.assertions = 1.

Exercises

  1. Install and execute the first test.
  2. Modify the first test so that you add a name in the user field. Check the documentation for that.
  3. Put a random name in the user field (create a hardcoded list of possible names).
  4. Check that the introduced name is present in the last line in the comanda.txt file
  5. Choose a product of the products.txt file insted of a fixed one.
  6. Choose 3 products of the products.txt file (and check all of them).

About

Selenium example with PHP


Languages

Language:PHP 100.0%