diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayConfiguration.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayConfiguration.java index e2f7d2f2b87..d2842d0ba10 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayConfiguration.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayConfiguration.java @@ -2,7 +2,9 @@ package com.sap.sailing.selenium.pages.autoplay; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.WebDriverWait; +import com.google.common.base.Predicate; import com.sap.sailing.selenium.core.BySeleniumId; import com.sap.sailing.selenium.core.FindBy; import com.sap.sailing.selenium.pages.PageArea; @@ -29,6 +31,15 @@ public class AutoPlayConfiguration extends PageArea { ListBoxPO.create(driver, configurationSelectionBox).selectOptionByLabel(mode); ListBoxPO.create(driver, eventSelectionBox).selectOptionByLabel(event); ListBoxPO.create(driver, leaderboardSelectionBox).selectOptionByLabel(leaderboard); + WebDriverWait wait = new WebDriverWait(driver, 10); + //wait till the page processed the changes + wait.until(new Predicate() { + + @Override + public boolean apply(WebDriver arg0) { + return getConfiguredUrl() != null && !getConfiguredUrl().isEmpty(); + } + }); } public String getConfiguredUrl() { diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/autoplay/TestAutoPlay.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/autoplay/TestAutoPlay.java index 50356d566f3..c3e22beca2f 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/autoplay/TestAutoPlay.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/autoplay/TestAutoPlay.java @@ -89,17 +89,12 @@ public class TestAutoPlay extends AbstractSeleniumTest { AutoPlayConfiguration autoPlayConfiguration = page.getAutoPlayConfiguration(); assertNotNull(autoPlayConfiguration); autoPlayConfiguration.select("Sixty Inch Autoplay", BMW_CUP_EVENT, BMW_CUP_REGATTA); - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } String url = autoPlayConfiguration.getConfiguredUrl(); - // eventid and server might change slightly, better only check arguments + // eventid and server change, better only check arguments assertTrue("Url does not contain proper type " + url, url.contains("autoplayType=SIXTYINCH")); assertTrue("Url does not contain proper name " + url, url.contains("name=BMW+Cup+(J80)")); - // give some extra time to load settings and create url AutoPlayUpcomingView autoplayPage = page.goToAutoPlaySixtyInchUrl(getWebDriver(), url); + // give some extra time to load the leaderboard and finish the animation try { Thread.sleep(15000); } catch (InterruptedException e1) { @@ -107,7 +102,6 @@ public class TestAutoPlay extends AbstractSeleniumTest { } String nextUpText = autoplayPage.getText(); assertEquals("There are currently no further planned races", nextUpText); - // give some extra time to load the leaderboard and finish the animation } @Test @@ -124,14 +118,8 @@ public class TestAutoPlay extends AbstractSeleniumTest { AutoPlayConfiguration autoPlayConfiguration = page.getAutoPlayConfiguration(); assertNotNull(autoPlayConfiguration); autoPlayConfiguration.select("Classic Autoplay", BMW_CUP_EVENT, BMW_CUP_REGATTA); - // give some extra time to load settings and create url - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } String url = autoPlayConfiguration.getConfiguredUrl(); - // eventid and server might change slightly, better only check arguments + // eventid and server change, better only check arguments assertTrue("Url does not contain proper title " + url, url.contains("lbwh.saph.title=Leaderboard%3A+BMW+Cup+(J80)")); assertTrue("Url does not contain proper name " + url, url.contains("name=BMW+Cup+(J80)")); AutoPlayLeaderboardView autoplayPage = page.goToAutoPlayClassicUrl(getWebDriver(), url);