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

Commit 2dfb359

Browse files
committed
Removed @cached annotation and the complete caching feature
Caching added an unnecessary overhead of complexity to the framework which in the end didn't help as much as expected. The number of milliseconds saved by the feature were minimal and in some cases the caching itself became an overhead. Always resolving the WebElement anew is the way to go.
1 parent 446f268 commit 2dfb359

20 files changed

+17
-427
lines changed

documentation/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- Annotations
1212
- [@Action](chapters/annotation-action.md)
1313
- [@Attribute](chapters/annotation-attribute.md)
14-
- [@Cached](chapters/annotation-cached.md)
1514
- [@IdentifyUsing](chapters/annotation-identify-using.md)
1615
- [@Mark](chapters/annotation-mark.md)
1716
- [@Named](chapters/annotation-named.md)

documentation/chapters/annotation-cached.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

documentation/chapters/configuration.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ The following shows all default properties loaded by the `DefaultFileConfigurati
8080
The values are the same as the fallback values of the `BaseConfiguration` implementation.
8181

8282
```properties
83-
# Weather or not caches (i.e. of web elements) should be enabled by default.
84-
# TYPE: boolean [true, false]
85-
caches.enabled = false
86-
8783
# Weather or not the events should be fired.
8884
# TYPE: boolean [true, false]
8985
events.enabled = true

documentation/chapters/page-fragment.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ These annotations can be used within a `PageFragment`.
9090

9191
- [@Action](annotation-action.md)
9292
- [@Attribute](annotation-attribute.md)
93-
- [@Cached](annotation-cached.md)
9493
- [@IdentifyUsing](annotation-identify-using.md)
9594
- [@Mark](annotation-mark.md)
9695
- [@Named](annotation-named.md)

documentation/chapters/page.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public interface CollectionPage extends Page {
9393
These annotations can be used within a `Page`.
9494

9595
- [@Action](annotation-action.md)
96-
- [@Cached](annotation-cached.md)
9796
- [@IdentifyUsing](annotation-identify-using.md)
9897
- [@Named](annotation-named.md)
9998
- [@PostConstruct](annotation-post-construct.md)

webtester-core/src/main/java/info/novatec/testit/webtester/config/BaseConfiguration.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ public class BaseConfiguration implements Configuration {
5252

5353
/* named properties */
5454

55-
@Override
56-
public boolean isCachingEnabled() {
57-
return getBooleanProperty(key(NamedProperties.CACHES), Boolean.FALSE);
58-
}
59-
60-
@Override
61-
public Configuration setCaching(boolean active) {
62-
return setProperty(key(NamedProperties.CACHES), active);
63-
}
64-
6555
@Override
6656
public long getActionDeceleration() {
6757
return getLongProperty(key(NamedProperties.ACTIONS_DECELERATION), 0L);

webtester-core/src/main/java/info/novatec/testit/webtester/config/Configuration.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import info.novatec.testit.webtester.events.Event;
1212
import info.novatec.testit.webtester.events.EventSystem;
1313
import info.novatec.testit.webtester.pagefragments.annotations.Action;
14-
import info.novatec.testit.webtester.pagefragments.annotations.Cached;
1514
import info.novatec.testit.webtester.waiting.Wait;
1615

1716

@@ -39,25 +38,6 @@
3938
*/
4039
public interface Configuration {
4140

42-
/**
43-
* Returns whether or not caching mechanisms are globally enabled.
44-
*
45-
* @return true if caching is enabled by default
46-
* @see Cached
47-
* @since 2.0
48-
*/
49-
boolean isCachingEnabled();
50-
51-
/**
52-
* Set whether or not caching mechanisms are globally enabled.
53-
*
54-
* @param active true if caching should be enabled by default
55-
* @return the same instance for fluent API use
56-
* @see Cached
57-
* @since 2.0
58-
*/
59-
Configuration setCaching(boolean active);
60-
6141
/**
6242
* Returns the number of milliseconds actions should be decelerated.
6343
* Actions are methods annotated with {@link Action @Action}.

webtester-core/src/main/java/info/novatec/testit/webtester/internal/ActionTemplate.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
import java.util.function.Consumer;
66
import java.util.function.Function;
77

8-
import org.openqa.selenium.StaleElementReferenceException;
9-
108
import info.novatec.testit.webtester.browser.Browser;
119
import info.novatec.testit.webtester.events.Event;
1210
import info.novatec.testit.webtester.events.EventSystem;
13-
import info.novatec.testit.webtester.pagefragments.PageFragment;
1411
import info.novatec.testit.webtester.markings.Marker;
12+
import info.novatec.testit.webtester.pagefragments.PageFragment;
1513

1614

1715
public final class ActionTemplate {
@@ -42,16 +40,11 @@ public Action(T subject, Browser browser) {
4240
this.browser = browser;
4341
}
4442

45-
@SuppressWarnings({"unchecked", "PMD.AvoidCatchingGenericException"})
43+
@SuppressWarnings({ "unchecked", "PMD.AvoidCatchingGenericException" })
4644
public A execute(Consumer<T> consumer) {
4745
try {
48-
try {
49-
consumer.accept(subject);
50-
} catch (StaleElementReferenceException e) {
51-
WebElementFinder.clearCache();
52-
consumer.accept(subject);
53-
}
54-
} catch (RuntimeException e){
46+
consumer.accept(subject);
47+
} catch (RuntimeException e) {
5548
browser.events().fireExceptionEvent(e);
5649
throw e;
5750
}
@@ -80,16 +73,11 @@ public BiAction(T subject1, T subject2, Browser browser) {
8073
this.browser = browser;
8174
}
8275

83-
@SuppressWarnings({"unchecked", "PMD.AvoidCatchingGenericException"})
76+
@SuppressWarnings({ "unchecked", "PMD.AvoidCatchingGenericException" })
8477
public A execute(BiConsumer<T, T> consumer) {
8578
try {
86-
try {
87-
consumer.accept(subject1, subject2);
88-
} catch (StaleElementReferenceException e) {
89-
WebElementFinder.clearCache();
90-
consumer.accept(subject1, subject2);
91-
}
92-
} catch (RuntimeException e){
79+
consumer.accept(subject1, subject2);
80+
} catch (RuntimeException e) {
9381
browser.events().fireExceptionEvent(e);
9482
throw e;
9583
}
@@ -118,7 +106,7 @@ public PageFragmentAction(T subject) {
118106

119107
public PageFragmentAction<T> fireEvent(Function<T, Event> function) {
120108
EventSystem eventSystem = getEventSystem();
121-
if(eventSystem.isEnabled()) {
109+
if (eventSystem.isEnabled()) {
122110
eventSystem.fireEvent(function.apply(getSubject()));
123111
}
124112
return this;
@@ -144,7 +132,7 @@ public PageFragmentsAction(T subject1, T subject2) {
144132

145133
public PageFragmentsAction<T> fireEvent(BiFunction<T, T, Event> function) {
146134
EventSystem eventSystem = getEventSystem();
147-
if(eventSystem.isEnabled()) {
135+
if (eventSystem.isEnabled()) {
148136
eventSystem.fireEvent(function.apply(getSubject1(), getSubject2()));
149137
}
150138
return this;
@@ -172,7 +160,7 @@ public BrowserAction(T subject) {
172160

173161
public BrowserAction<T> fireEvent(Function<T, Event> function) {
174162
EventSystem eventSystem = getEventSystem();
175-
if(eventSystem.isEnabled()) {
163+
if (eventSystem.isEnabled()) {
176164
eventSystem.fireEvent(function.apply(getSubject()));
177165
}
178166
return this;

webtester-core/src/main/java/info/novatec/testit/webtester/internal/Caches.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

webtester-core/src/main/java/info/novatec/testit/webtester/internal/WebElementFinder.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)