aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2017-11-02 21:53:11 +0100
committerMartin Stockhammer <martin_s@apache.org>2017-11-02 21:53:11 +0100
commit8b3de94f7738c897acdc7d18bed1f0fa9bd90c0f (patch)
tree02140744c7a307af74847d36e3029427105650aa /archiva-modules
parent8070af6128fed9bd66b2766dd876df4958a201d3 (diff)
downloadarchiva-8b3de94f7738c897acdc7d18bed1f0fa9bd90c0f.tar.gz
archiva-8b3de94f7738c897acdc7d18bed1f0fa9bd90c0f.zip
Adding another hack for selenium tests
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryAdminTest.java19
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java27
2 files changed, 41 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 e8240f5c6..6daad8a42 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
@@ -25,7 +25,9 @@ import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.List;
@@ -61,9 +63,15 @@ public class RepositoryAdminTest
setFieldValue( "id", "myrepoid" );
setFieldValue( "name", "My repo name" );
setFieldValue( "url", "http://www.repo.org" );
-
+
+ el = wait.until( ExpectedConditions.elementToBeClickable(By.id("remote-repository-save-button") ));
+ Actions actions = new Actions(getWebDriver());
+ actions.moveToElement(el);
+ actions.perform();
+ ((JavascriptExecutor)getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
el.click();
- wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a")));
+ el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a")));
+ ((JavascriptExecutor)getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
tryClick(By.id("menu-proxy-connectors-list-a"),
ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")),
"Network proxies not available",
@@ -76,7 +84,12 @@ public class RepositoryAdminTest
el = wait.until(ExpectedConditions.elementToBeClickable( By.id("proxy-connectors-view-tabs-a-edit") ));
el.click();
el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connector-btn-save")));
- selectValue( "sourceRepoId", "internal" );
+ wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-edit-fieldset")));
+ // Another hack, don't know why the normal selectValue() does not work here
+ ((JavascriptExecutor)getWebDriver()).executeScript("jQuery('#sourceRepoId').css('display','block')");
+ Select select = new Select(getWebDriver().findElement(By.xpath(".//select[@id='sourceRepoId']")));
+ select.selectByVisibleText("internal");
+ // selectValue( "sourceRepoId", "internal", true );
// Workaround
// TODO: Check after upgrade of htmlunit, bootstrap or jquery
// TODO: Check whats wrong here
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 96d6cf897..f7d979973 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,8 +37,10 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -503,11 +505,32 @@ public abstract class AbstractSeleniumTest
}
- public void selectValue( String locator, String value )
+ public WebElement selectValue( String locator, String value) {
+ return this.selectValue( locator, value, false );
+ }
+
+ public WebElement selectValue( String locator, String value, boolean scrollToView )
{
- WebElement element = findElement(locator );
+ int count = 5;
+ boolean check = true;
+ WebDriverWait wait = new WebDriverWait( getWebDriver( ), 10 );
+ WebElement element = null;
+ while(check && count-->0)
+ {
+ try
+ {
+ element = findElement( locator );
+ List<WebElement> elementList = new ArrayList<>( );
+ elementList.add( element );
+ wait.until( ExpectedConditions.visibilityOfAllElements( elementList ) );
+ check=false;
+ } catch (Throwable e) {
+ logger.info("Waiting for select element {} to be visible", locator);
+ }
+ }
Select select = new Select(element);
select.selectByValue( value );
+ return element;
}
public WebElement findElement(String locator) {