This is an automated email from the ASF dual-hosted git repository. thiagohp pushed a commit to branch better-page-invalidation in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit f6b5fe4dadf9619bab7fb508af6c39c78b5e3d9d Author: Thiago H. de Paula Figueiredo <thi...@arsmachina.com.br> AuthorDate: Mon Dec 26 22:39:03 2022 -0300 TAP5-2744: upgrading Selenium and fixing integration tests TAP5-2744: upgrading Selenium TAP5-2744: upgrading Selenium again TAP5-2744: explicitly choosing Firefox for Selenium --- build.gradle | 3 +- tapestry-core/build.gradle | 2 +- .../integration/cluster/ClusterTests.java | 2 +- tapestry-test/build.gradle | 5 ++-- .../apache/tapestry5/test/SeleniumTestCase.java | 32 ++++++++++++++-------- tapestry-webresources/build.gradle | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index fc77f88e6..756578bf4 100755 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,8 @@ project.ext.versions = [ hibernate: "5.4.32.Final", slf4j: "1.7.25", geb: "2.0", - selenium: "3.141.59", + selenium: "4.5.0", + seleniumServer: "4.7.2", jackson: "2.13.1", jsonschemaGenerator: "4.20.0", junitJupiter: "5.8.2", diff --git a/tapestry-core/build.gradle b/tapestry-core/build.gradle index ee28a124e..142197c01 100644 --- a/tapestry-core/build.gradle +++ b/tapestry-core/build.gradle @@ -34,7 +34,7 @@ dependencies { implementation "commons-codec:commons-codec:1.10" testImplementation "org.junit.jupiter:junit-jupiter:${versions.junitJupiter}" - + testImplementation "org.apache.httpcomponents:httpclient:4.5.14" testRuntimeOnly project(':tapestry-spock') testRuntimeOnly "org.hsqldb:hsqldb:1.8.0.10" diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java index 30575af50..3b6f5f697 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/cluster/ClusterTests.java @@ -18,7 +18,7 @@ import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; -import io.github.bonigarcia.wdm.FirefoxDriverManager; +import io.github.bonigarcia.wdm.managers.FirefoxDriverManager; import org.apache.tapestry5.test.JettyRunner; import org.apache.tapestry5.test.TapestryTestConstants; diff --git a/tapestry-test/build.gradle b/tapestry-test/build.gradle index 95cdb58fb..008178eea 100644 --- a/tapestry-test/build.gradle +++ b/tapestry-test/build.gradle @@ -5,14 +5,15 @@ dependencies { api project(":tapestry-test-data") api project(":tapestry-runner") - api ("io.github.bonigarcia:webdrivermanager:2.2.4") + implementation ("io.github.bonigarcia:webdrivermanager:5.3.1") api "org.seleniumhq.selenium:selenium-leg-rc:${versions.selenium}", { exclude group: "org.seleniumhq.selenium", module: "jetty-repacked" exclude group: "org.testng", module: "testng" exclude group: "javax.servlet", module: "javax.servlet-api" + exclude group: "org.seleniumhq.selenium", module: "selenium-firefox-driver" } - api "org.seleniumhq.selenium:selenium-support:${versions.selenium}" + api "org.seleniumhq.selenium:selenium-java:${versions.seleniumServer}" api "org.testng:testng:${versions.testng}" api "org.easymock:easymock:${versions.easymock}" 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 6baec9a01..3f74477ab 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 @@ -19,15 +19,16 @@ import com.thoughtworks.selenium.webdriven.WebDriverCommandProcessor; import org.apache.tapestry5.test.constants.TapestryRunnerConstants; import org.openqa.selenium.By; +import org.openqa.selenium.Capabilities; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxDriverLogLevel; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxProfile; -import org.openqa.selenium.internal.WrapsDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -39,10 +40,11 @@ import org.testng.ITestContext; import org.testng.annotations.*; import org.testng.xml.XmlTest; -import io.github.bonigarcia.wdm.FirefoxDriverManager; +import io.github.bonigarcia.wdm.managers.FirefoxDriverManager; import java.io.File; import java.lang.reflect.Method; +import java.time.Duration; import java.util.concurrent.TimeUnit; /** @@ -211,26 +213,34 @@ public abstract class SeleniumTestCase extends Assert implements Selenium final Runnable stopWebServer = launchWebServer(container, webAppFolder, contextPath, port, sslPort); - FirefoxDriverManager.getInstance().setup(); +// FirefoxDriverManager.getInstance().setup(); + FirefoxDriverManager.firefoxdriver().setup(); File ffProfileTemplate = new File(TapestryRunnerConstants.MODULE_BASE_DIR, "src/test/conf/ff_profile_template"); - DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox(); - desiredCapabilities.setCapability(FirefoxDriver.MARIONETTE, true); + DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); - FirefoxOptions options = new FirefoxOptions(desiredCapabilities); - - if (ffProfileTemplate.isDirectory()) + FirefoxOptions options = new FirefoxOptions(desiredCapabilities); + options.setLogLevel(FirefoxDriverLogLevel.TRACE); + + if (ffProfileTemplate.isDirectory() && ffProfileTemplate.exists()) { + LOGGER.info("Loading Firefox profile from: {}", ffProfileTemplate); FirefoxProfile profile = new FirefoxProfile(ffProfileTemplate); options.setProfile(profile); +// profile.layoutOnDisk(); } - + else + { + FirefoxProfile profile = new FirefoxProfile(); + options.setProfile(profile); + profile.setPreference("intl.accept_languages", "en,fr,de"); + } + FirefoxDriver driver = new FirefoxDriver(options); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); CommandProcessor webDriverCommandProcessor = new WebDriverCommandProcessor(baseURL, driver); - final ErrorReporterImpl errorReporter = new ErrorReporterImpl(driver, testContext); ErrorReportingCommandProcessor commandProcessor = new ErrorReportingCommandProcessor(webDriverCommandProcessor, @@ -1363,7 +1373,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium protected void waitForCondition(ExpectedCondition condition, long timeoutSeconds) { - WebDriverWait wait = new WebDriverWait(webDriver, timeoutSeconds); + WebDriverWait wait = new WebDriverWait(webDriver, Duration.ofSeconds(timeoutSeconds)); wait.until(condition); } diff --git a/tapestry-webresources/build.gradle b/tapestry-webresources/build.gradle index 236dde6a7..770cc3717 100644 --- a/tapestry-webresources/build.gradle +++ b/tapestry-webresources/build.gradle @@ -26,7 +26,7 @@ dependencies { testImplementation "org.seleniumhq.selenium:selenium-java:${versions.selenium}", { exclude group: "org.eclipse.jetty" } - testImplementation "org.seleniumhq.selenium:selenium-server:${versions.selenium}", { + testImplementation "org.seleniumhq.selenium:selenium-server:${versions.seleniumServer}", { exclude group: "org.eclipse.jetty" } testImplementation ("io.github.bonigarcia:webdrivermanager:2.2.4")