From be4dab11592ec402fb4349f84fe7c535ce889abc Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sat, 2 Mar 2019 18:56:59 +0100 Subject: [PATCH] Fixing web ui tests --- .../archiva-web/archiva-webapp-test/pom.xml | 22 ++++++++++++++++--- .../archiva/web/test/WebDriverBrowseTest.java | 10 ++++++--- .../archiva/web/test/WebDriverTest.java | 7 +++++- .../web/test/parent/AbstractSeleniumTest.java | 17 +++++++++++++- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml index ecff6b481..2dbe3d220 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml @@ -23,7 +23,7 @@ org.apache.archiva archiva-web - 2.2.3-SNAPSHOT + 2.2.4-SNAPSHOT archiva-webapp-test pom @@ -210,7 +210,23 @@ org.seleniumhq.selenium htmlunit-driver 2.24 - + + + com.google.guava + guava + 16.0.1 + + + org.seleniumhq.selenium + selenium-chrome-driver + ${selenium-server.version} + + + org.seleniumhq.selenium + selenium-support + ${selenium-server.version} + + @@ -563,7 +579,7 @@ - + diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java index 4ed311db2..09c3927d4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java @@ -115,12 +115,16 @@ public class WebDriverBrowseTest fill( "#confirmPassword" ).with( p.getProperty( "ADMIN_PASSWORD" ) ); find( "#user-create-form-register-button" ).click(); - await().atMost( 2, TimeUnit.SECONDS ).until( "#logout-link" ).isPresent(); + await().atMost( 10, TimeUnit.SECONDS ).until( "#logout-link" ).isPresent(); + await().atMost( 10, TimeUnit.SECONDS ).until( "#footer-content" ).isPresent(); - FluentList elementss = find( "#menu-find-browse-a" ); + FluentList elementss = find( "#menu-find-search-a" ); WebElement webElsement = elementss.get( 0 ).getElement(); webElsement.click(); - await().atMost( 2, TimeUnit.SECONDS ).until( "#main_browse_result" ).isPresent(); + elementss = find( "#menu-find-browse-a" ); + webElsement = elementss.get( 0 ).getElement(); + webElsement.click(); + await().atMost( 120, TimeUnit.SECONDS ).until( "#main_browse_result" ).isPresent(); // give me search page :( not browse page takeScreenShot( "search.png" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java index deec6c0e2..0da5bf156 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java @@ -44,6 +44,8 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; import org.fluentlenium.core.Fluent; import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Olivier Lamy @@ -51,13 +53,15 @@ import org.junit.Before; public class WebDriverTest extends FluentTest { + Logger logger = LoggerFactory.getLogger( WebDriverTest.class ); + @Override public Fluent takeScreenShot(String fileName) { try { // save html to have a minimum feedback if jenkins firefox not up File fileNameHTML = new File(fileName + ".html"); FileUtils.writeStringToFile(fileNameHTML, getDriver().getPageSource()); - } catch (IOException e) { + } catch (Throwable e) { System.out.print(e.getMessage()); e.printStackTrace(); } @@ -104,6 +108,7 @@ public class WebDriverTest String seleniumHost = System.getProperty("seleniumHost", "localhost"); int seleniumPort = Integer.getInteger("seleniumPort", 4444); try { + logger.info("Remote Web Driver: {}, {}", seleniumBrowser, seleniumPort); if (StringUtils.contains(seleniumBrowser, "chrome")) { return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java index 3a886c7c4..5890cee24 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java @@ -37,6 +37,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Emmanuel Venisse @@ -45,6 +47,7 @@ import org.apache.commons.io.FileUtils; public abstract class AbstractSeleniumTest { + final Logger logger = LoggerFactory.getLogger( AbstractSeleniumTest.class ); @Rule public ArchivaSeleniumExecutionRule archivaSeleniumExecutionRule = new ArchivaSeleniumExecutionRule(); @@ -83,7 +86,9 @@ public abstract class AbstractSeleniumTest baseUrl = "http://localhost:" + tomcatPort + "/archiva/index.html?request_lang=en"; + open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs ); + logger.info("Selected Browser: {}", browser); archivaSeleniumExecutionRule.selenium = selenium; assertAdminCreated(); } @@ -701,7 +706,17 @@ public abstract class AbstractSeleniumTest File fileName = new File( targetPath, fileBaseName + ".png" ); - selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "background=#FFFFFF" ); + try + { + selenium.captureEntirePageScreenshot( fileName.getAbsolutePath( ), "background=#FFFFFF" ); + } catch (Throwable e) { + try + { + selenium.captureScreenshot( fileName.getAbsolutePath( ) ); + } catch (Throwable e1) { + logger.error("Could not capture screenshot {}:", e1.getMessage(), e1); + } + } return fileName.getAbsolutePath(); } -- 2.39.5