Skip to content

Commit dc02d13

Browse files
committed
[java] support DEBUG environment variable for turning on logging of tests
1 parent f779b50 commit dc02d13

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

java/test/org/openqa/selenium/testing/JupiterTestBase.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import java.net.MalformedURLException;
2323
import java.net.URL;
2424
import java.time.Duration;
25+
import java.util.Arrays;
2526
import java.util.Optional;
27+
import java.util.logging.Level;
2628
import java.util.logging.Logger;
2729
import org.junit.jupiter.api.AfterEach;
2830
import org.junit.jupiter.api.BeforeAll;
@@ -43,6 +45,18 @@ public abstract class JupiterTestBase {
4345

4446
@RegisterExtension protected static SeleniumExtension seleniumExtension = new SeleniumExtension();
4547

48+
static {
49+
if ("true".equalsIgnoreCase(System.getenv("DEBUG"))) {
50+
Logger rootLogger = Logger.getLogger("");
51+
rootLogger.setLevel(Level.FINE);
52+
Arrays.stream(rootLogger.getHandlers()).forEach(handler -> {
53+
handler.setLevel(Level.FINE);
54+
});
55+
56+
LOG.fine("Global debug logging enabled via DEBUG environment variable");
57+
}
58+
}
59+
4660
protected TestEnvironment environment;
4761
protected AppServer appServer;
4862
protected Pages pages;
@@ -81,9 +95,12 @@ public void prepareEnvironment() {
8195

8296
pages = new Pages(appServer);
8397

98+
99+
84100
driver = seleniumExtension.getDriver();
85101
wait = seleniumExtension::waitUntil;
86102
shortWait = seleniumExtension::shortWaitUntil;
103+
87104
}
88105

89106
@AfterEach

0 commit comments

Comments
 (0)