Lettuce (Python) integration with Asayer.
- Prerequisites
- Set it up
- Run it
- Dashboard
- Application Parameters
- Capabilities
- Integrating Asayer with your existing project
- Local Testing
- Mark Session
- Dependencies
- Python 2.7 or newer
- An IDE is optional
- Clone the repo
git clone https://github.com/asayer-io/asayer-lettuce.git
or download it - Install the required dependencies
pip install -r requirements.txt
- Update the
asayer.config.json
file under theconfig
folder with your Asayer API key
To run the test, proceed as follows:
- In the terminal, execute
lettuce
- 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 asayer.config.json
file.
{
"apikey": "ASAYER API KEY",
"server": "https://hub.asayer.io/wd/hub",
"name": "Testing Lettuce with Asayer",
...
}
Belows are the supported settings:
Name | Value | Description | Required |
---|---|---|---|
apikey |
Your Asayer API key | yes | |
server |
https://hub.asayer.io/wd/hub |
Asayer's Selenium hub | 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 asayer.config.json
file under capabilities
.
{
...
"capabilities": {
"browserName": "chrome",
"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 asayer.config.json
file under capabilities:flags
.
In the following example, we used some of the Chrome flags:
{
...
"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:
- Copy the
AsayerWebDriver.py
file to your project under thefeatures
folder - Have the required dependencies installed
- Copy the
asayer.config.json
file to your project under theconfig
folder, setup the Application Parameters (here) then configure the desired Capabilities (here) - Make sure that the
before.each_scenario
hook of theAsayerWebDriver
file is the only hook initiating theworld.browser
webDriver
instance
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 asayer.config.json
file
{
...
"tunnelId": "[TUNNEL_ID]",
"capabilities": {
...
}
}
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 mark_session(["Passed"|"Failed"])
method of the AsayerWebDriver.py
file.
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: world.session_id, // Required
sessionStatus:"Passed"|"Failed", // Required
apiKey:"YOUR ASAYER API KEY" | world.apikey, // Required
}
The state will be visible in the Dashboard:
For reporting purposes, you can call the mark_session_details(state, requirementID, testStatus)
method of the AsayerWebDriver.py
file.
mark_session_details
's parameters are:
state
: the session's staterequirementID
: the session's requirement IDtestStatus
: a dictionary object of"testId":"testStatus"
See the example below:
mark_session_details("Passed", "requirementId1230", {"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:
- lettuce
- selenium
- nose
- requests
To install the required dependencies, execute in the terminal pip install -r requirements.txt