mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 14:12:11 +00:00
Bug 4339: Fix for non deterministic test failure due to
waitForAjaxRequests not being successful because of many parallel remote calls
This commit is contained in:
1 parent
f266258640
commit
005acbdd05
3 files changed
+16
-12
No files matched your search
+7
-9
@@ -7,8 +7,8 @@ import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.StaleElementReferenceException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
@@ -59,10 +59,10 @@ public abstract class DataEntryDialogPO extends PageArea {
|
||||
}
|
||||
|
||||
public void pressOk() {
|
||||
pressOk(false);
|
||||
pressOk(false, true);
|
||||
}
|
||||
|
||||
public void pressOk(boolean accept) {
|
||||
public void pressOk(boolean acceptAlert, boolean waitForAjaxRequests) {
|
||||
// This generically triggers revalidation in dialogs to ensure that the ok button gets enabled
|
||||
((JavascriptExecutor) driver).executeScript("!!document.activeElement ? document.activeElement.blur() : 0");
|
||||
|
||||
@@ -71,15 +71,13 @@ public abstract class DataEntryDialogPO extends PageArea {
|
||||
waitUntil(() -> isElementEntirelyVisible(this.okButton) && this.okButton.isEnabled());
|
||||
this.okButton.click();
|
||||
|
||||
|
||||
ExpectedCondition<Alert> condition = ExpectedConditions.alertIsPresent();
|
||||
Alert alert = condition.apply(this.driver);
|
||||
|
||||
if(alert != null && accept) {
|
||||
if (acceptAlert) {
|
||||
final Alert alert = new WebDriverWait(driver, DEFAULT_WAIT_TIMEOUT_SECONDS)
|
||||
.until(ExpectedConditions.alertIsPresent());
|
||||
alert.accept();
|
||||
}
|
||||
|
||||
if(alert == null || accept) {
|
||||
if (waitForAjaxRequests) {
|
||||
// Wait, since we do a callback usually
|
||||
waitForAjaxRequests();
|
||||
}
|
||||
|
||||
+2
-2
@@ -130,7 +130,7 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
RegattaDetailsCompositePO regattaDetails = regattaStructure.getRegattaDetails(this.regatta);
|
||||
SeriesEditDialogPO seriesDialog = regattaDetails.editSeries(RegattaStructureManagementPanelPO.DEFAULT_SERIES_NAME);
|
||||
seriesDialog.deleteRace("D3");
|
||||
seriesDialog.pressOk(true);
|
||||
seriesDialog.pressOk(true, false);
|
||||
final List<String> expectedRaces = Arrays.asList("D1", "D2", "D4", "D5");
|
||||
regattaDetails.waitForRacesOfSeries(RegattaStructureManagementPanelPO.DEFAULT_SERIES_NAME, expectedRaces);
|
||||
// Now we can check the result with our expectation
|
||||
@@ -169,7 +169,7 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
RegattaDetailsCompositePO regattaDetails = regattaStructure.getRegattaDetails(this.regatta);
|
||||
SeriesEditDialogPO seriesDialog = regattaDetails.editSeries(RegattaStructureManagementPanelPO.DEFAULT_SERIES_NAME);
|
||||
seriesDialog.renameRace("D1", "Q");
|
||||
seriesDialog.pressOk(true);
|
||||
seriesDialog.pressOk(true, false);
|
||||
|
||||
// Now we can check the result with our expectation
|
||||
leaderboardWindow.switchToWindow();
|
||||
|
||||
+7
-1
@@ -198,7 +198,13 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
Assert.assertFalse(mapSettings.isTransparentHoverlines());
|
||||
mapSettings.setWindUp(false);
|
||||
mapSettings.setTransparentHoverlines(false);
|
||||
mapSettings.pressOk();
|
||||
|
||||
// When just doing mapSettings.pressOk() this test often fails because the internally called waitForAjaxRequests
|
||||
// often never terminates because many components do parallel calls in short cycles
|
||||
// That's why we do not want to use waitForAjaxRequests here but instead wait a fix amount of time as workaround
|
||||
// TODO this could be improved by using a specific category for saving settings so that we could explicitly wait for this
|
||||
mapSettings.pressOk(false, false);
|
||||
Thread.sleep(5000);
|
||||
|
||||
raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA, BMW_CUP_REGATTA,
|
||||
String.format(BMW_RACE, 1), "WINNING_LANES");
|
||||
|
||||
Reference in new issue
Block a user