2020-10-15 10:41:57 +02:00
# Run End-to-End Tests
2020-10-08 09:05:22 +02:00
2020-10-15 10:41:57 +02:00
### Run Selenium
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
Create a working directory
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
`mkdir selenium; cd selenium;`
Selenium has been used for automating the browser.
2020-10-15 06:33:47 +02:00
[Download ](https://www.selenium.dev/downloads/ ) the `latest stable version` of the `Selenium standalone server JAR file` .
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
`wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar`
2020-10-15 06:33:47 +02:00
Also [download ](https://chromedriver.chromium.org/downloads ) the `latest stable version` of `Chrome Driver` .
Once you have downloaded Chrome Driver, you need to unzip it by running the following command:
2020-12-16 17:33:40 +01:00
`wget https://chromedriver.storage.googleapis.com/86.0.4240.22/chromedriver_linux64.zip`
2020-10-15 06:33:47 +02:00
`unzip chromedriver_linux64.zip`
2020-10-15 10:47:44 +02:00
Once you have unzipped it, you need to move the *chromedriver* file (shared library) and place it inside the same folder where you have placed the Selenium standalone server file.
2020-10-15 06:33:47 +02:00
Now we can run selenium by two ways:
* Start selenium server with a command which usually looks like:
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
`java -jar selenium-server-standalone-*.jar -port 4444`
2020-10-15 10:41:57 +02:00
2020-12-16 17:33:40 +01:00
* Or run selenium in docker with
2020-10-08 09:05:22 +02:00
`docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug`
2020-10-15 10:41:57 +02:00
or `docker run -d --network="host" -v /dev/shm:/dev/shm selenium/standalone-chrome-debug`
or `docker run -d --network host -v /dev/shm:/dev/shm selenium/standalone-chrome-debug`
2020-10-08 09:05:22 +02:00
2020-10-15 10:41:57 +02:00
### Run the acceptance tests
2020-10-08 09:05:22 +02:00
2020-10-15 10:41:57 +02:00
* Install *yarn* . For example on Ubuntu:
2020-10-08 09:05:22 +02:00
2020-10-15 10:41:57 +02:00
```
2020-12-16 17:33:40 +01:00
sudo apt install yarnpkg
2020-10-15 10:41:57 +02:00
```
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
* Install *npm* tools to manage *nodejs* libraries. For example on Ubuntu:
2020-10-15 11:01:37 +02:00
```
apt install npm
2020-12-16 17:33:40 +01:00
```
* Go into the git local repository of the Dolibarr version to test.
```
cd ~/git/dolibarr
npm install cucumber nightwatch-api nightwatch
2020-10-15 11:01:37 +02:00
npm update
```
2020-10-08 09:05:22 +02:00
2020-10-15 10:41:57 +02:00
* In *nightwatch.conf.js* file inside the root directory of the project and inside the configuration file following environment variable has been specified. We can change the default values according to our local configuration.
2020-10-08 09:05:22 +02:00
```
2020-10-15 10:41:57 +02:00
const admin_username = process.env.ADMIN_USERNAME || 'admin';
2020-10-08 09:05:22 +02:00
const admin_password = process.env.ADMIN_PASSWORD || 'password';
const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/';
```
2020-10-14 18:03:02 +02:00
2020-10-15 11:36:19 +02:00
* You can run a test using following commands
2020-10-08 09:05:22 +02:00
2020-10-15 11:36:19 +02:00
`LAUNCH_URL='<launch_url>'; ADMIN_USERNAME='<admin_username>'; ADMIN_PASSWORD='<admin_password>';`
2020-12-16 17:33:40 +01:00
`yarnpkg run test:e2e test/acceptance/features/<feature_file>`
2020-10-08 09:05:22 +02:00
2020-12-16 17:33:40 +01:00
For example: `yarnpkg run test:e2e test/acceptance/features/WebUI/addUsers.feature`
2020-10-08 09:05:22 +02:00
2020-10-15 11:36:19 +02:00
Note: The script to run all the acceptance tests is specified in `scripts` object of `package.json` file inside the project's root directory as :
2020-10-08 09:05:22 +02:00
2020-10-15 11:36:19 +02:00
`"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"`
2020-10-08 09:05:22 +02:00
2020-10-14 18:03:02 +02:00
After you run the above command you can see the test running. For that :
2020-10-08 09:05:22 +02:00
2020-10-14 18:03:02 +02:00
* open `Remmina` (Remmina is a Remote Desktop Client and comes installed with Ubuntu)
2020-10-08 09:05:22 +02:00
2020-10-14 18:03:02 +02:00
* choose `VNC` and enter `localhost` on the address bar
2020-10-08 09:05:22 +02:00
2020-10-14 18:03:02 +02:00
* enter `secret` as the password