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

Commit fca8849

Browse files
committed
Extended some of the documentation files
- documentation/chapters/ad-hoc-find.md - documentation/chapters/annotation-action.md - documentation/chapters/annotation-attribute.md - documentation/chapters/annotation-cached.md - documentation/chapters/annotation-identify-using.md - documentation/chapters/annotation-mark.md - documentation/chapters/annotation-must.md - documentation/chapters/annotation-named.md - documentation/chapters/annotation-post-construct.md - documentation/chapters/annotation-wait.md - documentation/chapters/browser.md - documentation/chapters/by-producers.md - documentation/chapters/page-fragment.md - documentation/chapters/page.md
1 parent d621b5e commit fca8849

14 files changed

+238
-125
lines changed

documentation/chapters/ad-hoc-find.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
[Home](../README.md)
22

3-
# Ad-Hoc finding of Page Objects
4-
The `Browser`, `Page` and `PageFragment` classes provide entry points to the "ad-hoc finding" API.
5-
This allows you to apply a more script style approach to your tests.
3+
# Ad-Hoc Finding API
64

7-
**Doing so might be useful in the following circumstances:**
5+
It is not always the best solution to declare page fragments via public `@IdentifyUsing` method.
6+
Sometimes it is necessary to find a certain fragment programmatically:
87

9-
- You don't have an unique identification property for initializing a `PageFragment` field and need to take a programmatic
10-
approach
11-
- You want to rapidly prototype your tests scenarios
12-
- You want to execute some border cases upon elements and don't like to declare those as fields in your pages
13-
- Getting to a specific page fragment is not possible using `@IdentifyUsing`
8+
- Maybe the fragment is only used in very special cases and should therefore not be public...
9+
- Maybe you need a list of fragments fitting certain parameters which can not be expressed with CSS or XPath..
10+
- Or maybe are just prototyping your approach and don't want to implement page objects, yet...
11+
12+
For these cases the Ad-Hoc finding API was developed.
13+
This API can be accessed through a `Browser`, `Page` or a `PageFragment`.
14+
Depending on where the API is accessed the search context for fragments might differ:
15+
16+
- `Browser`: The whole HTML page is searched for the fragment.
17+
- `Page`: The whole HTML page is searched for the fragment.
18+
- `PageFragment`: The area between the page fragment's open and close tags is searched for the fragment.
19+
20+
There are several ways to start finding fragments, here are a few examples:
1421

15-
## Examples
1622
```java
17-
// find an element by its ID 'fooId' as a GenericElement
23+
// find an element by it's ID 'fooId' as a generic element
1824
GenericElement element = getBrowser()
1925
.find("#fooId");
2026

21-
// find many elements by their shared CSS class 'foo' as a stream of GenericElement
27+
// find many elements by their shared CSS class 'foo' as a stream of generic elements
2228
Stream<GenericElement> elements = getBrowser()
2329
.findMany(".foo");
2430

25-
// find a TextField by it's ID - Identification first
31+
// find an element by it's ID 'textField' as a text field (identifier first)
2632
TextField textField = getBrowser()
2733
.findBy(id("textField"))
2834
.as(TextField.class);
2935

30-
// find a TextField by it's ID - class first
36+
// find an element by it's ID 'textField' as a text field (class first)
3137
TextField textField = getBrowser()
3238
.find(TextField.class)
3339
.by(id("textField"));
3440

35-
// find all all elements with the CSS class 'foo' within an element with ID 'group' as TextFields
41+
// find all all elements with the CSS class 'foo'
42+
// within an element with ID 'group' as a stream of text fields
3643
Stream<TextField> textFields = getBrowser()
3744
.find("#group")
3845
.findBy(css(".foo"))
@@ -41,6 +48,7 @@ Stream<TextField> textFields = getBrowser()
4148

4249
# Linked Documentation
4350

44-
- [Conditions](conditions.md)
45-
- [ByProducers](by-producers.md)
51+
- [Page Fragments](page-fragment.md)
4652
- [Generic Elements](generic-element.md)
53+
- [ByProducers](by-producers.md)
54+
- [Conditions](conditions.md)

documentation/chapters/annotation-action.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# @Action
44
This annotation can be added to methods of `Page` or `PageFragment` subclasses in order to mark these methods as actions.
5-
Actions can be configured to behave in certain ways:
5+
Currently the only effect of this annotation the option to delay the execution of annotated methods by setting the
6+
property `actions.deceleration` to a certain amount of milliseconds.
67

7-
- The execution of actions can be delayed by setting the property `actions.deceleration` to a certain amount of milliseconds.
8-
9-
## Example
8+
> The effects of this annotation will grow in future versions of WebTester
109
10+
**Example of action method in page:**
1111
```java
1212
public interface FooPage extends Page {
1313

@@ -18,3 +18,20 @@ public interface FooPage extends Page {
1818

1919
}
2020
```
21+
22+
**Example of action method in page fragment:**
23+
```java
24+
public interface BarFragment extends PageFragment {
25+
26+
@Action
27+
default void doSomething() {
28+
...
29+
}
30+
31+
}
32+
```
33+
34+
# Linked Documentation
35+
36+
- [Pages](page.md)
37+
- [Page Fragments](page-fragment.md)

documentation/chapters/annotation-attribute.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,61 @@
44
This annotation can be used within a `PageFragment` subclass in order to retrieve attributes of the underlying element.
55
Attribute values (which are returned as Strings from the `WebElement`) will be parsed to the method's return type.
66

7+
**Supported Types:**
8+
9+
- String
10+
- Boolean
11+
- Long
12+
- Integer
13+
- Float
14+
- Double
15+
- Optional&lt;String&gt;
16+
- Optional&lt;Boolean&gt;
17+
- Optional&lt;Long&gt;
18+
- Optional&lt;Integer&gt;
19+
- Optional&lt;Float&gt;
20+
- Optional&lt;Double&gt;
21+
722
**Constraints:**
823

9-
- Annotated method must return String, Boolean, Long, Integer, Float, Double or any of those as an Optional<>.
10-
- Annotated method must not have arguments.
24+
- Annotated method must not have arguments!
25+
- Annotated methods have to be part of a page fragment!
1126

12-
## Example
27+
> It is possible to declare annotated methods in any interface, as long as they are used from a page fragment.
1328
29+
**Example of different attribute methods:**
1430
```java
1531
public interface FooFragment extends PageFragment {
1632

33+
// returns the string value of the 'value' attribute
1734
@Attribute("value")
1835
String value();
1936

37+
// returns the long value of the 'number' attribute
2038
@Attribute("number")
2139
Long number();
2240

41+
// returns the optional string value of the 'optional' attribute
2342
@Attribute("optional")
2443
Optional<String> optional();
2544

26-
...
45+
}
46+
```
47+
48+
**Example of trait interface with attribute method:**
49+
```java
50+
public interface HasValue {
2751

52+
@Attribute("value")
53+
String value();
54+
55+
}
56+
57+
public interface BarFragment extends PageFragment, HasValue {
58+
// will have access to working 'value()' method
2859
}
2960
```
61+
62+
# Linked Documentation
63+
64+
- [Page Fragments](page-fragment.md)

documentation/chapters/annotation-cached.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
[Home](../README.md)
22

33
# @Cached
4-
This annotation can be added to `PageFragment` returning methods of `Page` or `PageFragment` subclasses.
5-
It will override the configured default caching behavior of the returned page fragment.
4+
This annotation can be added to `@IdentifyUsing` annotated methods of `Page` or `PageFragment` subclasses.
5+
It will *override* the configured default caching behavior (property: `caches.enabled`) of the returned page fragment.
66

7-
> Caching will remember resolved `WebElement` instances for up to 5 seconds.
7+
> If caching is enabled, resolved `WebElement` instances will be remembered for up to `5` seconds.
8+
This mechanism is intended to reduce lookup time when executing multiple operations on the same web element in a short
9+
period of time where it is unlikely for the element to change. Please note, that enabling caching in AJAX heavy
10+
applications might make your tests unstable and increase the occurrence of `StaleElementReferenceException`.
811

9-
**Constraints:**
12+
**Cacheable Return Types:**
1013

11-
- Annotated methods must be identification methods (@IdentifyUsing).
12-
- Annotated methods must not return collection of page fragments.
13-
14-
## Example for Page
14+
- Single `PageFragment` instances
15+
- Lists, Sets and Streams of `PageFragment` instances
1516

17+
**Example for page:**
1618
```java
1719
public interface FooPage extends Page {
1820

@@ -29,8 +31,7 @@ public interface FooPage extends Page {
2931
}
3032
```
3133

32-
## Example for Page Fragment
33-
34+
**Example for page fragment:**
3435
```java
3536
public interface FooWidget extends PageFragment {
3637

@@ -46,3 +47,8 @@ public interface FooWidget extends PageFragment {
4647

4748
}
4849
```
50+
51+
# Linked Documentation
52+
53+
- [Pages](page.md)
54+
- [Page Fragments](page-fragment.md)

documentation/chapters/annotation-identify-using.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
# @IdentifyUsing
44
This annotation is used to tell the framework how the fragment(s) should be resolved when a page fragment returning method
55
is invoked.
6-
The annotation provides all necessary information to identify the corresponding element(s) in the DOM of the displayed page.
6+
The annotation provides all necessary information to identify the corresponding element(s) in the DOM of the displayed page:
77

8-
**Properties:**
8+
- `how`: Which `ByProducer` to use. I.e. `CssSelector`, `Id`, `XPath` etc. Defaults to `CssSelector`.
9+
- `value`: The value to be used by the mechanism.
910

10-
- `value` - A String containing identification data for the method to use the format depends on the used `ByProducer`
11-
defined with the `how` property.
12-
- `how` - The by producer being used to identify the object in the DOM. This is a class reference to any `ByProducer`
13-
implementing class.
11+
Methods annotated with `@IdentifyUsing` must not have arguments and can only return:
1412

15-
**Constraints:**
16-
17-
- Annotated method must return either `PageFragment`, `List<PageFragment>`, `Set<PageFragment>` or `Stream<PageFragment>`
18-
(subclasses of `PageFragment` are possible).
19-
20-
## Example on Page
13+
- Subclass of `PageFragment`
14+
- `List` of subclass of `PageFragment`
15+
- `Set` of subclass of `PageFragment`
16+
- `Stream` of subclass of `PageFragment`
2117

18+
**Example for page:**
2219
```java
2320
public interface FooPage extends Page {
2421

@@ -37,8 +34,7 @@ public interface FooPage extends Page {
3734
}
3835
```
3936

40-
## Example as Part of Page Fragment
41-
37+
**Example for page fragment:**
4238
```java
4339
public interface SearchWidget extends PageFragment {
4440

@@ -50,3 +46,8 @@ public interface SearchWidget extends PageFragment {
5046

5147
}
5248
```
49+
50+
# Linked Documentation
51+
52+
- [Pages](page.md)
53+
- [Page Fragments](page-fragment.md)
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
[Home](../README.md)
22

33
# @Mark
4-
This annotation can be added to methods of `PageFragment` subclasses in order to mark the page fragment in case the method
5-
is invoked.
6-
7-
The marking feature can be activated / deactivated by setting the `markings.enabled` property.
4+
This annotation can be added to methods of `PageFragment` subclasses in order to mark the fragment in case the method
5+
is invoked. The 'marking' is done by setting different style attributes for the underlying element.
86

97
The following marking types are available:
108

119
- USED - the state of the fragment was changed
1210
- READ - the state of the fragment was read
1311

12+
The marking feature can be activated / deactivated by setting the `markings.enabled` property.
1413
The color of each of these types can be configured by changing any of the following properties:
1514

1615
- `markings.used.background`
1716
- `markings.used.outline`
1817
- `markings.read.background`
1918
- `markings.read.outline`
2019

21-
Colors are specified as HEX RGB color codes, i.e. `#ffaa99`.
22-
23-
## Example
20+
> Colors are specified as HEX RGB color codes, i.e. `#ffaa99`.
2421
22+
**Example:**
2523
```java
2624
public interface FooFragment extends PageFragment {
2725

26+
// calling this method will mark the FooFragment as used
2827
@Mark(As.USED)
2928
default void doSomething() {
3029
...
3130
}
3231

3332
}
3433
```
34+
35+
# Linked Documentation
36+
37+
- [Page Fragments](page-fragment.md)

0 commit comments

Comments
 (0)