aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2017-06-13 16:39:33 +0200
committerMartin Stockhammer <martin_s@apache.org>2017-06-13 16:39:33 +0200
commit577fa611b1bde885f3f3b6da650d695137557e8a (patch)
tree549b9c2b5725c362f853b4240eccc0a5602c593a
parent5608f7bbafd0951c2d65c170d7f1ba0eb88c507c (diff)
downloadarchiva-577fa611b1bde885f3f3b6da650d695137557e8a.tar.gz
archiva-577fa611b1bde885f3f3b6da650d695137557e8a.zip
Fixing another timing issue with JS tests
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java27
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java17
3 files changed, 32 insertions, 14 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java
index 37805588a..5e7cb0f4d 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java
@@ -22,10 +22,15 @@ package org.apache.archiva.web.test;
import org.apache.archiva.web.test.parent.AbstractArchivaTest;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
public class ArchivaAdminTest
extends AbstractArchivaTest
{
@@ -33,23 +38,23 @@ public class ArchivaAdminTest
@Test
public void testHome()
{
- getWebDriver().get( baseUrl );
- WebDriverWait wait = new WebDriverWait(getWebDriver(), 30);
- wait.until(ExpectedConditions.titleContains("Apache Archiva"));
+ loadPage( baseUrl, 30 );
+ WebDriverWait wait = new WebDriverWait( getWebDriver(), 30 );
+ wait.until( ExpectedConditions.titleContains( "Apache Archiva" ) );
}
@Test
public void testInitialRepositories()
{
- WebDriverWait wait = new WebDriverWait(getWebDriver(), 20);
+ WebDriverWait wait = new WebDriverWait( getWebDriver(), 20 );
WebElement el;
- el = wait.until(ExpectedConditions.elementToBeClickable( By.id("menu-repositories-list-a")));
- tryClick( el, ExpectedConditions.presenceOfElementLocated( By.xpath("//table[@id='managed-repositories-table']//td[contains(text(),'internal')]") ),
- "Managed Repositories not activated");
- wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='managed-repositories-table']//td[contains(text(),'snapshots')]") ));
- el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repositories-content']")));
- tryClick(el,ExpectedConditions.visibilityOfElementLocated(By.xpath("//table[@id='remote-repositories-table']//td[contains(text(),'central')]")),
- "Remote Repositories View not available");
+ el = wait.until( ExpectedConditions.elementToBeClickable( By.id( "menu-repositories-list-a" ) ) );
+ tryClick( el, ExpectedConditions.presenceOfElementLocated( By.xpath( "//table[@id='managed-repositories-table']//td[contains(text(),'internal')]" ) ),
+ "Managed Repositories not activated" );
+ wait.until( ExpectedConditions.visibilityOfElementLocated( By.xpath( "//table[@id='managed-repositories-table']//td[contains(text(),'snapshots')]" ) ) );
+ el = wait.until( ExpectedConditions.elementToBeClickable( By.xpath( "//a[@href='#remote-repositories-content']" ) ) );
+ tryClick( el, ExpectedConditions.visibilityOfElementLocated( By.xpath( "//table[@id='remote-repositories-table']//td[contains(text(),'central')]" ) ),
+ "Remote Repositories View not available" );
}
} \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
index 66696bc2e..c2731fc9f 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
@@ -180,7 +180,7 @@ public abstract class AbstractArchivaTest
public void goToHomePage()
{
- getWebDriver().get( baseUrl );
+ loadPage( baseUrl, 30 );
}
protected void logout()
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 4d51fa270..7ee5a6aed 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
@@ -129,6 +129,19 @@ public abstract class AbstractSeleniumTest
initializeArchiva( baseUrl, browser, maxWaitTimeInMs, seleniumHost, seleniumPort, remoteSelenium );
}
+ public void loadPage(String url, int timeout) {
+ getWebDriver().get( url );
+ WebDriverWait wait = new WebDriverWait( getWebDriver(), timeout );
+ wait.until( new Function<WebDriver, Boolean>()
+ {
+ public Boolean apply( WebDriver driver )
+ {
+ return ( (JavascriptExecutor) driver ).executeScript( "return document.readyState" ).equals( "complete" );
+ }
+ }
+ );
+ }
+
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs, String seleniumHost,
int seleniumPort, boolean remoteSelenium)
throws Exception
@@ -136,7 +149,7 @@ public abstract class AbstractSeleniumTest
open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs, remoteSelenium);
- getWebDriver().get(baseUrl);
+ loadPage(baseUrl, 30);
WebDriverWait wait = new WebDriverWait(getWebDriver(),30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("topbar-menu")));
@@ -232,7 +245,7 @@ public abstract class AbstractSeleniumTest
public void goToLoginPage()
{
logger.info("Goto login page");
- getWebDriver().get( baseUrl );
+ loadPage(baseUrl, 30);
WebDriverWait wait = new WebDriverWait(getWebDriver(),30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("topbar-menu")));
wait.until(ExpectedConditions.or(ExpectedConditions.visibilityOfElementLocated(By.id("logout-link")),