Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 4165a6f

Browse files
committed
Add documentation as part of the code base. This is replacing the externally hosted Confluence system.
1 parent 50b5161 commit 4165a6f

23 files changed

+1410
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ It is the product of years of consulting experience in various projects and aims
1717
- If you must, Selenium is always just a method call away.
1818

1919
### Get in touch
20-
Until our infrastructure is up and running you can send any questions to our technical lead: stefan.ludwig@novatec-gmbh.de
20+
You can reach contact us using [Gitter](https://gitter.im/testIT-WebTester/webtester-core) or create an [issue](https://github.com/testIT-WebTester/webtester-core/issues).
2121

2222
### Documentation
23-
The [user documentation](https://documentation.novatec-gmbh.de/display/TESTIT/WebTester) provides in-depth documentation on all the features.
23+
The [user documentation](documentation/README.md) is part of the repository and provides in-depth documentation on all the features.
2424
If you have further questions please get in touch with us.
2525

2626
### Contribute / Issues
27-
The contribution and bug processes are not defined, yet.
28-
For the mean time feel free to contact us with any problems or contributions you might have.
27+
The contribution process is not yet defined. But if you experience any issues please use GitHub's [issue](https://github.com/testIT-WebTester/webtester-core/issues) system to tell us about it!
2928

3029
### Licensing
3130
testIT WebTester is licensed under [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt).

documentation/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
![testIT WebTester](images/logo-650x157.png)
2+
3+
## Welcome to the testIT WebTester documentation!
4+
5+
- [Browser](chapters/browser.md)
6+
- [Configuration](chapters/configuration.md)
7+
- [Event System](chapters/event-system.md)
8+
- [Page Objects](chapters/page-object.md)
9+
- [Anatomy of Pages](chapters/page-object-anatomy.md)
10+
- [Functional Page Objects](chapters/page-object-functional.md)
11+
- [Generic Element](chapters/page-object-generic.md)
12+
- [Page Object Factory](chapters/page-object-factory.md)
13+
- Utility Classes
14+
- [Conditions](chapters/conditions.md)
15+
- [Identifications](chapters/identifications.md)
16+
- [Mouse](chapters/mouse.md)
17+
- [Waits](chapters/waits.md)
18+
- Support Modules
19+
- Assertions
20+
- [AssertJ](chapters/support-assertj.md)
21+
- [Hamcrest](chapters/support-hamcrest.md)
22+
- Browser
23+
- [Chrome](chapters/support-chrome.md)
24+
- [Firefox](chapters/support-firefox.md)
25+
- [Internet Explorer](chapters/support-ie.md)
26+
- Testing
27+
- [JUnit](chapters/support-junit.md)
28+
- Integration
29+
- [Spring 4](chapters/support-spring4.md)
30+
- Advanced Topics
31+
- [Ad-Hoc finding of Page Objects](chapters/ad-hoc-find.md)
32+
33+
34+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[Home](../README.md)
2+
3+
# Ad-Hoc finding of Page Objects
4+
The `Browser` and `PageObject` classes provide entry points to the "ad-hoc finding" API.
5+
This allows you to apply a more script style approach to your tests.
6+
7+
**Doing so might be useful in the following circumstances:**
8+
9+
- You don't have an unique identification property for initializing a `PageObject` field and need to take a programmatic approach
10+
- You want to rapidly prototype your tests scenarios
11+
- You want to execute some bordercases upon elements and don't like to declare those as fields in your page objects
12+
- Getting to a specific page object is not possible by using `@IdentifyUsing`, `@FindBy` or `@FindBys`
13+
14+
## Examples
15+
```java
16+
// find an element by its ID 'fooId' as a GenericElement
17+
GenericElement element = getBrowser()
18+
.find("#fooId");
19+
20+
// find many elements by their shared CSS class 'foo' as a list of GenericElement
21+
List<GenericElement> elements = getBrowser()
22+
.findMany(".foo");
23+
24+
// find a TextField by it's ID - Identification first
25+
TextField textField = getBrowser()
26+
.findBy(id("textField"))
27+
.as(TextField.class);
28+
29+
// find a TextField by it's ID - class first
30+
TextField textField = getBrowser()
31+
.find(TextField.class)
32+
.by(id("textField"));
33+
34+
// find all all elements with the CSS class 'foo' within an element with ID 'group' as TextFields
35+
List<TextField> textFields = getBrowser()
36+
.find("#group")
37+
.findBy(css(".foo"))
38+
.asMany(TextField.class);
39+
```
40+
41+
# Linked Documentation
42+
43+
- [Conditions](conditions.md)
44+
- [Identifications](identifications.md)
45+
- [Generic Elements](page-object-generic.md)

documentation/chapters/browser.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[Home](../README.md)
2+
3+
# Browser
4+
5+
## Interfaces
6+
7+
### Browser
8+
A `Browser` provides a streamlined and context centric API for the interaction with a web browser.
9+
10+
### BrowserBuilder
11+
A `BrowserBuilder` provides the framework for initializing `Browser` instances and setting custom service implementations.
12+
Customizable services are:
13+
14+
- [`Configuration`](configuration.md)
15+
- [`PageObjectFactory`](page-object-factory.md)
16+
17+
### BrowserFactory
18+
A `BrowserFactory` creates an abstraction over the `Browser` initialisation based on project-global settings.
19+
They are intended to allow easy browser initialization and encapsulation of the underlying configuration / initialization
20+
processes.
21+
22+
**Provided default BrowserFactory implementations:**
23+
24+
- [`ChromeFactory`](support-chrome.md)
25+
- [`FirefoxFactory`](support-firefox.md)
26+
- [`InternetExplorerFactory`](support-ie.md)
27+
28+
Each of them comes in their own support module. The Firefox's factory implementation is trimmed for optimal performance.
29+
30+
### ProxyConfiguration
31+
In order to configure a proxy you can either configure it manually when initializing the `WebDriver` or
32+
you can implement a `ProxyConfiguration` and provide it to the `BrowserFactory` before creating a `Browser` instance.
33+
34+
```java
35+
ProxyConfiguration pc = createProxyConfiguration();
36+
Browser browser = new FirefoxFactory().withProxyConfiguration(pc).createBrowser();
37+
```
38+
39+
## The WebDriver Browser
40+
The `WebDriverBrowser` class implements `Browser` and is used to wrap a Selenium `WebDriver`.
41+
Instances can be created by using the `WebDriverBrowser's` factory methods:
42+
43+
1. `WebDriverBrowser.forWebDriver(webDriver).build();`
44+
2. `WebDriverBrowser.buildForWebDriver(webDriver);`
45+
46+
Both of these are equal. The first method can be used to customize same aspects of the browser before it is build.
47+
48+
## Examples
49+
**Initialization of a new WebDriverBrowser instance:**
50+
```java
51+
WebDriver webDriver = createWebDriver();
52+
Browser browser = WebDriverBrowser.buildForWebDriver(webDriver);
53+
Browser browser = WebDriverBrowser.forWebDriver(webDriver).build();
54+
Browser browser = new WebDriverBrowserBuilder(webDriver).build();
55+
```
56+
**Initialization of a new WebDriverBrowser instance with custom service implementations:**
57+
```java
58+
Configuration config = createConfiguration();
59+
PageObjectFactory factory = createFactory();
60+
61+
Browser browser = WebDriverBrowser.forWebDriver(webDriver)
62+
.withConfiguration(config)
63+
.withFactory(factory)
64+
.build();
65+
66+
Browser browser = new WebDriverBrowserBuilder(webDriver)
67+
.withConfiguration(config)
68+
.withFactory(factory)
69+
.build();
70+
```
71+
72+
# Linked Documentation
73+
74+
- [Configuration](configuration.md)
75+
- [Page Object Factory](page-object-factory.md)
76+
- [Chrome Support](support-chrome.md)
77+
- [Firefox Support](support-firefox.md)
78+
- [Internet Explorer Support](support-ie.md)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[Home](../README.md)
2+
3+
# The Conditions Utility Class
4+
The utility class `Conditions` provides several factory methods for creating GUAVA `Predicate` instances.
5+
These can be (re-)used in the following sub-systems:
6+
7+
- Filtering a [`PageObjectList`](page-object.md)
8+
- As a condition of `waitUntil(...)` operations from the [`Waits` API](waits.md)
9+
10+
```java
11+
browser.findMany(".textfield").filter(Conditions.is(Conditions.visible()));
12+
Waits.waitUntil(textField, Conditions.has(Conditions.text("foo")));
13+
```
14+
15+
Since all of these make use of GUAVA's `Predicate` interface it is easy to create your own conditions if need be.
16+
17+
## Syntax
18+
19+
Conditions are designed to be readable. They take a lot of inspiration from Hamecrest's `Matcher` API.
20+
It is generally recommended to use static imports when working with the `Conditions` class.
21+
22+
We provide two kinds of classes in the `info.novatec.testit.webtester.utils.conditions` package:
23+
24+
- Syntax operations like `Has`, `Is` and `Not` in order to make conditions more readable
25+
- Property conditions like `TextEquals`, `Visible`, `Writeable` etc. which are executing the real checks
26+
27+
## List of current Conditions
28+
29+
**Syntax:**
30+
31+
- `Either`
32+
- `Has`
33+
- `Is`
34+
- `Not`
35+
36+
**Checks:**
37+
38+
- `AttributeWithValue`
39+
- `Disabled`
40+
- `Editable`
41+
- `Enabled`
42+
- `FileName`
43+
- `Interactable`
44+
- `Invisible`
45+
- `Label`
46+
- `Present`
47+
- `ReadOnly`
48+
- `Selected`
49+
- `SelectedIndex`
50+
- `SelectedIndices`
51+
- `SelectedText`
52+
- `SelectedTexts`
53+
- `SelectedValue`
54+
- `SelectedValues`
55+
- `SourcePath`
56+
- `TextContains`
57+
- `TextEquals`
58+
- `Value`
59+
- `Visible`
60+
- `VisibleTextContains`
61+
- `VisibleTextEquals`
62+
63+
## Examples
64+
```java
65+
// ## Waits API ##
66+
Waits.waitUntil(textField, Conditions.has(Conditions.text("foo")));
67+
waitUntil(textField, has(text("foo")));
68+
69+
// ## Ad-Hoc PageObject creation API
70+
browser.findMany(".textfield").filter(is(visible));
71+
```
72+
73+
# Linked Documentation
74+
75+
- [Ad-Hoc Finding of Page Objects](ad-hoc-find.md)
76+
- [Waits API](waits.md)
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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

Comments
 (0)