]> source.dussan.org Git - archiva.git/commitdiff
Fixing web ui tests
authorMartin Stockhammer <martin_s@apache.org>
Sat, 2 Mar 2019 17:56:59 +0000 (18:56 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Sat, 2 Mar 2019 17:56:59 +0000 (18:56 +0100)
archiva-modules/archiva-web/archiva-webapp-test/pom.xml
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java

index ecff6b48140d7f1ca42ed8c15861e160c8917ae7..2dbe3d220367ea40bbacf225d706447acd7bf0a3 100644 (file)
@@ -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>
               <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>
                 </goals>
                 <configuration>
                   <tasks>
-                    <delete file="${user.home}/.m2/archiva.xml" quiet="true"/>
+                    <delete file="${user.home}/.m2/archiva.xml" quiet="true" />
                   </tasks>
                 </configuration>
               </execution>
index 4ed311db24fa16f7acff00f59ee480ca29f92e8e..09c3927d439517edc2611284fd958455a112eeb8 100644 (file)
@@ -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" );
index deec6c0e2b1db9eb3d7527e2b898ada1ed230210..0da5bf156780669ded1777ae17b8534d5bb28731 100644 (file)
@@ -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"),
index 3a886c7c4c11f4d54bc3c6ec8174aabac357ff24..5890cee244bf58c3f3678c354916495147bd1f4b 100644 (file)
@@ -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();
     }