mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
bug 4339 adjust tests for raceboard to be more resistant against timing
issues
This commit is contained in:
1 parent
56d3f902bd
commit
d84b609dac
2 files changed
+119
-120
No files matched your search
+32
@@ -3,9 +3,11 @@ package com.sap.sailing.selenium.pages.raceboard;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
@@ -20,6 +22,7 @@ public class RaceBoardPage extends HostPageWithAuthentication {
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "raceMapSettingsButton")
|
||||
private WebElement raceMapSettingsButton;
|
||||
private boolean doneInit;
|
||||
|
||||
/**
|
||||
* Navigates to the given home URL and provides the corresponding {@link PageObject}.
|
||||
@@ -42,6 +45,35 @@ public class RaceBoardPage extends HostPageWithAuthentication {
|
||||
private RaceBoardPage(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void waitForAjaxRequests(int timeout, int polling) {
|
||||
// since the raceboard continually loads new data, we cannot wait for it to finish initially
|
||||
if (doneInit) {
|
||||
super.waitForAjaxRequests(timeout, polling);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initElements() {
|
||||
super.initElements();
|
||||
doneInit = true;
|
||||
|
||||
// wait untill initial rendering of racemap & compilation ect, as default ajax based wait won't work here
|
||||
WebDriverWait webDriverWait = new WebDriverWait(driver, 300);
|
||||
webDriverWait.until(new Function<WebDriver, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(WebDriver t) {
|
||||
try {
|
||||
return raceMapSettingsButton.isDisplayed() && raceMapSettingsButton.getLocation().y > 100;
|
||||
} catch (Exception e) {
|
||||
// RaceMap cause multiple reflows and the element may temporarily not be in the viewport
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MapSettingsPO openMapSettings() {
|
||||
waitUntil(new BooleanSupplier() {
|
||||
@Override
|
||||
|
||||
+87
-120
@@ -77,7 +77,6 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
// Modes settings were formerly patched on the user defaults but are now patched on top of the system defaults.
|
||||
// In addition, there are now different settigns keys per mode so that settigns for one mode do not have an effect on other modes.
|
||||
// To verify this, there are new tests below but these do not test ReceBoard's embedded Leaderboard.
|
||||
// FIXME uncomment leaderboard test code when selenium infrastructure gets an upgrade
|
||||
/**
|
||||
* Verifies the settings storage of the raceboard. Checks the precedences of url, context specific settings, mode
|
||||
* settings and global settings.
|
||||
@@ -95,35 +94,29 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
RaceBoardPage raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA,
|
||||
BMW_CUP_REGATTA, String.format(BMW_RACE, 1), "PLAYER");
|
||||
|
||||
//FIXME uncomment the leaderboard code when selenium on remote build server displays the raceboard properly
|
||||
DetailCheckboxInfo[] detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// Overall details
|
||||
|
||||
// DetailCheckboxInfo[] detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// // Overall details
|
||||
//
|
||||
// // Race details
|
||||
// DetailCheckboxInfo.RACE_GAP_TO_LEADER,
|
||||
// DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND,
|
||||
// DetailCheckboxInfo.DISPLAY_LEGS,
|
||||
//
|
||||
// // Race Start Analysis
|
||||
//
|
||||
// // Leg Details
|
||||
// DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
//
|
||||
// // Maneuvers
|
||||
// DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE,
|
||||
// DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
//
|
||||
// };
|
||||
//
|
||||
// LeaderboardSettingsDialogPO leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
// LeaderboardSettingsPanelPO leaderboardSettingsPanelPO =
|
||||
// leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
// DetailCheckboxInfo[] selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
// Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
// leaderboardSettingsPanelPO.setRefreshInterval(2);
|
||||
// leaderboardSettingsDialog.pressMakeDefault();
|
||||
// leaderboardSettingsDialog.pressCancel();
|
||||
// Race details
|
||||
DetailCheckboxInfo.RACE_GAP_TO_LEADER, DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND,
|
||||
DetailCheckboxInfo.DISPLAY_LEGS,
|
||||
|
||||
// Leg Details
|
||||
DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
|
||||
// Maneuvers
|
||||
DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE, DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
|
||||
};
|
||||
|
||||
LeaderboardSettingsDialogPO leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
LeaderboardSettingsPanelPO leaderboardSettingsPanelPO = leaderboardSettingsDialog
|
||||
.getLeaderboardSettingsPanelPO();
|
||||
DetailCheckboxInfo[] selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
leaderboardSettingsPanelPO.setRefreshInterval(2);
|
||||
leaderboardSettingsDialog.pressMakeDefault();
|
||||
leaderboardSettingsDialog.pressCancel();
|
||||
|
||||
MapSettingsPO mapSettings = raceboard.openMapSettings();
|
||||
// Verify initial mode settings
|
||||
@@ -136,58 +129,38 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA, BMW_CUP_REGATTA,
|
||||
String.format(BMW_RACE, 1), "WINNING_LANES");
|
||||
|
||||
// detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// // Overall details
|
||||
//
|
||||
// // Race details
|
||||
// DetailCheckboxInfo.RACE_GAP_TO_LEADER, //merged from user settings
|
||||
// DetailCheckboxInfo.RACE_DISTANCE,
|
||||
// DetailCheckboxInfo.RACE_TIME,
|
||||
// DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND, //merged from user settings
|
||||
// DetailCheckboxInfo.RACE_AVERAGE_ABSOLUTE_CROSS_TRACK_ERROR,
|
||||
// DetailCheckboxInfo.RACE_AVERAGE_SIGNED_CROSS_TRACK_ERROR,
|
||||
//
|
||||
// // Race Start Analysis
|
||||
//
|
||||
// // Leg Details
|
||||
// DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
//
|
||||
// // Maneuvers
|
||||
// DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE,
|
||||
// DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
//
|
||||
// };
|
||||
//
|
||||
//
|
||||
// leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
// leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
// selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
// Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
//
|
||||
// detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// // Overall details
|
||||
//
|
||||
// // Race details
|
||||
// DetailCheckboxInfo.RACE_GAP_TO_LEADER,
|
||||
// DetailCheckboxInfo.RACE_DISTANCE,
|
||||
// DetailCheckboxInfo.RACE_TIME,
|
||||
// DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND,
|
||||
// DetailCheckboxInfo.RACE_RATIO_BETWEEN_TIME_SINCE_LAST_POSITION_FIX_AND_AVERAGE_SAMPLING_INTERVAL, //new value
|
||||
// DetailCheckboxInfo.DISPLAY_LEGS, //new value which should override mode settings
|
||||
//
|
||||
// // Race Start Analysis
|
||||
//
|
||||
// // Leg Details
|
||||
// DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
//
|
||||
// // Maneuvers
|
||||
// DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE,
|
||||
// DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
//
|
||||
// };
|
||||
// leaderboardSettingsPanelPO.selectDetailsAndDeselectOther(detailsToSelect);
|
||||
// leaderboardSettingsPanelPO.setRefreshInterval(1);
|
||||
// leaderboardSettingsDialog.pressOk();
|
||||
detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// Race details
|
||||
DetailCheckboxInfo.RACE_DISTANCE, DetailCheckboxInfo.RACE_TIME,
|
||||
DetailCheckboxInfo.RACE_AVERAGE_ABSOLUTE_CROSS_TRACK_ERROR,
|
||||
DetailCheckboxInfo.RACE_AVERAGE_SIGNED_CROSS_TRACK_ERROR,
|
||||
// Leg Details
|
||||
DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
// Maneuvers
|
||||
DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE, DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
|
||||
};
|
||||
|
||||
leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
|
||||
detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// Race details
|
||||
DetailCheckboxInfo.RACE_GAP_TO_LEADER, DetailCheckboxInfo.RACE_DISTANCE, DetailCheckboxInfo.RACE_TIME,
|
||||
DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND,
|
||||
DetailCheckboxInfo.RACE_RATIO_BETWEEN_TIME_SINCE_LAST_POSITION_FIX_AND_AVERAGE_SAMPLING_INTERVAL,
|
||||
DetailCheckboxInfo.DISPLAY_LEGS,
|
||||
// Leg Details
|
||||
DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
// Maneuvers
|
||||
DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE, DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
|
||||
};
|
||||
leaderboardSettingsPanelPO.selectDetailsAndDeselectOther(detailsToSelect);
|
||||
leaderboardSettingsPanelPO.setRefreshInterval(1);
|
||||
leaderboardSettingsDialog.pressOk(false, false);
|
||||
|
||||
mapSettings = raceboard.openMapSettings();
|
||||
// verify default mode settings override custom user settings
|
||||
@@ -209,16 +182,16 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA, BMW_CUP_REGATTA,
|
||||
String.format(BMW_RACE, 1), "WINNING_LANES");
|
||||
|
||||
// leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
// leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
// selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
//
|
||||
// //verify highest precedence of document settings
|
||||
// Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
// //verify that document settings are able to override custom user settings by a system default value
|
||||
// Assert.assertEquals(1, leaderboardSettingsPanelPO.getRefreshInterval());
|
||||
//
|
||||
// leaderboardSettingsDialog.pressCancel();
|
||||
leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
|
||||
// verify highest precedence of document settings
|
||||
Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
// verify that document settings are able to override custom user settings by a system default value
|
||||
Assert.assertEquals(1, leaderboardSettingsPanelPO.getRefreshInterval());
|
||||
|
||||
leaderboardSettingsDialog.pressCancel();
|
||||
|
||||
mapSettings = raceboard.openMapSettings();
|
||||
// Verify that mode settings are overridden by document settings
|
||||
@@ -228,35 +201,29 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
|
||||
//FIXME uncomment when START_ANALYSIS mode can be handled by remote CI server
|
||||
// verify that custom document settings override mode settings of other modes
|
||||
// raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA,
|
||||
// BMW_CUP_REGATTA,
|
||||
// String.format(BMW_RACE, 1), "START_ANALYSIS");
|
||||
// leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
// leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
// selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
//
|
||||
// detailsToSelect = new DetailCheckboxInfo[] {
|
||||
// DetailCheckboxInfo.RACE_GAP_TO_LEADER, //start analysis mode
|
||||
// DetailCheckboxInfo.RACE_CURRENT_SPEED_OVER_GROUND, //user settings
|
||||
// DetailCheckboxInfo.DISPLAY_LEGS, //document settings which override mode settings
|
||||
// DetailCheckboxInfo.RACE_RATIO_BETWEEN_TIME_SINCE_LAST_POSITION_FIX_AND_AVERAGE_SAMPLING_INTERVAL, //document settings
|
||||
// DetailCheckboxInfo.RACE_DISTANCE_TO_START_FIVE_SECONDS_BEFORE_START, //start analysis mode
|
||||
// DetailCheckboxInfo.RACE_SPEED_OVER_GROUND_FIVE_SECONDS_BEFORE_START, //start analysis mode
|
||||
// DetailCheckboxInfo.DISTANCE_TO_START_AT_RACE_START, //start analysis mode
|
||||
// DetailCheckboxInfo.SPEED_OVER_GROUND_AT_RACE_START, //start analysis mode
|
||||
// DetailCheckboxInfo.SPEED_OVER_GROUND_WHEN_STARTING, //start analysis mode
|
||||
// DetailCheckboxInfo.DISTANCE_TO_STARBOARD_END_OF_STARTLINE_WHEN_STARTING, //start analysis mode
|
||||
// DetailCheckboxInfo.START_TACK, //start analysis mode
|
||||
//
|
||||
// DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
//
|
||||
// DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE, DetailCheckboxInfo.PENALTY_CIRCLE
|
||||
// };
|
||||
// Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
// leaderboardSettingsDialog.pressCancel();
|
||||
//
|
||||
// mapSettings = raceboard.openMapSettings();
|
||||
// Assert.assertFalse(mapSettings.isWindUp());
|
||||
raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA, BMW_CUP_REGATTA,
|
||||
String.format(BMW_RACE, 1), "START_ANALYSIS");
|
||||
leaderboardSettingsDialog = raceboard.openLeaderboardSettingsDialog();
|
||||
leaderboardSettingsPanelPO = leaderboardSettingsDialog.getLeaderboardSettingsPanelPO();
|
||||
selectedDetails = leaderboardSettingsPanelPO.getSelectedDetails();
|
||||
|
||||
detailsToSelect = new DetailCheckboxInfo[] { DetailCheckboxInfo.RACE_GAP_TO_LEADER, // start analysis mode
|
||||
DetailCheckboxInfo.RACE_DISTANCE_TO_START_FIVE_SECONDS_BEFORE_START, // start analysis mode
|
||||
DetailCheckboxInfo.RACE_SPEED_OVER_GROUND_FIVE_SECONDS_BEFORE_START, // start analysis mode
|
||||
DetailCheckboxInfo.DISTANCE_TO_START_AT_RACE_START, // start analysis mode
|
||||
DetailCheckboxInfo.SPEED_OVER_GROUND_AT_RACE_START, // start analysis mode
|
||||
DetailCheckboxInfo.SPEED_OVER_GROUND_WHEN_STARTING, // start analysis mode
|
||||
DetailCheckboxInfo.DISTANCE_TO_STARBOARD_END_OF_STARTLINE_WHEN_STARTING, // start analysis mode
|
||||
DetailCheckboxInfo.START_TACK, // start analysis mode
|
||||
|
||||
DetailCheckboxInfo.AVERAGE_SPEED_OVER_GROUND, DetailCheckboxInfo.DISTANCE, DetailCheckboxInfo.RANK_GAIN,
|
||||
|
||||
DetailCheckboxInfo.TACK, DetailCheckboxInfo.JIBE, DetailCheckboxInfo.PENALTY_CIRCLE };
|
||||
Assert.assertArrayEquals(detailsToSelect, selectedDetails);
|
||||
leaderboardSettingsDialog.pressCancel();
|
||||
|
||||
mapSettings = raceboard.openMapSettings();
|
||||
Assert.assertTrue(mapSettings.isWindUp());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user