Webtest WebTest GitHub Home

General Step config

Description

This is a nested task of webtest and is used to configure the target host system to use for a particular webtest and several other features such as reporting of test results and printing of debug information.

The <config> element is a nested element of webtest and is used to configure the target host system to use for a particular webtest and several other feature like reporting of test results and printing of debug information.

Since the <config> element can contain so many different attributes, the description of the attributes is split over many tables.

The first table describes the default URL parameter.

basepath
Required? No, defaults is empty
Defines the constant base path used to construct request URLs, e.g. "shop" can be considered a basepath in "http:/www.myhost.com/shop/productlist" and "http:/www.myhost.com/shop/checkout".
host
Required? No, default is "localhost"
Defines the hostname to use for executing requests, e.g. "localhost" or "www.myhost.com".
port
Required? No, defaults is "80"
Defines the port number to use for executing requests, e.g. "8080".
protocol
Required? No, defaults is "http"
Defines the protocol to use for executing requests. "http", "https", and "file" are currently the only supported protocols.

The next table describes the attributes responsible for WebTest's reporting and logging. These attributes define if and where WebTest store logging information. Actual reporting is usually performed by xsl transformation after the test complete.

resultpath
Required? No, default is the subdirectory "webtest-results" of the project base directory.
Defines the resultpath of saved responses (for example last response).
saveprefix
Required? No, default is "response"
Sets the name to use if the current response received from the target host is to be saved into a file. A unique id will also be appended after the prefix.
saveresponse
Required? No, default is "false"
Defines whether the last response received from the target host is saved into the file "<saveprefix><uniqueId>.html". saveprefix is the value set in the <saveprefix> config element.
uniqueId is a timestamp at the time the file is saved.
This is especially helpful for debugging your tests.

The next table describes the webtest's behaviour when encountering failures and errors.

errorproperty
Required? No
Specifies the name of an ant property which is set to true if the execution of the current <webtest> stops if a program error (unhandled exception) is encountered in one of the test steps. When using this property, set "haltonerror" to "false". Then check the ant property after performing all of your tests and if set fail. This allows your tests to continue running even if some experience execution errors (allowing you to catch multiple errors with one test run) but still ultimately fails the build if anything went wrong.
failureproperty
Required? No
Specifies the name of an ant property which is set to true if the test fails. When using this property, set "haltonfailure" to "false". Then check the ant property after performing all of your tests and if set fail. This allows your tests to continue running even if some fail (allowing you to catch multiple errors with one test run) but still ultimately fails the build if anything went wrong.
haltonerror
Required? No, default is "true"
Determines if the execution of the current <webtest> stops if a program error (unhandled exception) is encountered in one of the test steps. An ANT BuildFailed exception will be raised if it is set to "Yes". This will terminate the execution of the ANT script.
Setting the option to "false" will stop the execution of the current <webtest> but continues with the next ANT task, e.g. another <webtest>.
haltonfailure
Required? No, default is "true"
Determines if the execution of the current test halts if a failure of one of the test steps is detected, e.g. a <verify...> test did not pass. Even when set to "false" all of the trailing <step>s of the current <webtest> will be skipped but processing will continue with the next <webtest>.

The next table groups miscellaneous configuration options.

autorefresh
Required? No, default is "false"
Specifies whether the client should automatically follow page refresh requests (html: <meta http-equiv="refresh" ...>).
If set to "true" or "false", this indicates if refresh requests should be followed or not. If set to an integer value only refresh request with a delay less or equal to the specified value will be executed.
browser
Required? No, default is "best"
Specifies the browser that should be simulated. All values are evaluated case insensitive. Allowed values are best (emulates Chrome), chrome, Firefox45 (or FF45), Firefox52 (or FF52), Firefox (or FF) will emulate FF52, Edge, InternetExplorer11 (or IE11), InternetExplorer (or IE).
defaultpropertytype
Required? No, default is "dynamic",
Determines the default storage used for properties. If set to "dynamic", webtest dynamic properties are used. If set to "ant", properties are stored as ant variables. If set to "antstrict", ant properties are used but normal ant immutability is respected, i.e. if a property is already set, then it won't be over-written.
When setting this attribute to "ant" or "antstrict", the #{propName} syntax allows late binding to ant properties whereas the ${propName} syntax remains supported with normal binding.
If using ant properties to store webtest properties, the values of properties persist across <webtest> tasks but you run the risk of name clashes with other tasks using ant properties.
If using repeat steps, avoid using "antstrict" for this setting if you need access to the repeat loop counter value. The repeat loop will execute as normal but the #{count} property will remain unchanged once set.
showhtmlparseroutput
Required? No, default is "false"
Defines that the JTidy output of parsing resulting HTML pages shall be shown. If enabled, the generated errors/warnings are collected as test step parameters and written into the report file. The output is also written to stdout. The parser output can be used to detect invalid HTML code in a particular page, unbalanced elements or invalid nesting of elements (e.g. <form> and <table>).
Since the parser can generate a lot of warnings and these warnings need to be manually analyzed, it is recommended to enable this option only on demand, e.g. to initially verify the correctness of an HTML page or if a particular test case does not work (e.g. a button can not be found in a page).
sslKeyStore
Required? No, default is "null"
Specifies a file system path or URL to a keystore or certificate file containing one or more client certificates. If present, WebTest is performing ssl authentication using client certificates. The file / keystore type is defined by "sslKeyStoreType".
sslKeyStorePassword
Required? No, default is "null"
Specifies the keystore password.
sslKeyStoreType
Required? No, default is "jks"
Specifies type of the keystore or ssl certificate file defined by "sslKeyStore". Can be "pkcs12" or "jks" (Java Key Store) ...
sslTrustStore
Required? No, default is "null"
Specifies the path or URL to a Java Key Store containing server certificates to be trusted.
sslTrustStorePassword
Required? No, default is "null"
Specifies the sslTrustStore password.
timeout
Required? No, default is "300"
Defines the timeout value in seconds for both connection and socket.
The connection timeout is the maximum allowed time until a connection is etablished. The socket timeout is the timeout for waiting for data.
A timeout value of zero is interpreted as an infinite timeout.
useInsecureSSL
Required? No, default is "false"
Specifies if WebTest should ignore insecure SSL certificates like self signed certificate that have not been added to the truststore or expired certificates.
config
<webtest name="Visit the shop on myhost">
  <config
    host="www.myhost.com"
    port="8080"
    protocol="http"
    basepath="shop"
    saveresponse="true"
    resultpath="/tmp/results"
  >
    <header name="User-Agentvalue="Mozilla/4.0"/>
    <header name="Accept-Languagevalue="de-ch"/>
  </config>
  ...
</webtest>

The previous test code example will create URLs with the following prefix: "http://www.myhost.com:8080/shop/".

Parameters

description
Required? no
The description of this test step.

Nested Parameters

header
Required? no
Specify http headers by name and value
option
Required? no
Tweak the underlying web client options/settings