aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2017-06-09 23:19:58 +0200
committerMartin Stockhammer <martin_s@apache.org>2017-06-09 23:19:58 +0200
commit2513029e2e6c3333073c265fa496bc50fb2e405d (patch)
tree30f0a3ca4333f906bb6880313d5d1ab270028cde /archiva-modules/archiva-web
parentf242578be0635b7487976c6c0187acb4f70a0b27 (diff)
downloadarchiva-2513029e2e6c3333073c265fa496bc50fb2e405d.tar.gz
archiva-2513029e2e6c3333073c265fa496bc50fb2e405d.zip
Adding fixes for chrome WebDriver
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java8
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java26
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/tools/WebdriverUtility.java9
3 files changed, 38 insertions, 5 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java
index d9d0da10b..6dbf5ebc6 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java
@@ -66,9 +66,11 @@ public class RepositoryAdminTest
el.click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a")));
- el = wait.until(ExpectedConditions.elementToBeClickable( By.id("menu-proxy-connectors-list-a") ));
- el.click();
- wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")));
+ tryClick(By.id("menu-proxy-connectors-list-a"),
+ ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")),
+ "Network proxies not available",
+ 3,10
+ );
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("main-content"), "Proxy Connectors"));
// proxy connect
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central" ));
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 2cfe0705c..7922997e5 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
@@ -620,6 +620,32 @@ public abstract class AbstractSeleniumTest
}
}
+ public <V> V tryClick(By clickableLocator, Function<? super WebDriver, V> conditions, String message, int attempts, int maxWaitTimeInS) {
+
+ int count = attempts;
+ WebDriverWait wait = new WebDriverWait( getWebDriver(), maxWaitTimeInS );
+ V result = null;
+ Exception ex = null;
+ while(count>0)
+ {
+ try
+ {
+ WebElement el = wait.until(ExpectedConditions.elementToBeClickable( clickableLocator ));
+ el.click();
+ result = wait.until( conditions );
+ count=0;
+ ex = null;
+ } catch (Exception e) {
+ ex = e;
+ count--;
+ }
+ }
+ if (ex!=null) {
+ Assert.fail( message);
+ }
+ return result;
+ }
+
/**
* Executes click() on the WebElement <code>el</code> and waits for the conditions.
* If the condition is not fulfilled in <code>maxWaitTimeInS</code>, the click is executed again
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/tools/WebdriverUtility.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/tools/WebdriverUtility.java
index 12546c340..a1fbca3bf 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/tools/WebdriverUtility.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/tools/WebdriverUtility.java
@@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
@@ -69,13 +70,17 @@ public class WebdriverUtility
try {
if ( StringUtils.contains(seleniumBrowser, "chrome")) {
+ ChromeOptions options = new ChromeOptions();
+ options.addArguments("start-maximized");
if (seleniumRemote)
{
+ DesiredCapabilities capabilities = DesiredCapabilities.chrome();
+ capabilities.setCapability( ChromeOptions.CAPABILITY, options );
return new RemoteWebDriver( new URL( "http://" + seleniumHost + ":" + seleniumPort + "/wd/hub" ),
- DesiredCapabilities.chrome()
+ capabilities
);
} else {
- return new ChromeDriver( );
+ return new ChromeDriver( options );
}
}