Web Application & REST API Integration Plugin
The plugin provides the integration between web application testing functionality and REST API features.
Installation
-
Copy the below line to
dependencies
section of the projectbuild.gradle
filePlease make sure to use the same version for all VIVIDUS dependencies. Example 1. build.gradleimplementation(group: 'org.vividus', name: 'vividus-plugin-web-app-to-rest-api')
-
If the project was imported to the IDE before adding new dependency, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.
Table Transformers
FROM_SITEMAP
FROM_SITEMAP
transformer generates table based on the website sitemap.
The use of web-application.main-page-url property for setting of main page for crawling is deprecated and will be removed in VIVIDUS 0.7.0, please see either mainPageUrl transformer parameter or transformer.from-sitemap.main-page-url property.
|
The properties outlined in the table below are applied to all FROM_SITEMAP transformers utilized in the tests, unless they override the values by specifiying the corresponding table parameters.
Property Name | Acceptable values | Default | Description |
---|---|---|---|
|
URL |
The main application page URL, used as initial seed URL that is fetched by the crawler to extract new URLs in it and follow them for crawling. |
|
|
|
|
Ignore sitemap parsing errors. |
|
|
|
Whether invalid URLs will be rejected silently (where "invalid" means that the URL is not under the base URL, see sitemap file location explanation for more details) |
|
|
|
defines whether urls that has redirect to the one that has already been included in the table are excluded from the table |
The parameters outlined in the table below are exclusively applicable to the transformer in which they are declared.
Parameter | Acceptable values | Default | Description |
---|---|---|---|
|
URL |
If not specified, the default value is taken from |
The main application page URL, used as initial seed URL that is fetched by the crawler to extract new URLs in it and follow them for crawling. |
|
Relative URL |
The relative URL of |
|
|
The column name to store collected relative URLs in the generated table. |
||
|
|
If not specified, the default value is taken from |
Ignore sitemap parsing errors. |
|
|
If not specified, the default value is taken from |
Whether invalid URLs will be rejected silently (where "invalid" means that the URL is not under the base URL, see sitemap file location explanation for more details) |
Examples:
{transformer=FROM_SITEMAP, siteMapRelativeUrl=/sitemap.xml, ignoreErrors=true, strict=false, column=page-url}
FROM_HEADLESS_CRAWLING
FROM_HEADLESS_CRAWLING
transformer generates table based on the results of headless crawling.
The use of web-application.main-page-url property for setting of main page for crawling is deprecated and will be removed in VIVIDUS 0.7.0, please see either mainPageUrl transformer parameter or transformer.from-headless-crawling.main-page-url property.
|
Property Name | Acceptable values | Default | Description | ||
---|---|---|---|---|---|
General |
|||||
|
|
main application page URL, used as initial seed URL that is fetched by the crawler to extract new URLs in it and follow them for crawling.
|
|||
|
Comma-separated list of values |
List of relative URLs, a seed URL is a URL that is fetched by the crawler to extract new URLs in it and follow them for crawling. |
|||
|
Regular expression a |
|
The regular expression to match URLs. The crawler will not crawl all URLs that matching the given regular expression and they will not be added to the resulting table. URI fragments and URL query are ignored at filtering. |
||
|
Regular expression |
no default value |
The regular expression to match extensions in URLs. The crawler will ignore all URLs referring to files with extensions matching the given regular expression. |
||
|
|
|
Defines whether urls that has redirect to the one that has already been included in the table are excluded from the table. |
||
|
|
|
Socket timeout in milliseconds. |
||
|
|
|
Connection timeout in milliseconds. |
||
|
|
|
Max allowed size of a page in bytes. Pages larger than this size will not be fetched. |
||
|
|
|
Maximum connections per host. |
||
|
|
|
Maximum total connections. |
||
|
|
|
Whether to follow redirects. |
||
|
|
|
Maximum depth of crawling, for unlimited depth this parameter should be set to -1. |
||
|
|
|
Number of pages to fetch, for unlimited number of pages this parameter should be set to -1. |
||
|
|
|
Politeness delay in milliseconds between sending two requests to the same host. |
||
|
|
|
Max number of outgoing links which are processed from a page. |
||
|
|
|
Whether to honor links with nofollow flag. |
||
|
|
|
Whether to honor links with noindex flag. |
||
|
|
|
|||
|
|
|
Cookie policy as defined per cookie specification. |
||
|
|
|
Whether to consider single level domains valid (e.g. http://localhost). |
||
|
|
|
Whether to crawl https pages. |
||
|
Set of headers to set for every crawling request being sent.
|
||||
Proxy |
|||||
|
|
|
Proxy host. |
||
|
|
|
Proxy port. |
||
|
|
|
Username to authenticate with proxy. |
||
|
|
|
Password to authenticate with proxy. |
Parameter Name | Description | ||
---|---|---|---|
|
main application page URL, used as initial seed URL that is fetched by the crawler to extract new URLs in it and follow them for crawling.
|
||
|
The column name in the generated table. |
Examples:
{transformer=FROM_HEADLESS_CRAWLING, column=page-url}
FROM_HTML
The transformer has been moved to |
Steps
Resources validations
Steps to check resource availability using HTTP requests.
Resource validation statuses
Status | Description |
---|---|
|
An HTTP request to the resource returns a status code other than 200 OK. |
|
An HTTP request has been blocked by Akamai Web Application Firewall and requires manual validation. |
|
Reasons:
|
|
An HTTP request to the resource returns 200 OK status code. |
|
Reasons:
|
|
A resource validation has already been performed, i.e. if the same resource might be present on several pages so we do not need to validate it twice. |
Properties
Property Name | Acceptable values | Default | Description |
---|---|---|---|
|
HTML Attributes |
|
A comma-separated list of HTML attributes where resource links will be searched. If values present in multiple attributes, the link will be fetched from the first one. |
|
|
|
Whether to attach the HTTP response body for HTTP calls with non-successful status codes (may reduce performance). |
Validate resources on web pages
Validates resources on web pages.
Resource validation logic:
-
If the
pages
row contains relative URL then it gets resolved against URL inweb-application.main-page-url
property, i.e. if the main page URL ishttps://elderscrolls.bethesda.net/
and relative URL is/skyrim10
the resulting URL will behttps://elderscrolls.bethesda.net/skyrim10
-
Collect elements by the CSS selector from each page
-
Get either
href
orsrc
attribute value from each element, if neither of the attributes exists the validation fails -
For each received value execute HEAD request
-
If the status code is 200 OK then the resource validation is considered as passed
-
If the status code is one of 404 Not Found, 405 Method Not Allowed, 501 Not Implemented, 503 Service Unavailable then GET request will be executed
-
If the GET status code is 200 OK then the resource validation is considered as passed, otherwise failed
-
Then all resources found by $htmlLocatorType `$htmlLocator` are valid on:$pages
Deprecated syntax (will be removed in VIVIDUS 0.7.0):
Then all resources by selector `$cssSelector` are valid on:$pages
-
$htmlLocatorType
- The HTML locator type, eitherCSS selector
orXPath
. -
$htmlLocator
- The actual locator.-
$pages
- The pages to validate resources on.
-
Then all resources found by xpath `//a` are valid on:
|pages |
|https://vividus.org/ |
|/test-automation-made-awesome|
Validate resources from HTML
Validates resources from HTML document.
Resource validation logic:
-
Collects elements by the CSS selector from the specified HTML document
-
Get either
href
orsrc
attribute value from each element, if neither of the attributes exists the validation fails. If the element value contains relative URL then it gets resolved against URL inweb-application.main-page-url
property -
For each received value execute HEAD request
-
If the status code is 200 OK then the resource validation is considered as passed
-
If the status code is one of 404 Not Found, 405 Method Not Allowed, 501 Not Implemented, 503 Service Unavailable then GET request will be executed
-
If the GET status code is 200 OK then the resource validation is considered as passed, otherwise failed
-
Then all resources found by $htmlLocatorType `$htmlLocator` in $html are valid
Deprecated syntax (will be removed in VIVIDUS 0.7.0):
Then all resources by selector `$cssSelector` from $html are valid
-
$htmlLocatorType
- The HTML locator type, eitherCSS selector
orXPath
. -
$htmlLocator
- The actual locator.-
$html
- HTML document to validate.
-
Then all resources found by CSS selector `a,img` in ${source-code} are valid
Validate redirects
The step has been moved to |
Validate SSL rating
Then SSL rating for URL `$url` is $comparisonRule `$gradeName`
-
$url
- The URL for SSL scanning and grading. -
$comparisonRule
- The comparison rule. -
$gradeName
- The name of grade. The possible values:A+
,A
,A-
,B
,C
,D
,E
,F
,T
,M
.
Property Name | Acceptable values | Default | Description |
---|---|---|---|
|
|
SSL Labs endpoint. |
https://www.google.com
Then SSL rating for URL `https://www.google.com` is equal to `B`
Cookie Steps
Set browser cookies to the HTTP context
Set current browser cookies to the HTTP client for future executing HTTP requests.
When I set browser cookies to HTTP context
Given I am on main application page
When I set browser cookies to HTTP context
When I execute HTTP GET request for resource with relative URL `/get`
Set HTTP cookies to the browser
Set current cookies from the previous HTTP calls to the browser. Make sure that expected cookies from HTTP calls matches with web browser opened page domain. The actions performed by the step:
-
add the cookies;
-
refresh the current page (this action is required to apply the changes in cookies).
When I set HTTP context cookies to browser
When I execute HTTP GET request for resource with relative URL `/get`
Given I am on main application page
When I set HTTP context cookies to browser
Set HTTP cookies to the browser without applying changes
Set current cookies from the previous HTTP calls to the browser, but does not apply the changes in cookies instantly. The current page must be refreshed or the navigation must be performed to apply the cookie changes. Make sure that expected cookies from HTTP calls matches with web browser opened page domain.
When I set HTTP context cookies to browser without applying changes
When I execute HTTP GET request for resource with relative URL `/get`
Given I am on main application page
When I set HTTP context cookies to browser without applying changes