public final class Configuration
extends java.lang.Object
Global object for configuration data storage.
Configuration data is supposed to be stored in the properties file.
By default the configuration is taken from the config.properties file
which should be located either in the root project folder or in the resource
root. If there's a need to read configuration from different location it is
recommended to call setDefaultConfigFile(String)
method
before any other calls to other configuration methods.
Sample use:
Configuration.load(); // Loads configuration options String value = Configuration.get("config_property"); // Gets config_property property valueFor more information read methods description.
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
get(ConfigurationOption option)
Gets value for the predefined configuration option which is defined as
ConfigurationOption enumeration. |
static java.lang.String |
get(java.lang.String option)
Gets the value of the configuration option specified by the parameter.
|
static java.lang.String |
getDefaultConfigFile()
Returns the default location of the configuration file to read data from.
|
static void |
load()
Overloaded version of the
load(String) method where the default
configuration location is used. |
static void |
load(java.lang.String location)
Loads properties from the file specified by the location.
|
static java.lang.String |
pagesPackage()
Retrieves the value of pages package.
|
static Platform |
platform()
Retrieves configuration option value for currently defined platform.
|
static void |
print()
Prints all available configuration options with their values into standard output stream.
|
static void |
reset()
Restores the internal data to initial state when the list of properties
is null and the default configuration path is config.properties.
|
static void |
setDefaultConfigFile(java.lang.String defaultConfigFileValue)
Sets the default location for the configuration file.
|
static int |
timeout()
Returns timeout value based on
ConfigurationOption.TIMEOUT parameter. |
public static void reset()
public static void load(java.lang.String location) throws java.io.IOException
Loads properties from the file specified by the location. The location may refer either to file path (either absolute or relative) or to resource path in case the configuration path is provided as the resource.
NOTE: if both external file and resource are available by the path specified by location parameter, the external file is read.
location
- path to the properties file which can be either external file or internal resource.java.io.IOException
- invoked in case of any problems with reading file.public static void load() throws java.io.IOException
Overloaded version of the load(String)
method where the default
configuration location is used. Without any additional settings that would be config.properties
file. If any other default location is needed, it is recommended to call
setDefaultConfigFile(String)
method first.
java.io.IOException
- invoked in case of any problems with reading file.setDefaultConfigFile(String)
,
getDefaultConfigFile()
,
load(String)
public static java.lang.String getDefaultConfigFile()
public static void setDefaultConfigFile(java.lang.String defaultConfigFileValue)
Sets the default location for the configuration file. If custom configuration location is used it is recommended to invoke this method first.
defaultConfigFileValue
- New default configuration file/ resource location.public static java.lang.String get(java.lang.String option)
Gets the value of the configuration option specified by the parameter.
If configuration hasn't been loaded yet the load()
method
will be forcibly invoked. It means that by default the Configuration
object
invokes configuration load from the default location.
option
- the configuration option name to get value for. Name is represented as the string.public static java.lang.String get(ConfigurationOption option)
ConfigurationOption
enumeration. Such version is needed for
frequently used configuration options which have dedicated constant.option
- the configuration option code to get value for.ConfigurationOption
public static void print()
public static int timeout()
ConfigurationOption.TIMEOUT
parameter.
If such option is unavailable the default value of 60 seconds is returned.
Mainly this method can be used together with WebDriver waiting predicates
as the default explicit timeout.public static Platform platform()
Platform
public static java.lang.String pagesPackage()