diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-03-02 18:56:59 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-03-02 18:56:59 +0100 |
commit | be4dab11592ec402fb4349f84fe7c535ce889abc (patch) | |
tree | 5051e3d639f972e86973bfec12be457268d53ffc /archiva-modules | |
parent | 29e40eae69f945119b566d75dc3bdecd4a81edd5 (diff) | |
download | archiva-be4dab11592ec402fb4349f84fe7c535ce889abc.tar.gz archiva-be4dab11592ec402fb4349f84fe7c535ce889abc.zip |
Fixing web ui tests
Diffstat (limited to 'archiva-modules')
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 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>2.2.3-SNAPSHOT</version> + <version>2.2.4-SNAPSHOT</version> </parent> <artifactId>archiva-webapp-test</artifactId> <packaging>pom</packaging> @@ -210,7 +210,23 @@ <groupId>org.seleniumhq.selenium</groupId> <artifactId>htmlunit-driver</artifactId> <version>2.24</version> - </dependency> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>16.0.1</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-chrome-driver</artifactId> + <version>${selenium-server.version}</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium</groupId> + <artifactId>selenium-support</artifactId> + <version>${selenium-server.version}</version> + </dependency> + </dependencies> </plugin> <plugin> @@ -563,7 +579,7 @@ </goals> <configuration> <tasks> - <delete file="${user.home}/.m2/archiva.xml" quiet="true"/> + <delete file="${user.home}/.m2/archiva.xml" quiet="true" /> </tasks> </configuration> </execution> 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<FluentWebElement> elementss = find( "#menu-find-browse-a" ); + FluentList<FluentWebElement> 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 <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> @@ -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(); } |