This is an automated email from the ASF dual-hosted git repository.

benw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 2c7b146803a43bded4a4e76f5265c0094617a366
Author: Ben Weidig <[email protected]>
AuthorDate: Mon Apr 6 13:04:22 2026 +0200

    SeleniumTestCase timeouts from testng.xml or system props only
    
    Managing the timeouts didn’t work out as planned, as Selenium is reused,
    and a different configuration might not be applied.
    
    To make it an explicit decision, we only consider the testng.xml
    parameters and the system properties as a fallback on runner creation.
---
 .../apache/tapestry5/test/SeleniumTestCase.java    | 57 +++++++++++++++-------
 .../tapestry5/test/TapestryTestConfiguration.java  | 13 -----
 .../tapestry5/test/TapestryTestConstants.java      | 18 ++++++-
 tapestry-webresources/build.gradle                 |  1 +
 .../services/web/WebResourcesTest.java             |  2 +-
 5 files changed, 59 insertions(+), 32 deletions(-)

diff --git 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
index cad438a32..6c4e84cf7 100644
--- 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
+++ 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
@@ -70,17 +70,29 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
 
     public static final String JETTY = "jetty";
 
+    /**
+     * Default: 15 seconds
+     * 
+     * @see {@link TapestryTestConstants#PAGE_LOAD_TIMEOUT_PARAMETER}
+     */
+    public static final String PAGE_LOAD_TIMEOUT = "15000";
+
+    /**
+     * Default: 15 seconds
+     *
+     * @see {@link TapestryTestConstants#WEBDRIVER_WAIT_TIMEOUT_PARAMETER}
+     * @since 5.10
+     */
+    public static final long WEBDRIVER_WAIT_TIMEOUT = 15L;
+
     /**
      * An XPath expression for locating a submit element (very commonly used
      * with {@link #clickAndWait(String)}.
-     *
+     
      * @since 5.3
      */
     public static final String SUBMIT = "//input[@type='submit']";
 
-    private long waitTimeout = 0L;
-    private String pageLoadTimeout = null;
-
     /**
      * The underlying {@link Selenium} instance that all the methods of this 
class delegate to;
      * this can be useful when attempting to use SeleniumTestCase with a newer 
version of Selenium which
@@ -102,6 +114,10 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
 
     private boolean errorReportWritten = false;
 
+    private String pageLoadTimeout;
+
+    private long webdriverWaitTimeout;
+
     /**
      * Starts up the servers for the entire test (i.e., for multiple 
TestCases). By placing &lt;parameter&gt; elements
      * inside the appropriate &lt;test&gt; (of your testng.xml configuration
@@ -119,7 +135,7 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
      * <td>container</td>
      * <td>tapestry.servlet-container</td>
      * <td>JETTY_7</td>
-     * <td>The Servlet container to use for the tests. Currently {@link 
#JETTY_7} or {@link #TOMCAT_6}</td>
+     * <td>The Servlet container to use for the tests. Currently {@link 
#JETTY} or {@link #TOMCAT}</td>
      * </tr>
      * <tr>
      * <td>webAppFolder</td>
@@ -195,10 +211,6 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
             annotation = 
EmptyInnerClass.class.getAnnotation(TapestryTestConfiguration.class);
         }
 
-        this.waitTimeout = getLongParameter(xmlTest, "selenium.wait.timeout", 
annotation.waitTimeout());
-        long pageLoadNum = getLongParameter(xmlTest, 
"selenium.page-load.timout", annotation.pageLoadTimeout());
-        this.pageLoadTimeout = String.valueOf(pageLoadNum * 1_000L);
-
         String webAppFolder = getParameter(xmlTest, 
TapestryTestConstants.WEB_APP_FOLDER_PARAMETER,
                 annotation.webAppFolder());
         String container = getParameter(xmlTest, 
TapestryTestConstants.SERVLET_CONTAINER_PARAMETER,
@@ -212,7 +224,14 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
 
         String baseURL = String.format("http://localhost:%d%s/";, port, 
contextPath);
 
-        String sep = System.getProperty("line.separator");
+        long waitTimeoutSeconds = getLongParameter(xmlTest, 
TapestryTestConstants.WEBDRIVER_WAIT_TIMEOUT_PARAMETER, WEBDRIVER_WAIT_TIMEOUT);
+        long pageLoadTimeoutSeconds = getLongParameter(xmlTest, 
TapestryTestConstants.PAGE_LOAD_TIMEOUT_PARAMETER, 
Long.parseLong(PAGE_LOAD_TIMEOUT) / 1000L);
+        String pageLoadTimeoutMs = String.valueOf(pageLoadTimeoutSeconds * 
1_000L);
+
+        
testContext.setAttribute(TapestryTestConstants.WEBDRIVER_WAIT_TIMEOUT_PARAMETER,
 waitTimeoutSeconds);
+        
testContext.setAttribute(TapestryTestConstants.PAGE_LOAD_TIMEOUT_PARAMETER, 
pageLoadTimeoutMs);
+
+        String sep = System.lineSeparator();
 
         LOGGER.info("Starting SeleniumTestCase:" + sep +
                 "      currentDir: " + System.getProperty("user.dir") + sep +
@@ -222,8 +241,8 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
                 String.format("           ports: %d / %d", port, sslPort) + 
sep +
                 "    browserStart: " + browserStartCommand + sep +
                 "         baseURL: " + baseURL + sep +
-                "     waitTimeout: " + this.waitTimeout + "s" + sep +
-                " pageLoadTimeout: " + pageLoadNum + "s");
+                "     waitTimeout: " + waitTimeoutSeconds + "s" + sep +
+                " pageLoadTimeout: " + pageLoadTimeoutSeconds + "s");
 
         final Runnable stopWebServer = launchWebServer(container, 
webAppFolder, contextPath, port, sslPort);
 
@@ -235,9 +254,7 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
         // TAP5-2819: Run headless on CI
         if (Boolean.parseBoolean(System.getProperty("ci", "false")))
         {
-            options.addArguments("-headless");
-            options.addArguments("--width=1920");
-            options.addArguments("--height=1080");
+            options.addArguments("-headless", "--width=1920", "--height=1080");
         }
 
         File ffProfileTemplate = new 
File(TapestryRunnerConstants.MODULE_BASE_DIR, 
"src/test/conf/ff_profile_template");
@@ -346,6 +363,8 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
                     
testContext.removeAttribute(TapestryTestConstants.ERROR_REPORTER_ATTRIBUTE);
                     
testContext.removeAttribute(TapestryTestConstants.COMMAND_PROCESSOR_ATTRIBUTE);
                     
testContext.removeAttribute(TapestryTestConstants.SHUTDOWN_ATTRIBUTE);
+                    
testContext.removeAttribute(TapestryTestConstants.PAGE_LOAD_TIMEOUT_PARAMETER);
+                    
testContext.removeAttribute(TapestryTestConstants.WEBDRIVER_WAIT_TIMEOUT_PARAMETER);
                 }
             }
         });
@@ -475,6 +494,9 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
         webDriver = ((WebDriverBackedSelenium) selenium).getWrappedDriver();
         baseURL = (String) 
context.getAttribute(TapestryTestConstants.BASE_URL_ATTRIBUTE);
         errorReporter = (ErrorReporter) 
context.getAttribute(TapestryTestConstants.ERROR_REPORTER_ATTRIBUTE);
+
+        this.webdriverWaitTimeout = (Long) 
context.getAttribute(TapestryTestConstants.WEBDRIVER_WAIT_TIMEOUT_PARAMETER);
+        this.pageLoadTimeout = (String) 
context.getAttribute(TapestryTestConstants.PAGE_LOAD_TIMEOUT_PARAMETER);
     }
 
     @AfterClass
@@ -513,13 +535,14 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
      * Either default vaule (15L) or set via system properties 
(selenium.wait.timeout).
      */
     public long getWaitTimeout() {
-        return this.waitTimeout;
+        return this.webdriverWaitTimeout;
     }
 
     /**
      * Returns the Selenium page load timeout in millis as String.
      *
-     * Either default vaule ("15000") or set via system properties 
(selenium.page-loag.timeout).
+     * Either default value ({@link #PAGE_LOAD_TIMEOUT}) or set via testng.xml 
/ system property
+     * ({@link TapestryTestConstants#PAGE_LOAD_TIMEOUT_PARAMETER}).
      */
     public String getPageLoadTimeout() {
         return this.pageLoadTimeout;
diff --git 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConfiguration.java
 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConfiguration.java
index 65f902717..54c6dd559 100644
--- 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConfiguration.java
+++ 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConfiguration.java
@@ -66,17 +66,4 @@ public @interface TapestryTestConfiguration
      * The browser start command to use with Selenium. Defaults to "*firefox".
      */
     String browserStartCommand() default "*firefox";
-
-    /**
-     * The duration of seconds {@link WebDriverWait} should use.
-     * Defaults to 15, overridable via TestNG xml or system properties: {@code 
selenium.wait.timeout}
-     */
-    long waitTimeout() default 15L;
-
-    /**
-     * The duration of seconds {@link Selenium#waitForPageToLoad(String)} is 
using.
-     * Defaults to 15, overridable via TestNG or system properties: {@code 
selenium.page-load.timeout}
-     * The value is automatically converted to String.
-     */
-    long pageLoadTimeout() default 15L;
 }
diff --git 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
index 09e403940..cc5389dc7 100644
--- 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
+++ 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2010, 2013 The Apache Software Foundation
+// Copyright 2007, 2010, 2013, 2026 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -106,4 +106,20 @@ public class TapestryTestConstants
      * @since 5.3
      */
     public static final String SERVLET_CONTAINER_PARAMETER = 
"tapestry.servlet-container";
+
+    /**
+     * {@link XmlTest} parameter (in seconds) and {@link ITestContext} 
attribute (stored as millis String)
+     * for the page-load timeout passed to Selenium.
+     *
+     * @since 5.10
+     */
+    public static final String PAGE_LOAD_TIMEOUT_PARAMETER = 
"tapestry.page-load-timeout";
+
+    /**
+     * {@link XmlTest} parameter (in seconds) and {@link ITestContext} 
attribute for the
+     * WebDriverWait timeout used by Selenium conditions.
+     *
+     * @since 5.10
+     */
+    public static final String WEBDRIVER_WAIT_TIMEOUT_PARAMETER = 
"tapestry.wait-timeout";
 }
diff --git a/tapestry-webresources/build.gradle 
b/tapestry-webresources/build.gradle
index 8a56b25d0..4588f1334 100644
--- a/tapestry-webresources/build.gradle
+++ b/tapestry-webresources/build.gradle
@@ -26,6 +26,7 @@ dependencies {
 
 test {
     systemProperties(
+        'tapestry.page-load-timeout': '60',
         'tapestry.compiled-asset-cache-dir': "$buildDir/compiled-asset-cache",
         'tapestry.production-mode': 'false',
         'tapestry.compress-whitespace': 'false',
diff --git 
a/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
 
b/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
index b260b674c..c4b932c81 100644
--- 
a/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
+++ 
b/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
@@ -20,7 +20,7 @@ import org.testng.annotations.Test;
 /**
  * Adapted from WebResourcesSpec.groovy.s
  */
-@TapestryTestConfiguration(webAppFolder = "src/test/webapp", pageLoadTimeout = 
60L)
+@TapestryTestConfiguration(webAppFolder = "src/test/webapp")
 public class WebResourcesTest extends SeleniumTestCase {
 
     @Test

Reply via email to