Ever felt the need for lightning-fast acceptance tests in a lightweight setup?
Look no further, I’ll show you how it’s done!
First, install the necessary dependencies.
composer require codeception/codeception:^5.0 codeception/codeception/module-webdriver:^4.0
Once dependencies are installed, get aerokube-selenium, enabling you to run a Selenium instance without Docker effortlessly:
In my case, i’m using: selenoid_windows_amd64.exe
Next, create our config file browsers.json. But first, check your Chrome version. Mine is 115.
{
"chrome": {
"default": "115",
"versions": {
"115": {
"image": ["path-to-my-project/vendor/bin/chromedriver.exe"]
}
}
}
}
Download ChromeDriver version 115 and place it in the vendor/bin
directory of your project or where it suits you:
Now, let’s configure our acceptance tests in Codeception
, specifically Acceptance.suite.yml
.
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
actor: AcceptanceTester
extensions:
enabled:
- Codeception\Extension\RunProcess:
0: php -d variables_order=EGPCS -S localhost:4444 -t tests/_data/public
sleep: 1
modules:
enabled:
- WebDriver:
url: http://localhost:4444
browser: chrome # 'chrome' or 'firefox'
window_size: maximize
# add Codeception\Step\Retry trait to AcceptanceTester to enable retries
step_decorators:
- Codeception\Step\ConditionalAssertion
- Codeception\Step\TryTo
- Codeception\Step\Retry
Now, open a terminal window in your project directory and start the Selenium
instance:
vendor/bin/selenoid_windows_amd64.exe -conf browsers.json -disable-docker
Finally, open another terminal window and run your tests:
vendor/bin/codecept run Acceptance
Note: If you want to capture tests screen by screen, you can use the Recorder extension of Codeception.
Happy coding!
#qa #testing #codeception #selenium #php