You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by th...@apache.org on 2023/01/15 12:29:48 UTC
[tapestry-5] branch better-page-invalidation updated: Attempt to get Firefox tests run on Linux with and without Snap
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
The following commit(s) were added to refs/heads/better-page-invalidation by this push:
new 6bd052e46 Attempt to get Firefox tests run on Linux with and without Snap
6bd052e46 is described below
commit 6bd052e46d5c4960fc9ff9b072c3f2690dace9af
Author: Thiago H. de Paula Figueiredo <th...@arsmachina.com.br>
AuthorDate: Sun Jan 15 09:29:34 2023 -0300
Attempt to get Firefox tests run on Linux with and without Snap
---
.../org/apache/tapestry5/test/SeleniumTestCase.java | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
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 620e94b7b..339e28ed8 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
@@ -239,7 +239,15 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
profile.setPreference("intl.accept_languages", "en,fr,de");
}
- FirefoxDriver driver = new FirefoxDriver(createGeckoDriverService("/home/thiago/tmp/selenium"), options);
+ // From https://forums.parasoft.com/discussion/5682/using-selenium-with-firefox-snap-ubuntu
+ String osName = System.getProperty("os.name");
+ String profileRoot = osName.contains("Linux") && new File("/snap/firefox").exists()
+ ? createProfileRootInUserHome()
+ : null;
+ FirefoxDriver driver = profileRoot != null
+ ? new FirefoxDriver(createGeckoDriverService(profileRoot), options)
+ : new FirefoxDriver(options);
+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
CommandProcessor webDriverCommandProcessor = new WebDriverCommandProcessor(baseURL, driver);
@@ -315,6 +323,17 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
});
}
+ private static String createProfileRootInUserHome() {
+ String userHome = System.getProperty("user.home");
+ File profileRoot = new File(userHome, "snap/firefox/common/.firefox-profile-root");
+ if (!profileRoot.exists()) {
+ if (!profileRoot.mkdirs()) {
+ return null;
+ }
+ }
+ return profileRoot.getAbsolutePath();
+ }
+
private static GeckoDriverService createGeckoDriverService(String tempProfileDir) {
return new GeckoDriverService.Builder() {
@Override