Codeception (PHP) integration with Asayer.
- Prerequisites
- Set it up
- Run it
- Dashboard
- Application Parameters
- Capabilities
- Integrating Asayer with your existing project
- Local Testing
- Mark Session
- Dependencies
- Clone the repo
git clone https://github.com/asayer-io/asayer-codeception.git
or download it - Install the required dependencies
composer install
- Update the
acceptance.suite.yml
file under thetests
folder with your Asayer API key
To run the test, proceed as follows:
- In the terminal, execute
php vendor/bin/codecept run acceptance
- Go to https://dashboard.asayer.io/automate/sessions and see what happened.
Details about the test session can be found in the Dashboard under Automate > Sessions.
This is where all your executed tests are listed. You can use the filter to navigate through Passed or Failed tests (see Mark A Completed Test to learn how to mark a test).
Encloses various details like State, Duration, Execution Time, Platform/Browser as well as the User who initiated the test.
Each session gets fully recorded. The video can be played or downloaded (as part of the Assets).
All commands gets displayed in the form of a comprehensive timeline, including details such as Execution Time, Duration and Screenshot.
A screenshot is taken automatically upon the execution of each and every command. Simply hover over the cam icon to see it.
Various actions (i.e. HTTP) taking place throughout the session, are logged.
Chrome and Opera console logs are captured and displayed back.
Clicking on the Download Assets button will download a zip file enclosing:
- All screenshots
- Session recording (.webm)
- Server logs
- Browser console logs (only Chrome and Opera)
The list of your active tunnels is available in Settings > Tunnels. For more information, see Local Testing.
You can change the app settings from the acceptance.suite.yml
file under modules:config:WebDriver
.
...
modules:
enabled:
...
config:
WebDriver:
...
capabilities:
apikey: 'ASAYER API KEY'
name : 'Testing Codeception with Asayer'
...
Belows are the supported settings:
Name | Value | Description | Required |
---|---|---|---|
apikey |
Your Asayer API key | yes | |
name |
The name of the test to execute (will be visible in the Dashboard) | yes | |
build |
The build's ID (if any) | no | |
tunnelId |
The tunnel's ID for local tests | yes for (local testing) |
You can change the caps from the acceptance.suite.yml
file under modules:config:WebDriver
.
...
modules:
enabled:
...
config:
WebDriver:
...
browser: chrome
capabilities:
platform: 'any'
...
Below is the list of supported capabilities:
Name | Possible Values | Default Value | Description | Required |
---|---|---|---|---|
platform |
linux windows mac android ios any |
linux | The platform used for the test | yes |
browser |
chrome firefox ie safari opera edge |
chrome | The browser used for the test | yes |
seleniumVersion |
2.53.1 , latest |
latest |
The selenium version used for the test | no |
browserVersion |
see the list of supported browser versions | latest |
The browser version used for the test | no |
flags |
- | A list of flags to be passed to the browser, see Fun with Flags | no | |
deviceName |
see the list of supported mobile devices | - | The android device name to use for the test | yes if platform is set to android or ios |
The list of supported browser versions are:
Name | Versions |
---|---|
edge | 15 |
opera | 48 |
firefox | 47 , 56.0.1 |
chrome | 62 |
ie | 11 |
safari | 11 |
The list of available mobile simulators/emulators is as below:
platform | deviceName |
---|---|
android |
Galaxy_S8 , LG_G6 , Pixel , Pixel_XL , Pixel_C , Nexus_5X , Nexus_6P Nexus_9 |
ios |
iPhone 5 , iPhone 5s , iPhone 6 , iPhone 6 Plus , iPhone 6s , iPhone 6s Plus , iPhone 7 , iPhone 7 Plus , iPhone SE , iPad Air , iPad Air 2 , iPad Pro |
Note: Only Android 7.1.1
and iOS 10.3
are supported.
In addition to the above mentioned capabilities, you can attach a list of flags
(to run the browser with) by simply adding [FLAG NAME]:[value]
to the acceptance.suite.yml
file under modules:config:WebDriver:capabilities:flags
.
In the following example, we used some of the Chrome flags:
...
modules:
...
config:
WebDriver:
...
capabilities:
...
flags:
"--incognito": true
"--start-fullscreen": true
These flags will be interpreted as --incognito --start-fullscreen
.
- Kepp in mind that each browser has its own and unique list of flags:
Follow the below steps to integrate Asayer with your existing project:
- Add/update your
acceptance.suite.yml
file with the following configuration:... modules: enabled: - WebDriver ... config: WebDriver: protocol: https host: 'hub.asayer.io' port: 443 browser: chrome capabilities: apikey: 'ASAYER API KEY' name : 'Testing Asayer with Codeception' platform: 'any' ....
- Have the required dependencies installed
- If you want to add auto-reporting support to your tests, you can add the
AsayerReporting
helper class to your project undertests\_support\Helper
, and load it after theWebDriver
module in theacceptance.suite.yml
file... modules: enabled: - WebDriver - \Helper\AsayerReporting ...
Local testing allows you to test your internal servers, in addition to public URLs, using Asayer's infrastucture without having to update your firewalls or proxies.
- Download
asayer-tunnel
for Windows (32bits|64bits), Linux (32bits|64bits) or Mac (32bits|64bits) - Open a terminal and
cd
to the binary folder - Execute the binary by running
asayer-tunnel_win64.exe -k API_KEY -i TUNNEL_NAME
The complete manual for the tunnel is the following:
$ asayer-tunnel_win64.exe -h
Usage:
main [OPTIONS]
Application Options:
-k, --key= The user API_KEY
-i, --id= The id of the tunnel
-p, --port= The local proxy port (default: 9090)
-w, --whitelist= List of URLs to exclude from proxy, separated by ';' (eg: url1; url2)
--proxy-url= If you are behind a proxy set its URL here, the format is HOST:PORT.
If needed, auth info can be set in --proxy-user and --proxy-password
--proxy-user= Basic auth HTTP Proxy username
--proxy-password= Basic auth HTTP Proxy password
-v, --verbose Show debug information
Help Options:
-h, --help Show this help message
Note that only -k
and -i
parameters are required.
To set up your tests for local testing, you must add the tunnelId
capability to the acceptance.suite.yml
file under modules:config:WebDriver:capabilities
section
...
modules:
enabled:
...
config:
WebDriver:
...
capabilities:
tunnelId: "[TUNNEL_ID]"
...
Once done, run your tests as usual. HTTP traffic will then be redirected to the machine on which the asayer-tunnel
binary is running through a secure connection.
Details about the local tests can be found in the Dashboard. Local tests are marked with a plug icon.
- Local Testing is available on
chrome
,firefox
andopera
browsers only - Only 3 active tunnels are allowed per organization
Once the session is completed, you can mark the test (either passed or failed) by calling the markSession(["Passed"|"Failed"])
method of the AsayerReporting
helper class.
You can also rely on our REST API to do so by submitting sessionID
and sessionStatus
parameters:
Endpoint: https://dashboard.asayer.io/mark_session
Method: POST
Json: {
sessionID: $this->sessionId, // Required
sessionStatus:"Passed"|"Failed", // Required
apiKey:"YOUR ASAYER API KEY", // Required
}
The state will be visible in the Dashboard:
For reporting purposes, you can call the markSessionDetails(state, requirementID, testStatus)
method of the AsayerReporting
helper class.
markSessionDetails
's parameters are:
state
: the session's staterequirementID
: the session's requirement IDtestStatus
: an array of"testId" => "testStatus"
See the example below:
$this->markSessionDetails("Passed", "requirementId1230", array("TEST ID 1"=>"Passed","TEST ID 2" => "Failed"));
You can also rely on our REST API by calling:
Endpoint: https://dashboard.asayer.io/mark_session
Method: POST
Json: {
sessionID:$this->sessionId, // Required
sessionStatus:"Passed"|"Failed", // Required
apiKey:"YOUR ASAYER API KEY ($this->apikey)", // Required
reqID: "REQUIREMENT ID", // Required
testStatus: { // Required
"TEST ID 1":"Passed"|"Failed",
"TEST ID 2": "Passed"|"Failed"
...
}
}
Note that every step’s status is automatically reported to Asayer throughout the execution of the test. This may be seen in in the Reporting section, as shown below:
This project relies on the below dependencies:
- codeception/codeception