diff --git a/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationInProgressException.java b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationInProgressException.java new file mode 100644 index 0000000..d66c7fa --- /dev/null +++ b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationInProgressException.java @@ -0,0 +1,4 @@ +package info.gehrels.voting.web.integrationTests.pages; + +public class ElectionCalculationInProgressException extends IllegalStateException { +} diff --git a/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationPage.java b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationPage.java index 937ce70..92c3ec4 100644 --- a/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationPage.java +++ b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ElectionCalculationPage.java @@ -1,6 +1,5 @@ package info.gehrels.voting.web.integrationTests.pages; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableSet; @@ -9,7 +8,6 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.WebDriverWait; import java.util.List; import java.util.Set; @@ -34,12 +32,6 @@ public final class ElectionCalculationPage { public ElectionCalculationPage(final WebDriver webDriver) { this.webDriver = webDriver; - new WebDriverWait(webDriver, 60).until(new Predicate() { - @Override - public boolean apply(WebDriver input) { - return webDriver.findElement(By.id("status-text")).isDisplayed(); - } - }); } public boolean electionCalculationHasFinished() { diff --git a/src/test/java/info/gehrels/voting/web/integrationTests/pages/ManageElectionCalculationsPage.java b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ManageElectionCalculationsPage.java index 4c79b58..0d435aa 100644 --- a/src/test/java/info/gehrels/voting/web/integrationTests/pages/ManageElectionCalculationsPage.java +++ b/src/test/java/info/gehrels/voting/web/integrationTests/pages/ManageElectionCalculationsPage.java @@ -1,12 +1,9 @@ package info.gehrels.voting.web.integrationTests.pages; -import com.google.common.base.Predicate; -import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.WebDriverWait; import static org.junit.Assert.fail; @@ -23,8 +20,6 @@ public final class ManageElectionCalculationsPage { public ManageElectionCalculationsPage(final WebDriver webDriver) { this.webDriver = webDriver; - new WebDriverWait(webDriver, 60) - .until((Predicate) input -> webDriver.findElement(By.xpath(INPUT_TYPE_SUBMIT)).isDisplayed()); } public T clickStartNewElectionCalculation(Class expectedResult) { @@ -34,7 +29,7 @@ public T clickStartNewElectionCalculation(Class expectedResult) { public ElectionCalculationPage clickElectionCalculation() { firstElectionCalculation.click(); - while(webDriver.getPageSource().contains("Die Wahlergebnisse werden momentan berechnet")) { + while(electionCalculationStillInProgress()) { try { Thread.sleep(500); } catch (InterruptedException e) { @@ -45,4 +40,10 @@ public ElectionCalculationPage clickElectionCalculation() { } return PageFactory.initElements(webDriver, ElectionCalculationPage.class); } + + private boolean electionCalculationStillInProgress() { + return + webDriver.getPageSource().contains("Die Wahlergebnisse werden momentan berechnet") || + webDriver.getPageSource().contains("Die Ergebnisberechnung wurde noch nicht gestartet."); + } }