info.novatec.testit.webtester.config.Configuration Maven / Gradle / Ivy
package info.novatec.testit.webtester.config;
import java.io.File;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import org.openqa.selenium.support.Color;
import info.novatec.testit.webtester.browser.factories.RemoteFactory;
import info.novatec.testit.webtester.config.exceptions.SetNullValuesException;
import info.novatec.testit.webtester.events.Event;
import info.novatec.testit.webtester.events.EventSystem;
import info.novatec.testit.webtester.pagefragments.annotations.Action;
import info.novatec.testit.webtester.waiting.Wait;
/**
* Classes implementing this interface allow access to a variety of configuration properties for the framework. These
* properties can be retrieved and changed at runtime.
*
* Instances should be constructed using a {@link ConfigurationBuilder builder}. Since they provide for a comfortable way to
* use specific {@link ConfigurationAdapter adapters} and {@link ConfigurationExporter exporters} to adapt (change
* configuration based on different sources) and export the configuration's properties and values.
*
* Besides a number of 'named' properties with their own setter- and getter-methods custom properties can be set and read as
* well.
*
* In order to allow the export of set properties (and changes to them) any number of {@link ConfigurationExporter exporters}
* can be defined.
*
* @see ConfigurationBuilder
* @see ConfigurationAdapter
* @see ConfigurationExporter
* @since 2.0
*/
public interface Configuration {
/**
* Returns the number of milliseconds actions should be decelerated. Actions are methods annotated with
* {@link Action @Action}.
*
* A value of 0
will be interpreted as "no deceleration".
*
* @return true if caching is enabled by default
* @see Action
* @since 2.0
*/
long getActionDeceleration();
/**
* Set the number of milliseconds actions should be decelerated. Actions are methods annotated with
* {@link Action @Action}.
*
* A value of 0
will be interpreted as "no deceleration".
*
* @param value the amount of deceleration in milliseconds
* @return the same instance for fluent API use
* @see Action
* @since 2.0
*/
Configuration setActionDeceleration(long value);
/**
* Returns whether or not the firing of events is enabled. Disabling this may improve performance significantly but at
* the cost of traceability.
*
* @return true id the firing of events is enabled
* @see Event
* @see EventSystem
* @since 2.0
*/
boolean isEventSystemEnabled();
/**
* Returns whether or not the firing of events is enabled. Disabling this may improve performance significantly but at
* the cost of traceability.
*
* @param active true if the firing of events should be enabled
* @return the same instance for fluent API use
* @see Event
* @see EventSystem
* @since 2.0
*/
Configuration setEventSystemEnabled(boolean active);
/**
* Returns the default entry point of the application under test if set.
*
* This can be used to navigate to a specific URL without having to specify it in code.
*
* @return the optional URL
* @since 2.0
*/
Optional getDefaultEntryPoint();
/**
* Sets the default entry point of the application under test.
*
* This can be used to navigate to a specific URL without having to specify it in code.
*
* @param entryPoint the entry point to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setDefaultEntryPoint(String entryPoint);
/**
* Returns the folder were screenshots files should be saved if no specific folder is provided.
*
* @return the folder
* @since 2.0
*/
File getScreenshotFolder();
/**
* Sets the folder were screenshots files should be saved if no specific folder is provided.
*
* @param folder the folder to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setScreenshotFolder(File folder);
/**
* Returns the folder were source code files should be saved if no specific folder is provided.
*
* @return the folder
* @since 2.0
*/
File getPageSourceFolder();
/**
* Sets the folder were source code files should be saved if no specific folder is provided.
*
* @param folder the folder to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setPageSourceFolder(File folder);
/**
* Returns the folder were logs files should be saved if no specific folder is provided.
*
* @return the folder
* @since 2.0
*/
File getLogFolder();
/**
* Sets the folder were logs files should be saved if no specific folder is provided.
*
* @param folder the folder to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setLogFolder(File folder);
/**
* Returns whether or not markings are activated. If activated most interactions with elements on a page will mark them
* as 'used' with the configured {@link #getMarkingsColorUsedBackground()} and {@link #getMarkingsColorUsedOutline()}
* colors.
*
* @return true if markings are active, otherwise false
* @since 2.0
*/
boolean isMarkingsEnabled();
/**
* Sets whether or not markings are activated. If activated most interactions with elements on a page will mark them as
* 'used' with the configured {@link #getMarkingsColorUsedBackground()} and {@link #getMarkingsColorUsedOutline()}
* colors.
*
* @param activated whether or not markings should be activated
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setMarkingsEnabled(boolean activated);
/**
* Returns the color to use for the background of elements marked as 'used' on a page.
*
* @return the color
* @since 2.0
*/
Color getMarkingsColorUsedBackground();
/**
* Sets the color to use for the background of elements marked as 'used' on a page.
*
* @param color the color to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setMarkingsColorUsedBackground(Color color);
/**
* Returns the color to use for the outline of elements marked as 'used' on a page.
*
* @return the color
* @since 2.0
*/
Color getMarkingsColorUsedOutline();
/**
* Sets the color to use for the outline of elements marked as 'used' on a page.
*
* @param color the color to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setMarkingsColorUsedOutline(Color color);
/**
* Returns the color to use for the background of elements marked as 'read' on a page.
*
* @return the color
* @since 2.0
*/
Color getMarkingsColorReadBackground();
/**
* Sets the color to use for the background of elements marked as 'read' on a page.
*
* @param color the color to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setMarkingsColorReadBackground(Color color);
/**
* Returns the color to use for the outline of elements marked as 'read' on a page.
*
* @return the color
* @since 2.0
*/
Color getMarkingsColorReadOutline();
/**
* Sets the color to use for the outline of elements marked as 'read' on a page.
*
* @param color the color to set
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setMarkingsColorReadOutline(Color color);
/**
* Returns the default maximum number of seconds to wait when executing wait operations on page objects using the
* {@link Wait} API.
*
* @return the number of seconds
* @since 2.0
*/
int getWaitTimeout();
/**
* Sets the default maximum number of seconds to wait when executing wait operations on page objects using the
* {@link Wait} API.
*
* @param waitTimeout timeout in seconds
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setWaitTimeout(int waitTimeout);
/**
* Returns the default number of milliseconds to wait between checks when executing wait operations on page objects
* using the {@link Wait} API.
*
* @return the number of milliseconds
* @since 2.0
*/
long getWaitInterval();
/**
* Sets the default number of milliseconds to wait between checks when executing wait operations on page objects
* using the {@link Wait} API.
*
* @param waitInterval the interval in milliseconds
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration setWaitInterval(long waitInterval);
/**
* Returns the name of the browser to use when working with a remote Selenium Grid.
*
* @return the name of the browser (e.g. "firefox")
* @see RemoteFactory
* @since 2.1
*/
String getRemoteBrowserName();
/**
* Sets the name of the browser to use when working with a remote Selenium Grid.
*
* @param name the browser name - must be lower case!
* @return the same configuration for fluent API
* @since 2.1
*/
Configuration setRemoteBrowserName(String name);
/**
* Returns the version of the browser to use when working with a remote Selenium Grid.
*
* @return the version of the browser (e.g. "46.0.1")
* @see RemoteFactory
* @since 2.1
*/
String getRemoteBrowserVersion();
/**
* Sets the version of the browser to use when working with a remote Selenium Grid.
*
* @param version the browser version
* @return the same configuration for fluent API
* @since 2.1
*/
Configuration setRemoteBrowserVersion(String version);
/**
* Returns whether or not the Marionette driver should be used when working with a remote Firefox via Selenium Grid.
*
* @return true if Marionette driver should be used
* @see RemoteFactory
* @since 2.1
*/
boolean getRemoteFirefoxMarionette();
/**
* Sets whether or not the Marionette driver should be used when working with a remote Firefox via Selenium Grid.
*
* @param marionette true to use Marionette driver
* @return the same configuration for fluent API
* @since 2.1
*/
Configuration setRemoteFirefoxMarionette(boolean marionette);
/**
* Returns the host or IP address to use when working with a remote Selenium Grid.
*
* @return the host (e.g. "localhost")
* @see RemoteFactory
* @since 2.1
*/
String getRemoteHost();
/**
* Sets the host or IP address to use when working with a remote Selenium Grid.
*
* @param host the host (e.g. "localhost")
* @return the same configuration for fluent API
* @since 2.1
*/
Configuration setRemoteHost(String host);
/**
* Returns the port to use when working with a remote Selenium Grid.
*
* @return the port (e.g. "4444")
* @see RemoteFactory
* @since 2.1
*/
int getRemotePort();
/**
* Sets the port to use when working with a remote Selenium Grid.
*
* @param port the port (e.g. "4444")
* @return the same configuration for fluent API
* @since 2.1
*/
Configuration setRemotePort(int port);
/**
* Removes the property with the given key from this {@link Configuration configuration}.
*
* @param key the key of the property to removed
* @return the same configuration for fluent API
* @since 2.0
*/
Configuration removeProperty(String key);
/**
* Sets the given property key to the given value. Also calls all {@link ConfigurationExporter configuration exporters}
* of this {@link Configuration configuration} to inform them about the change to the property.
*
* Note: NULL values are not allowed - use {@link #removeProperty(String)} for removing properties.
*
* Valid value types:
*
* - String
* - Integer
* - Long
* - Float
* - Double
* - Boolean
*
*
* @param key the key
* @param value the value
* @return the same configuration instance for fluent API
* @throws SetNullValuesException in case a NULL value is given
* @since 2.0
*/
Configuration setProperty(String key, Object value);
/**
* Returns a property value as a string.
*
* @param key the property key to use
* @return the property for the given key as a String
* @since 2.0
*/
Optional getStringProperty(String key);
/**
* Returns a property value as a string. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as a String
* @since 2.0
*/
String getStringProperty(String key, String defaultValue);
/**
* Returns a property value as an integer.
*
* @param key the property key to use
* @return the property for the given key as an integer
* @since 2.0
*/
Optional getIntegerProperty(String key);
/**
* Returns a property value as an integer. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as an integer
* @since 2.0
*/
Integer getIntegerProperty(String key, Integer defaultValue);
/**
* Returns a property value as a long.
*
* @param key the property key to use
* @return the property for the given key as a long
* @since 2.0
*/
Optional getLongProperty(String key);
/**
* Returns a property value as a long. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as a long
* @since 2.0
*/
Long getLongProperty(String key, Long defaultValue);
/**
* Returns a property value as a float.
*
* @param key the property key to use
* @return the property for the given key as a float
* @since 2.0
*/
Optional getFloatProperty(String key);
/**
* Returns a property value as a float. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as a float
* @since 2.0
*/
Float getFloatProperty(String key, Float defaultValue);
/**
* Returns a property value as a double.
*
* @param key the property key to use
* @return the property for the given key as a double
* @since 2.0
*/
Optional getDoubleProperty(String key);
/**
* Returns a property value as a double. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as a double
* @since 2.0
*/
Double getDoubleProperty(String key, Double defaultValue);
/**
* Returns a property value as a boolean.
*
* @param key the property key to use
* @return the property for the given key as a boolean
* @since 2.0
*/
Optional getBooleanProperty(String key);
/**
* Returns a property value as a boolean. If the property value is null
the given default is returned.
*
* @param key the property key to use
* @param defaultValue the default value to return if no property for the
* given key was found
* @return the property for the given key as a boolean
* @since 2.0
*/
Boolean getBooleanProperty(String key, Boolean defaultValue);
/**
* Returns a property value as an object.
*
* @param key the property key to use
* @return the property for the given key as an object
* @since 2.0
*/
Optional