com.qmetry.qaf.automation.keys.ApplicationProperties Maven / Gradle / Ivy
Show all versions of qaf Show documentation
/*******************************************************************************
* Copyright (c) 2019 Infostretch Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package com.qmetry.qaf.automation.keys;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.testng.IRetryAnalyzer;
import org.testng.ITestContext;
import org.testng.ITestResult;
import com.qmetry.qaf.automation.core.ConfigurationManager;
import com.qmetry.qaf.automation.core.QAFListener;
import com.qmetry.qaf.automation.data.BaseDataBean;
import com.qmetry.qaf.automation.data.PasswordDecryptor;
import com.qmetry.qaf.automation.http.UriProxySelector;
import com.qmetry.qaf.automation.step.QAFTestStepListener;
import com.qmetry.qaf.automation.ui.selenium.SeleniumCommandListener;
import com.qmetry.qaf.automation.ui.webdriver.QAFWebDriverCommandListener;
import com.qmetry.qaf.automation.ui.webdriver.QAFWebElementCommandListener;
import com.qmetry.qaf.automation.ws.rest.RestClientFactory;
/**
* TO get properties key/value While reading value First preference will be
* System property if set before run
*
* @author chirag
*/
public enum ApplicationProperties {
/**
* key: report.log.level
* value: one of Info, Pass, Fail
*
* - Info
- will report Info, pass and fail messages
*
- Pass
- will report pass and fail messages but not Info
*
- Fail
- will report fail messages but not Info or Pass
*
*/
REPORT_LOG_LEVEL("report.log.level"),
/**
* key: report.log.skip.success
* value: boolean, when true it will not show verification success message in report.
*/
REPORT_SKIP_SUCCESS("report.log.skip.success"),
/**
* key: test.results.dir
* value: dir to place generated result files
*/
REPORT_DIR("test.results.dir"), JSON_REPORT_ROOT_DIR("json.report.root.dir"), JSON_REPORT_DIR("json.report.dir"),
/**
* key: selenium.screenshots.dir
* value: dir to place screen-shots
*/
SCREENSHOT_DIR("selenium.screenshots.dir"),
/**
* key: selenium.screenshots.relative.path
* value: screen-shots relative path for reporting
*/
SCREENSHOT_RELATIVE_PATH("selenium.screenshots.relative.path"),
/**
* key: selenium.success.screenshots
* value: set this flag to 1 if you want to capture screen-shots for
* assertion/verification success.
*/
SUCEESS_SCREENSHOT("selenium.success.screenshots"),
/**
* key: selenium.failure.screenshots
* value: set this flag to 1 if you want to capture screen-shots for
* assertion/verification failures. Default value is 1
*/
FAILURE_SCREENSHOT("selenium.failure.screenshots"),
/**
* key: selenium.wait.timeout
* value: default wait time to be used by framework by wait/assert/verify methods
*/
SELENIUM_WAIT_TIMEOUT("selenium.wait.timeout"),
/**
* key: selenium.auto.shutdown
* value: flag to auto shutdown selenium server
*/
SELENIUM_AUTO_SHUTDOWN("selenium.auto.shutdown"),
/**
* key: tng.context
* value: {@link ITestContext} object for current running
* thread/test-case.
*
*/
CURRENT_TEST_CONTEXT("tng.context"),
/**
* key: current.testcase.name
* value: name of the current running test case.
*
*/
CURRENT_TEST_NAME("current.testcase.name"),
/**
* key: current.testcase.desc
* value: description of the current running test case.
*
*/
CURRENT_TEST_DESCRIPTION("current.testcase.desc"),
/**
* key: current.testcase.result
* value: {@link ITestResult} object for the current running test
* case.
*
* @since 2.1.9
*/
CURRENT_TEST_RESULT("current.testcase.result"),
/**
* key: driver.name
* value: driver to be used, for instance firefoxDriver or
* firefoxRemoteDriver etc...
*
* @since 2.1.6
*/
DRIVER_NAME("driver.name"),
/**
* key: driver.resources.format
* value: file or directory to load driver specific resources, for
* instance driver specific locators. If you specified driver.name
* androidDriver
or androidRemoteDriver
you can
* specify resources for android driver by using
* android.resources
key.
*
* @since 2.1.12
*/
DRIVER_RESOURCES_FORMAT("%s.resources"),
/**
* key: driver.init.retry.timeout
* value: duration in multiplication of 10 seconds for example 50.
*
* @since 2.1.9
*/
DRIVER_INIT_TIMEOUT("driver.init.retry.timeout"),
/**
* key: driver.additional.capabilities
* value: specify multiple additional capabilities as map that can
* applicable for any driver.
*
* @see {@link #DRIVER_CAPABILITY_PREFIX} to provide individual capability
*
* {@link #DRIVER_ADDITIONAL_CAPABILITIES_FORMAT} to provide driver
* specific capability
*/
DRIVER_ADDITIONAL_CAPABILITIES("driver.additional.capabilities"),
/**
* key: driver.capabilities
* value: specify additional capability by name with this prefix that
* can applicable for any driver. For example,
* driver.capabilities.<capabilityName>=<value>
*
* @see {@link #DRIVER_ADDITIONAL_CAPABILITIES} to provide multiple
* additional capabilities
*/
DRIVER_CAPABILITY_PREFIX("driver.capabilities"),
/**
* key: <drivername>.additional.capabilities
*
* value: specify multiple additional capabilities as map that can
* applicable for specific driver.
*
* @see {@link #DRIVER_CAPABILITY_PREFIX} to provide single capability
* {@link #DRIVER_ADDITIONAL_CAPABILITIES} to provide capability for
* all drivers
*/
DRIVER_ADDITIONAL_CAPABILITIES_FORMAT("%s.additional.capabilities"),
/**
* key: <drivername>.capabilities
* value: specify additional capability by name with this prefix that
* can applicable for specific driver. For example,
* <drivername>.capabilities.<capabilityName>=<value>
*
* @see {@link #DRIVER_CAPABILITY_PREFIX} to provide individual capability
*
* {@link #DRIVER_ADDITIONAL_CAPABILITIES_FORMAT} to provide driver
* specific capability
*/
DRIVER_CAPABILITY_PREFIX_FORMAT("%s.capabilities"),
/**
* key: driverClass
* value: capability name to specify driver class name.
*/
CAPABILITY_NAME_DRIVER_CLASS("driverClass"),
/**
* key: remote.server
* value: remote server url, which will be considered if configured
* remote driver.
*
* @since 2.1.6
*/
REMOTE_SERVER("remote.server"),
/**
* key: remote.port
* value: remote server port, which will be considered if configured
* remote driver.
*
* @since 2.1.6
*/
REMOTE_PORT("remote.port"),
/**
* key: env.baseurl
* value: base URL of AUT to be used.
*/
SELENIUM_BASE_URL("env.baseurl"), // selenium.browser.url
/**
* key: selenium.command.listeners
* value: provide comma separated custom command listeners. Custom
* command listener must implement {@link SeleniumCommandListener}
*/
SELENIUM_CMD_LISTENERS("selenium.command.listeners"),
/**
* key: selenium.capture.network.traffic
* value: flag to set capture network traffic true/false, default
* value is false
*/
CAPTURE_NETWORK_TRAFFIC("selenium.capture.network.traffic"),
/**
* key: selenium.skip.autowait
* value:flag to skip auto wait for locator used in command, default
* value is false
*/
SKIP_AUTO_WAIT("selenium.skip.autowait"),
/**
* key: selenium.skip.autowait
* value: comma separated command list to be excluded from auto-wait.
*/
AUTO_WAIT_EXCLUDE_CMD("auto.wait.exclude.commands"),
/**
* key: auto.wait.include.commands
* value: additional comma separated command list to be included for
* auto-wait.
*/
AUTO_WAIT_INCLUDE_CMD("auto.wait.include.commands"),
/**
* key: reporter.log.exclude.commands
* value: additional comma separated command list to be excluded form
* selenium log in HTML report.
*/
REPORTER_LOG_EXCLUDE_CMD("reporter.log.exclude.commands"),
/**
* key: commands.execution.interval
* value: Set execution interval between two selenium commands.
*/
CMD_EXECUTION_INTERVAL("commands.execution.interval"),
/**
* key: integration.tool.qmetry
* value: flag that indicates integration with QMetry
*/
INTEGRATION_TOOL_QMETRY("integration.tool.qmetry"),
/**
* key: integration.tool.qmetry.uploadattachments
* value: flag that indicates integration with QMetry
*/
INTEGRATION_TOOL_QMETRY_UPLOADATTACHMENTS("integration.tool.qmetry.uploadattachments"),
/**
* key: qmetry.schedule.file
* value: Set QMetry Schedule XML file path.
*/
INTEGRATION_PARAM_QMETRY_SCHEDULE_FILE("qmetry.schedule.file"),
/**
* key: integration.param.qmetry.service.url
* value: Set QMetry web service URL.
*/
INTEGRATION_PARAM_QMETRY_SERVICE_URL("integration.param.qmetry.service.url"),
/**
* key: integration.param.qmetry.user
* value: Set QMetry web service login user name.
*/
INTEGRATION_PARAM_QMETRY_USER("integration.param.qmetry.user"),
/**
* key: integration.param.qmetry.pwd
* value: Set QMetry web service password.
*/
INTEGRATION_PARAM_QMETRY_PWD("integration.param.qmetry.pwd"),
/**
* key: integration.param.qmetry.project
* value: Set QMetry project.
*/
INTEGRATION_PARAM_QMETRY_PRJ("integration.param.qmetry.project"),
/**
* key: integration.param.qmetry.build
* value: Set QMetry build.
*/
INTEGRATION_PARAM_QMETRY_BLD("integration.param.qmetry.build"),
/**
* key: integration.param.qmetry.release
* value: Set QMetry release.
*/
INTEGRATION_PARAM_QMETRY_REL("integration.param.qmetry.release"),
/**
* key: integration.param.qmetry.cycle
* value: Set QMetry release.
*/
INTEGRATION_PARAM_QMETRY_CYCLE("integration.param.qmetry.cycle"),
/**
* key: integration.param.qmetry.suitid
* value: Set QMetry suit id.
*/
INTEGRATION_PARAM_QMETRY_SUIT("integration.param.qmetry.suitid"),
/**
* key: integration.param.qmetry.suitid
* value: Set QMetry suit id.
*/
INTEGRATION_PARAM_QMETRY_SUITERUNID("integration.param.qmetry.suitrunid"),
/**
* key: integration.param.qmetry.platform
* value: Set QMetry platform id.
*/
INTEGRATION_PARAM_QMETRY_PLATFORM("integration.param.qmetry.platform"),
/**
* key: integration.param.qmetry.drop
* value: Set QMetry drop id.
*/
INTEGRATION_PARAM_QMETRY_DROP("integration.param.qmetry.drop"),
/**
* key: webdriver.remote.session
* value: Set existing session of web-driver.
*
* This feature can be used with remote web-driver
*
*/
WEBDRIVER_REMOTE_SESSION("webdriver.remote.session"),
/**
* key: webdriver.chrome.driver
* value: Set Chrome driver path.
*/
CHROME_DRIVER_PATH("webdriver.chrome.driver"),
/**
* key: qc.testset.name
* value: Set QC test set name.
*/
QC_TS_NAME("qc.testset.name"),
/**
* key: qc.testset.folder.path
* value: Set QC test set folder path.
*/
QC_TS_FOLDER_PATH("qc.testset.folder.path"),
/**
* key: qc.testcase.folder.path
* value: Set QC test case folder path.
*/
QC_TC_FOLDER_PATH("qc.testcase.folder.path"),
/**
* key: qc.run.name
* value: Set QC run name.
*/
QC_RUN_NAME("qc.run.name"),
/**
* key: qc.timezone
* value: (Optional)Set QC server time - that will be used while
* setting date/time in run result.
*/
QC_TIMEZONE("qc.timezone"),
/**
* key: qc.runname.generator.impl
* value: qualified class name that implements
* com.qmetry.qaf.automation.integration.qc.QCRunNameGenerator interface. It
* can be used to generate name in custom format for auto-generated set and
* run name
*/
QC_RUN_NAME_GENERATOR("qc.runname.generator.impl"),
/**
* key: qc.user
* value: Set QC user name that will be used to access QC
*/
QC_USER("qc.user"),
/**
* key: qc.domain
* value: Set QC domain name that will be used to lookup QC project
*/
QC_DOMAIN("qc.domain"),
/**
* key: qc.project
* value: Set QC project name that where test case defined
*/
QC_PROJECT("qc.project"),
/**
* key: qc.pwd
* value: Set QC user password
*/
QC_PWD("qc.pwd"),
/**
* key: qc.service.url
* value: QC service URL, for example:
* http://10.20.30.252:8080/qcbin/
*/
QC_SERVICE_URL("qc.service.url"),
/**
* key: env.load.locales
* value: list of local names to be loaded
*/
LOAD_LOCALES("env.load.locales"),
/**
* key: env.default.locale
* value: local name from loaded locals that need to treated as
* default local
*/
DEFAULT_LOCALE("env.default.locale"), LOCALE_CHAR_ENCODING("locale.char.encoding"),
/**
* key: isfw.version
* value: ISFW version local
*/
ISFW_VERSION("isfw.version"),
/**
* key: isfw.revision
* value: ISFW revision local
*/
ISFW_REVISION("isfw.revision"),
/**
* key: isfw.build.date
* value: ISFW build date local
*/
ISFW_BUILD_DATE("isfw.build.date"),
/**
* key: isfw.build.info
* value: ISFW build information - version, revision and build date.
* local
*/
ISFW_BUILD_INFO("isfw.build.info"),
/**
* key: qaf.listeners
* value: list of qaf listeners (fully qualified class name that
* implements any of {@link QAFTestStepListener},
* {@link QAFWebDriverCommandListener},
* {@link QAFWebElementCommandListener}) to be registered.
*
* @see QAFListener
*/
QAF_LISTENERS("qaf.listeners"),
/**
* key: teststep.listeners
* value: list of test step listeners (fully qualified class name
* that implements QAFTestStepListener) to be registered.
*
* @see QAFTestStepListener
*/
TESTSTEP_LISTENERS("teststep.listeners"),
/**
* key: wd.command.listeners
* value: list of webdriver command listeners (fully qualified class
* name that implements QAFWebDriverCommandListener) to be registered.
*
* @see QAFWebDriverCommandListener
*/
WEBDRIVER_COMMAND_LISTENERS("wd.command.listeners"),
/**
* key: we.command.listeners
* value: list of webelement command listeners (fully qualified class
* name that implements QAFWebElementCommandListener) to be registered.
*
* @see QAFWebElementCommandListener
*/
WEBELEMENT_COMMAND_LISTENERS("we.command.listeners"),
/**
* key: integration.param.jira.baseurl
* value: Set JIRA Base URL.
*/
INTEGRATION_PARAM_JIRA_SERVICE_URL("integration.param.jira.baseurl"),
/**
* key: integration.param.jira.password
* value: Set JIRA Password.
*/
INTEGRATION_PARAM_JIRA_PWD("integration.param.jira.pwd"),
/**
* key: integration.param.jira.project
* value: Set JIRA Projects.
*/
INTEGRATION_PARAM_JIRA_PROJECT("integration.param.jira.project"),
/**
* key: integration.param.jira.username
* value: Set JIRA Username.
*/
INTEGRATION_PARAM_JIRA_USER("integration.param.jira.user"),
/**
* key: step.provider.pkg
* value: one or more package name from where test-step should be
* loaded. When more than one package provided and same step defined in
* multiple package than it will be loaded based on the package order in
* "step.provider.pkg", the last package has highest priority.
*/
STEP_PROVIDER_PKG("step.provider.pkg"),
/**
* key: retry.count
* value: integer to specify how many times test should be retried on
* failure by default retry analyzer. This will not take effect if custom
* retry analyzer is provided using
* {@link ApplicationProperties#RETRY_ANALYZER retry.analyzer }
*/
RETRY_CNT("retry.count"),
/**
* key: retry.analyzer
* value: fully qualified class name that implements
* {@link IRetryAnalyzer}. Provide this property to use your custom retry
* analyzer.
*/
RETRY_ANALYZER("retry.analyzer"),
/**
* key: bean.populate.random
* value: boolean value to specify whether to populate bean data
* randomly or in sequence. This property used by
* {@link BaseDataBean#fillFromConfig(String) fillFromConfig} method while
* populating bean from configuration, when more than one record exist in
* configuration .
*/
BEAN_POPULATE_RANDOM("bean.populate.random"),
DRY_RUN_MODE("dryrun.mode"),
/**
* @since 2.1.11 key: rest.client.impl
* value: full qualified name of the class that extends
* {@link RestClientFactory}.
*/
REST_CLIENT_FACTORY_IMPL("rest.client.impl"),
/**
* @since 2.1.13 key: password.decryptor.impl
* value: full qualified name of the class that implements
* {@link PasswordDecryptor}. This implementation will be used to
* decrypt password. When configuration manager found any key starts
* with {@link #ENCRYPTED_PASSWORD_KEY_PREFIX}
*/
PASSWORD_DECRYPTOR_IMPL("password.decryptor.impl"),
/**
* key: encrypted
* value: property with prefix 'encrypted'. When configuration
* manager found any key starts with 'encrypted' prefix, for example
* 'encripted.db.pwd', then it will store decrypted value without prefix,
* 'db.pwd' in this example. So you can reference decrypted value anywhere
* in the code with key without this prefix ('db.pwd' in this example).
*
* @since 2.1.13
*/
ENCRYPTED_PASSWORD_KEY_PREFIX("encrypted."),
/**
*
* To set default meta-data for all element. Meta-data provided with locator
* has higher preference than default values.
*
* key: element.default.metadata
* value: JSON map of meta data to be set as default for element.
*
* @since 2.1.13
*
*/
ELEMENT_GLOBAL_METADATA("element.default.metadata"),
/**
*
* Specify weather to attach default element listener or not.
*
* key: element.default.listener
* value: boolean true/false.
*
* @since 2.1.13
*
*/
ELEMENT_ATTACH_DEFAULT_LISTENER("element.default.listener"),
/**
*
* Set true to trust all certificates and ignore host name verification for
* web-services.
*
* key: https.accept.all.cert
* value: boolean true/false.
*
* @since 2.1.13
*
*/
HTTPS_ACCEPT_ALL_CERT("https.accept.all.cert"),
/**
*
* Set test case identifier meta-key which will be used to as file name of
* test case result json file.
*
* key: tc.identifier.key
* value: String test-case meta-key.
*
* @since 2.1.13
*
*/
TESTCASE_IDENTIFIER_KEY("tc.identifier.key"),
/**
*
* Set proxy server that needs to used by {@link UriProxySelector}
*
* key: proxy.server
* value: proxy server.
*
* @since 2.1.14
*
*/
PROXY_SERVER_KEY("proxy.server"),
/**
*
* Set proxy server port that needs to used by {@link UriProxySelector}.
* Default value is 80.
*
* key: proxy.port
* value: integer port of running proxy server.
*
* @since 2.1.14
*
*/
PROXY_PORT_KEY("proxy.port"),
/**
*
* Set one or more host url that needs to be proxied through given proxy server.
*
* key: host.to.proxy
* value: one or more host URL separated by ';'
*
* @since 2.1.14
*
*/
PROXY_HOSTS_KEY("host.to.proxy"),
/**
*
* Set list of meta-data rule to be applied on meta-data during dryrun.
*
* key: metadata.rules
* value: Json format List of {@link MetaDataRule}
*
* @since 2.1.15
*
*/
METADATA_RULES("metadata.rules"),
/**
*
* Set format as supported by {@link MessageFormat} that accepts one argument.
*
* key: metadata.formatter
* value: format to apply on meta-value
*
* @since 2.1.15
*
*/
METADATA_FORMTTOR_PREFIX("metadata.formatter");
public String key;
private ApplicationProperties(String key) {
this.key = key;
}
/**
* @param defaultVal
* optional
* @return
*/
public String getStringVal(String... defaultVal) {
return System.getProperty(key, getObjectVal(defaultVal).toString());
}
private Object getObjectVal(String... defaultVal) {
List> list = ConfigurationManager.getBundle().getList(key,
(null == defaultVal || defaultVal.length < 1 || null == defaultVal[0]) ? Collections.emptyList()
: Arrays.asList(defaultVal));
return list != null && !list.isEmpty() ? list.get(list.size() - 1) : "";
}
/**
* @param defaultVal
* optional
* @return
*/
public int getIntVal(int... defaultVal) {
try {
int val = Integer.parseInt(getStringVal());
return val;
} catch (Exception e) {
// just ignore
}
return (null != defaultVal) && (defaultVal.length > 0) ? defaultVal[0] : 0;
}
/**
* @param defaultVal
* optional
* @return
*/
public boolean getBoolenVal(boolean... defaultVal) {
try {
String sVal = getStringVal().trim();
boolean val = StringUtils.isNumeric(sVal) ? (Integer.parseInt(sVal) != 0) : Boolean.parseBoolean(sVal);
return val;
} catch (Exception e) {
// just ignore
}
return (null != defaultVal) && (defaultVal.length > 0) && defaultVal[0];
}
public Object getObject(Object... defaultVal) {
Object objToReturn = ConfigurationManager.getBundle().getObject(key);
return null != objToReturn ? objToReturn
: (null != defaultVal) && (defaultVal.length > 0) ? defaultVal[0] : null;
}
}