

# Pre-requisites
The project requires a browser driver to run the tests. The project currently is set to use Chrome webdriver. 
The webdiver must be downloaded and placed anywhere on your PC.

You can download the Chrome webdriver for the current versions from the following link, section Stable, see binary column and select the correct platform.
https://googlechromelabs.github.io/chrome-for-testing/

for older Chrome versions, you can download the Chrome driver from the following link
https://developer.chrome.com/docs/chromedriver/downloads

Unzip the downloaded file and place the chromedriver.exe file in a folder of your choice.

## Starting up the Chrome WebDriver
Go to the folder where you placed the chromedriver.exe file and run the following command
In windows, right click to get the contextual menu and select ```Open in terminal```.

Once the terminal is open, run the following command to start the Chrome WebDriver
```chromedriver.exe --port=4444```

Don't close the terminal window. The WebDriver will be running in the background.


# Installation

The code is in bitbucket repository. You can clone the repository using the following command.

Repository Name ecomnova-frontendtesting

```git clone git@bitbucket.org:ecomnova/ecomnova-frontendtesting.git```

The project require PHP >= 7.3

The project supports DDEV. DDEV config is included in the repository.

## DDEV Installation
- Clone the repository
- go to the folder
- run the command ```ddev start```
- open the project in IDE

## Non-DDEV Installation

- ensure you have PHP >= 7.3 installed
- ensure composer is installed
- inside the project folder run the following command
```composer install```

# Tests execution 

In the IDE in the test classes you should have icons to run the tests. You can run the tests from there.
Alternatively, you execute the tests using phpunit command.

From the root of the project run the following command

```./vendor/bin/phpunit src/Tests/AddressFieldsTest.php```

Change the test class name to run the other tests.

# Documentation for the WebDriver
https://github.com/php-webdriver/php-webdriver

How to use the WebDriver
https://github.com/php-webdriver/php-webdriver/wiki/Example-command-reference

# What is what

## src/Tests
This folder contains the test classes. Each test class is a separate test suite. There are tests for the core 
functionality of the framework as well as the frontend tests.

## src
This folder contains the classes that helps to execute and wrap the webdriver logic making it the Ecomnova Framework. 
The classes are used to interact with the browser in an easy way. See the basic usage in the class ```src\ProductPageBasicTest```


# FAQ
## My tests are failing but were executing fine before
Some tests like those for calendar depend on data that changes with time. If the tests are failing, it is possible that the data has changed. 


# Troubleshooting

## Failed to connect to localhost port 4444 after 2204 ms: Couldn't connect to server
Ensure the chromedriver is running. If you closed the terminal window where you started the chromedriver, you need to start it again.


