initbiz / oc-selenium2tests-plugin
Write tests in OctoberCMS using Selenium 2
Installs: 486
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Type:october-plugin
pkg:composer/initbiz/oc-selenium2tests-plugin
Requires
- php: >=7.0
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2024-02-05 14:43:51 UTC
README
This is a repo of OctoberCMS plugin by InIT.biz.
How-to
System requirements
- Java 8 installed in default location of your platform (for example /usr/bin/javafor Linux)
- The driver of the browser you want to use for tests (for example ChromeDriver)
Note for Linux users
Installing Chromium from your package manager should install ChromeDriver for you
Note for Mac users
You probably will have to link newer version of Java to your default path as described here
Installation
- You can use three methods to install the plugin:
- from OctoberCMS Marketplace,
- clone the code from GitHub into /plugins/initbiz/selenium2testsdirectory or
- install using Composer composer require --dev initbiz/oc-selenium2tests-plugin
- Add "laravel/dusk": "^2.0"to yourrequire-devsection incomposer.jsonfile
- Go to /plugins/initbiz/selenium2tests
- Copy selenium.php.exampletoselenium.phpand configure your environment
You can also create selenium.php file in your root directory, which will be read when the one in plugin's directory does not exist
Testing OctoberCMS basics
It is a good practice not to use the same DB for testing and developing purposes.
In order to configure a different database for testing purposes create directory testing in config directory and copy database.php to the newly-created directory. Then change the default connection as you wish.
After that, if you use APP_ENV=testing in your .env file, configuration from the testing directory will be used.
Writing tests in Selenium 2
There are example tests in tests/example directory that use Ui2TestCase class.
Running tests
First of all, you have to run the Selenium 2 standalone server which is included in the package. In order to start Selenium 2 server go to <project_root>/plugins/initbiz/selenium2tests and run java -jar selenium.jar.
You are ready to run tests using PHPUnit from OctoberCMS's vendor/bin/phpunit.
You can keep test files wherever you want, but .gitignore of the plugin will exclude all files from /tests except those in /tests/examples.
Browser options (like headless mode)
If you want to for example run browser in headless mode, you can add that line to your selenium.php file:
define('TEST_SELENIUM_BROWSER_OPTIONS', ['--headless']);
