|
| 1 | +[Home](../README.md) |
| 2 | + |
| 3 | +# Configuration |
| 4 | + |
| 5 | +The behavior of WebTester can be configured on a browser by browser basis |
| 6 | +by providing a `Configuration` instance while creating the `Browser`. |
| 7 | + |
| 8 | +A `Configuration` instance can be created by using a `ConfigurationBuilder` implementation. |
| 9 | +That instance can then be used to customize the browser's configuration using a `BrowserBuilder`. |
| 10 | + |
| 11 | +## BaseConfigurationBuilder |
| 12 | +The `BaseConfigurationBuilder` will use a `BaseConfiguration` instance as a starting point. |
| 13 | +It takes `ConfigurationAdapter` and `ConfigurationExporter` instances as options before the `build()` operation. |
| 14 | + |
| 15 | +## ConfigurationAdapter |
| 16 | +A `ConfigurationAdapter` is used to change properties of an existing `Configuration`. |
| 17 | +This is done using a callback method `adapt(Configuration c)`. |
| 18 | + |
| 19 | +The following adapters are provided by the `webtester-core` module: |
| 20 | + |
| 21 | +- `DefaultFileConfigurationAdapter` |
| 22 | +- `GlobalFileConfigurationAdapter` |
| 23 | +- `LocalFileConfigurationAdapter` |
| 24 | +- `TestItHomeFileConfigurationAdapter` |
| 25 | + |
| 26 | +**DefaultFileConfigurationAdapter** |
| 27 | +This adapter looks up a properties file called `testit-webtester-default.properties` on the classpath's root level |
| 28 | +and loads each contained key / value pair into the provided `Configuration` instance. |
| 29 | + |
| 30 | +**GlobalFileConfigurationAdapter** |
| 31 | +This adapter looks up a properties file called `testit-webtester-global.properties` on the classpath's root level |
| 32 | +and loads each contained key / value pair into the provided `Configuration` instance. |
| 33 | + |
| 34 | +**LocalFileConfigurationAdapter** |
| 35 | +This adapter looks up a properties file called `testit-webtester.properties` on the classpath's root level |
| 36 | +and loads each contained key / value pair into the provided `Configuration` instance. |
| 37 | + |
| 38 | +**TestItHomeFileConfigurationAdapter** |
| 39 | +This adapter looks up a properties file called `testit-webtester.properties` inside the `$TESTIT_HOME/config` folder |
| 40 | +and loads each contained key / value pair into the provided `Configuration` instance. |
| 41 | + |
| 42 | +## ConfigurationExporter |
| 43 | +A `ConfigurationExporter` is used to "export" a `Configuration` to another System. |
| 44 | +This is done by using a callback method `export(String key, Object value)` for each key / value pair of the `Configuration`. |
| 45 | + |
| 46 | +The following exporters are provided by the `webtester-core` module: |
| 47 | + |
| 48 | +- SystemPropertyConfigurationExporter |
| 49 | + |
| 50 | +**SystemPropertyConfigurationExporter** |
| 51 | +This exporter can be used to export each key / value pair as system properties in order to make them accessible using `System#getProperty(String key)`. |
| 52 | + |
| 53 | +## Default Configuration |
| 54 | +Since not everyone needs to customize the configuration in the context of his or her project |
| 55 | +a 'DefaultConfigurationBuilder' is provided which uses the following adapters (in order) |
| 56 | +and no exporters to build a Configuration : |
| 57 | + |
| 58 | +- `DefaultFileConfigurationAdapter` |
| 59 | +- `GlobalFileConfigurationAdapter` |
| 60 | +- `LocalFileConfigurationAdapter` |
| 61 | + |
| 62 | +**Note:** This builder is also used in case a `Browser` is [build](browser.md) without providing a custom `Configuration` instance. |
| 63 | + |
| 64 | +## Example |
| 65 | +```java |
| 66 | +ConfigurationAdapter adapter1 = ...; |
| 67 | +ConfigurationAdapter adapter2 = ...; |
| 68 | +ConfigurationExporter exporter = ...; |
| 69 | + |
| 70 | +// this will adapt a base configuration first with 'adapter1' and then with 'adapter2' |
| 71 | +// after that the final configuration will be exported using the 'exporter' |
| 72 | +Configuration config = new BaseConfigurationBuilder() |
| 73 | + .withAdapters(adapter1, adapter2) |
| 74 | + .withExporter(exporter) |
| 75 | + .build(); |
| 76 | +``` |
| 77 | + |
| 78 | +# Default Properties |
| 79 | +The following shows all default properties loaded by the `DefaultFileConfigurationAdapter`. |
| 80 | +The values are the same as the fallback values of the `BaseConfiguration` implementation. |
| 81 | + |
| 82 | +```properties |
| 83 | +# URL of the default entry point for the application under test. |
| 84 | +# TYPE: String [Resource URL] |
| 85 | +# browser.defaultEntryPoint = |
| 86 | + |
| 87 | +# Weather or not open browsers should be closed automatically when the JVM is shut down. |
| 88 | +# TYPE: boolean [true, false] |
| 89 | +browser.autoClose = false |
| 90 | + |
| 91 | +# Format pattern for timestamps to be used when printing timestamps. |
| 92 | +# TYPE: String [Java SimpleDateFormat style as described here: https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html] |
| 93 | +timestamp.pattern = MMM dd HH:mm:ss yyyy |
| 94 | + |
| 95 | +# Folder in which to save screenshots if not otherwise specified. |
| 96 | +# TYPE: String [absolute or relative path to be initialized as a java.io.File instance] |
| 97 | +folders.screenshot = screenshots |
| 98 | + |
| 99 | +# Folder in which to save source code of pages if not otherwise specified. |
| 100 | +# TYPE: String [absolute or relative path to be initialized as a java.io.File instance] |
| 101 | +folders.sourcecode = sourcecode |
| 102 | + |
| 103 | +# Folder in which to save log files if not otherwise specified. |
| 104 | +# TYPE: String [absolute or relative path to be initialized as a java.io.File instance] |
| 105 | +folders.log = logs |
| 106 | + |
| 107 | +# Weather or not color highlighting of used elements should be active or not. |
| 108 | +# TYPE: boolean [true, false] |
| 109 | +markings.activated = false |
| 110 | + |
| 111 | +# Color to use for the background of used elements if color highlighting is active. |
| 112 | +# TYPE: String [HEX RGB code starting with'#'] |
| 113 | +markings.color.used.background = #90ee90 |
| 114 | + |
| 115 | +# Color to use for the outline of used elements if color highlighting is active. |
| 116 | +# TYPE: String [HEX RGB code starting with'#'] |
| 117 | +markings.color.used.outline = #008000 |
| 118 | + |
| 119 | +# Default timeout for wait operations. |
| 120 | +# TYPE: int [seconds] |
| 121 | +wait.timeout = 2 |
| 122 | + |
| 123 | +# Default interval in which to check a condition for wait operations. |
| 124 | +# TYPE: int [miliseconds] |
| 125 | +wait.interval = 100 |
| 126 | + |
| 127 | +# Whether or not page object's wrapped web elements will be cached or resolved for each action. Has a great impact on stability when testing AJAX heavy application at the cost of performance. |
| 128 | +# TYPE: boolean [true, false] |
| 129 | +pageobjects.caching = true |
| 130 | +``` |
| 131 | + |
| 132 | +# Linked Documentation |
| 133 | + |
| 134 | +- [Browser](browser.md) |
0 commit comments