Skip to content

Configuration

There are multiple properties files located in src/main/resources:

  • _api.properties - API test endpoints reference
  • _config.properties - global test configuration
  • _database.properties - database connection properties
  • _email.properties - emailable reports config
  • _testdata.properties - test user credentials

All the properties may be retrieved in a test using R class:

R.API.get("GetUserMethods")
R.CONFIG.get("browser")
R.DATABASE.get("db.url")
R.EMAIL.get("title")
R.TESTDATA.get("user.email")

The default config properties can be obtained by

Configuration.get(Parameter.BROWSER)

All the project configuration properties are located in a _config.properties file. In the table below, please see the description of most of the parameters:

Attribute Meaning Example
env Environment specific configuration feature STAG, PROD, DEMO
selenium_url Selenium/Appium server URL http://localhost:4444/wd/hub
app_version Application version/build number for reporting 1.2.5
url Base application URL https://zebrunner.com
browser Browser for testing chrome, firefox, MicrosoftEdge, safari
headless Run tests in headless browser mode. Default: false Boolean
browser_language Browser language. Default: NULL to use default browser language. es, fr
locale Locale for using by L10N feature en_GB, de_DE, fr_FR
localization_testing Enables auto verification for elements that are marked with @Localized annotations Boolean
localization_encoding Encoding for generation of new/missed localization resources UTF-8
retry_count Number of test-retryings in case of failure. Default: 0 means that a test will be performed only once Integer
thread_count Number of threads to use when running tests in parallel. Default: -1 to use value from TestNG suite xml. Integer
data_provider_thread_count Number of threads to use for data providers when running tests in parallel. Default: -1 to use value from TestNG suite xml. Integer
core_log_level Level for Carina logging. Default: INFO ALL, DEBUG, ERROR, WARN, FATAL, INFO, OFF, TRACE
test_run_rules Executing rules logic: test_run_rules={RULE_NAME_ENUM}=>{RULE_VALUE1}&&{RULE_VALUE2};;... test_run_rules=PRIORITY=>P1&&P2&&P4;;OWNER=>owner;;TAGS=>tag1=temp||!!feature=reg
test_naming_pattern The pattern by which the name of the test method will be formed. {tuid} {test_name} - {method_name}
retry_interval Timeout interval in ms between calling HTML DOM for the element. Default: 100. For mobile automation specify in between 500-1000 Integer
auto_screenshot Global switch for taking screenshots. When disabled, screenshots will be captured only after failures. Default: true. Boolean
allow_fullsize_screenshot Global switch for allowing full size screenshots on failures. Default: false Boolean
max_screen_history Max number of reports artifacts saved in history. Default: 10 Integer
driver_event_listeners Comma-separated list of extra driver listeners. Listeners provide extra custom actions for WebDriver and have to be the instances of WebDriverEventListener com.some_company.core.EventListener
max_driver_count Max number of drivers per thread. Default: 3 Integer
init_retry_count Number of extra attempts to create a driver. Default: 0 means that there will be no extra attempts. Integer
init_retry_interval Interval in seconds between the attempts to create a driver. Default: 1 Integer
forcibly_disable_driver_quit If enabled, turns off webdriver quit based on initizalization phase. Default: false Boolean
custom_capabilities Path to the properties file with custom key-value capabilities browserstack/win/win_10_Edge.properties
explicit_timeout Timeout is seconds to wait for a certain condition to occur before proceeding further in the code Integer
read_timeout Timeout is seconds to read response from Selenium/Appium. Default: 600 Integer
page_opening_strategy Determines how carina detects whether the expected page is opened BY_ELEMENT, BY_URL, BY_URL_AND_ELEMENT
page_recursive_reflection Determines if pages should be searched in dependencies. Default: false Boolean
element_loading_strategy Determines how carina detects appearing of web elements on page BY_PRESENCE, BY_VISIBILITY, BY_PRESENCE_OR_VISIBILITY
auto_download The enabled parameter prevents downloading dialog and downloading a file automatically into the test artifact folder. The feature is supported for Chrome and Firefox. Default: false false, true
custom_artifacts_folder Custom unified path for auto-downloaded artifacts for all tests. Default: NULL to download into the unique test artifacts location. String
auto_download_apps MIME types / Internet Media Types. The parameter is needed only to configure auto-downloading for FireFox. List of values application/pdf
log_all_json API response will be logged in JSON format. Default: true Boolean
ignore_ssl API requests/responses to ignore SSL errors. Default: false Boolean
project_report_directory Path to a folder where the testing report will be saved ./reports
proxy_host Hostname of the proxy server host.example.com
proxy_port Port number 80
proxy_protocols Comma-separated list of internet protocols used to carry the connection information from the source requesting the connection to the destination for which the connection was requested. http,https,ftp,socks
browserup_proxy Boolean parameter which enables or disables the automatic BrowserUp proxy launch Boolean
browserup_port Port number for BrowserUp proxy (if nothing or 0 specified, then any free port will be reused) Integer
browserup_ports_range Range of ports that will be used for starting of browserup proxy. The first available port from the range will be used. If all ports are used, then a test will wait for the first freed port. 8001:8003
proxy_set_to_system Boolean parameter which enables or disables the setup of a proxy Boolean
no_proxy Excluded hostname(s) for communication via proxy. Available only when proxy_host and proxy_port are declared! localhost.example.com
date_format Date format for DateUtils.class HH:mm:ss dd/MM/yyyy, HH:mm MM/dd/yyyy
time_format Date format for DateUtils.class HH:mm:ss.SSS, HH:mm a zzz
crypto_key_value crypto key OIujpEmIVZ0C9kOkXniFRw==
tls_keysecure_location Path to a directory with tls secure keys ./tls/keysecure
db.url Database url jdbc:mysql://localhost/test
db.username Database username username
db.password Database password password
Most of the properties may be read in the following way:

Configuration.get(Parameter.URL) // returns string value
Configuration.getBoolean(Parameter.AUTO_SCREENSHOT) // returns boolean value
Configuration.getInt(Parameter.BIG_SCREEN_WIDTH) //return int value
Configuration.getDouble(Parameter.MAX_DRIVER_COUNT) // returns double value

Environment specific configuration

In some cases, it is required to support multiple environments for testing. Let's assume we have STAG and PROD environments which have different application URLs. In this case, we need to specify the following properties in _config.properties:

env=PROD
STAG.url=http://stag-app-server.com
PROD.url=http://prod-app-server.com

And get an env-specific argument in the test in the following way:

Configuration.getEnvArg("url")
Configuration.getEnvArg(Configuration.Parameter.URL)

As a result, you switch between the environments just changing the env argument in the _config.properties file.

In some cases, it is necessary to store multiple parameter sets for the same env (for example, if multiple databases are used). For this, the concept of an alias is added. The parameter with env and alias will be stored in the following way:

STAG.mongo.db.url=mongodb://stag.example.com:27017
STAG.mysql.db.url=jdbc:mysql://localhost/stag_test
PROD.mongo.db.url=mongodb://prod.example.com:27017
PROD.mysql.db.url=jdbc:mysql://localhost/prod_db

Get an env-alias-specific argument in the test in the following way:

Configuration.getEnvArg(Configuration.Parameter.DB_URL, "mongo") // mongodb://prod.example.com:27017
Configuration.getEnvArg(Configuration.Parameter.DB_URL, "mysql") // jdbc:mysql://localhost/prod_db

Tests execution filter configuration

The test_run_rules parameter is responsible for filtering tests. There are 3 filter types:
1) PRIORITY - enum field (from P0 to P6)
2) OWNER - the test owner
3) TAGS - custom label

Example of how to attach labels in code:

@Test
@TestPriority(Priority.P3)
@MethodOwner(owner = "Josh")
@MethodOwner(owner = "Jake")
@TestTag(name = "feature", value = "web")
@TestTag(name = "type", value = "regression")
public void t4(){
    ...
    some code
    ...
}

test_run_rules parameter parse logic:

1) A simple filter:

test_run_rules=OWNER=>Josh
#Where OWNER is tag, and "=>" split's tag and rule part.
#Because of the "Josh" rule, test will be executed if it has Josh as owner

2) With negative logic:

test_run_rules=OWNER=>!!Josh
#Test will be executed if it hasn't got Josh as owner

3) With boolean logic:

#Use || or && to create more difficult rules
#where || == OR; && == AND.

test_run_rules=OWNER=>Josh||Jake
#Test will be executed if it has at least Josh or Jake as owner.

test_run_rules=OWNER=>Josh&&Jake
#Test will be executed if it has at least Jish and Jake as owner

test_run_rules=OWNER=>Josh&&Jake||Peter
#Expression will be processed in sequential priority, like
#test_run_rules=OWNER=>((Josh&&Jake)||Peter)
#So test will be executed if it has at least (Josh and Jake) or (Peter) as owner

4) To add more tags to the rule, use ";;", for example:

#;; works as && (AND) but for tags

test_run_rules=PRIORITY=>!!P1;;OWNER=>Josh&&!!Jake;;TAGS=>feature=web&&!!type=smoke||feature=android

#Test will be executed if it has
#1) no @TestPriority(Priority.P1)
#AND
#2) @MethodOwner(owner = "Josh") without @MethodOwner(owner = "Jake")
#AND
#3) (@TestTag(name = "feature", value = "web") without @TestTag(name = "type", value = "smoke"))
        or @TestTag(name = "feature", value = "android")        

#In other words, tests will be executed only with Priority that differs from P1, with Josh as owner if there is no Jake 
#and if they are not for smoke web or if they are for android.

Changing the pattern of forming the name of the test method

The name of the test method is formed based on the pattern provided in the test_naming_pattern parameter. The pattern can be formed from the following parts:
1) {test_name} - test name (content of name attribute of <test> tag in xml)
2) {tuid} - TUID, see doc
3) {method_name} - test method name
4) {method_priority} - test method priority (number)
5) {method_thread_pool_size} - the number of threads to be used when invoking the method on parallel
6) {group_names} - the groups this method belongs to, possibly added to the groups declared on the class
7) {method_description} - description of test method
8) {test_class} - simple name of test class this method belongs to

Default pattern: test_naming_pattern={tuid} {test_name} - {method_name}

FAQ

Where is a recommended place to declare configuration parameters?

Declare default parameters in _config.properties. For multi-maven projects, you can use extra underscore symbol to override default settings on new layer __config.properties, ___config.properties, etc.

How to override params from the code?

Put method might be used to override parameters globally or for a current test only

R.CONFIG.put("selenium_url", "http://host1:4444/wd/hub"); //override selenium_url globally for the rest of tests
R.CONFIG.put("selenium_url", "http://host2:4444/wd/hub", true); // override selenium_url for current test only
R.DATABASE.put("db.driver", "org.postgresql.Driver") //override db.driver in_database.properties globally

Crypted values are returned in encrypted format. How can I decrypt them?

Use R.CONFIG.getDecrypted(String key) method to read decrypted value.

You should have valid crypto key to be able to decrypt values. For details, visit Security

Can I override configuration parameters from CI?

Provide updated values via System Properties to override a value, for example:

mvn -Denv=PROD ...