Skip to content

Commit

Permalink
Fixed flickering tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BGehrels committed Jul 23, 2017
1 parent 04932c1 commit dc3dc89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package info.gehrels.voting.web.integrationTests.pages;

public class ElectionCalculationInProgressException extends IllegalStateException {
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -34,12 +32,6 @@ public final class ElectionCalculationPage {

public ElectionCalculationPage(final WebDriver webDriver) {
this.webDriver = webDriver;
new WebDriverWait(webDriver, 60).until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return webDriver.findElement(By.id("status-text")).isDisplayed();
}
});
}

public boolean electionCalculationHasFinished() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -23,8 +20,6 @@ public final class ManageElectionCalculationsPage {

public ManageElectionCalculationsPage(final WebDriver webDriver) {
this.webDriver = webDriver;
new WebDriverWait(webDriver, 60)
.until((Predicate<WebDriver>) input -> webDriver.findElement(By.xpath(INPUT_TYPE_SUBMIT)).isDisplayed());
}

public <T> T clickStartNewElectionCalculation(Class<T> expectedResult) {
Expand All @@ -34,7 +29,7 @@ public <T> T clickStartNewElectionCalculation(Class<T> expectedResult) {

public ElectionCalculationPage clickElectionCalculation() {
firstElectionCalculation.click();
while(webDriver.getPageSource().contains("Die Wahlergebnisse werden momentan berechnet")) {
while(electionCalculationStillInProgress()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Expand All @@ -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.");
}
}

0 comments on commit dc3dc89

Please sign in to comment.