@@ -61,7 +61,6 @@ public abstract class JUnit4TestBase implements WrapsDriver {
61
61
protected AppServer appServer ;
62
62
protected Pages pages ;
63
63
private static ThreadLocal <WebDriver > storedDriver = new ThreadLocal <>();
64
- private Browser browser ;
65
64
protected WebDriver driver ;
66
65
protected Wait <WebDriver > wait ;
67
66
protected Wait <WebDriver > shortWait ;
@@ -84,21 +83,12 @@ public void prepareEnvironment() throws Exception {
84
83
85
84
@ Rule
86
85
public TestRule chain = RuleChain
87
- .outerRule (new DetectBrowserRule ())
88
- .around (new TraceMethodNameRule ())
86
+ .outerRule (new TraceMethodNameRule ())
89
87
.around (new ManageDriverRule ())
90
88
.around (new SwitchToTopRule ())
91
89
.around (new NotYetImplementedRule ())
92
90
.around (new CoveringUpSauceErrorsRule ());
93
91
94
- private class DetectBrowserRule extends TestWatcher {
95
- @ Override
96
- protected void starting (Description description ) {
97
- browser = Browser .detect ();
98
- super .starting (description );
99
- }
100
- }
101
-
102
92
private class TraceMethodNameRule extends TestWatcher {
103
93
@ Override
104
94
protected void starting (Description description ) {
@@ -116,6 +106,7 @@ protected void finished(Description description) {
116
106
private class ManageDriverRule extends TestWatcher {
117
107
@ Override
118
108
protected void starting (Description description ) {
109
+ super .starting (description );
119
110
NeedsFreshDriver annotation = description .getAnnotation (NeedsFreshDriver .class );
120
111
if (annotation != null ) {
121
112
removeDriver ();
@@ -127,7 +118,6 @@ protected void starting(Description description) {
127
118
} catch (Exception e ) {
128
119
throw new RuntimeException ("Exception creating driver" , e );
129
120
}
130
- super .starting (description );
131
121
}
132
122
133
123
@ Override
@@ -184,6 +174,13 @@ private void dealWithSauceFailureIfNecessary(Throwable t) {
184
174
}
185
175
186
176
private class NotYetImplementedRule implements TestRule {
177
+
178
+ private Browser browser ;
179
+
180
+ public NotYetImplementedRule () {
181
+ browser = Browser .detect ();
182
+ }
183
+
187
184
@ Override
188
185
public Statement apply (final Statement base , final Description description ) {
189
186
if (!isNotYetImplemented (description )) {
0 commit comments