mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-20 19:20:04 +00:00
Improved goToMethod for Raceboard to not require any test specific hard coded url
This commit is contained in:
1 parent
908f970634
commit
44cf0b17ad
2 files changed
+26
-8
No files matched your search
+20
-2
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.selenium.pages.raceboard;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
@@ -21,9 +23,14 @@ public class RaceBoardPage extends HostPageWithAuthentication {
|
||||
/**
|
||||
* Navigates to the given home URL and provides the corresponding {@link PageObject}.
|
||||
*
|
||||
* @param driver the {@link WebDriver} to use
|
||||
* @param url the desired destination URL
|
||||
* @param driver
|
||||
* the {@link WebDriver} to use
|
||||
* @param url
|
||||
* the desired destination URL
|
||||
* @return the {@link PageObject} for the home page
|
||||
*
|
||||
* Allows to use any url, because else some use cases for the RaceBoard are problematic to reach, for mor
|
||||
* generic cases, a more specialized goTo Version is recommended, to reduce hardcoded strings
|
||||
*/
|
||||
public static RaceBoardPage goToRaceboardUrl(WebDriver driver, String url) {
|
||||
// workaround for hostpage removing query from url, required for evenntid in this case
|
||||
@@ -45,5 +52,16 @@ public class RaceBoardPage extends HostPageWithAuthentication {
|
||||
});
|
||||
return new MapSettingsPO(driver, context.findElement(new BySeleniumId("raceMapSettings")));
|
||||
}
|
||||
|
||||
public static RaceBoardPage goToRaceboardUrl(WebDriver webDriver,String context, String leaderboardName, String regattaName,
|
||||
String raceName) throws UnsupportedEncodingException {
|
||||
// private static final String EVENT_LINK = "gwt/RaceBoard.html?leaderboardName=BMW+Cup+(J80)®attaName=BMW+Cup+(J80)&raceName=BMW+Cup+Race+1&canReplayDuringLiveRaces=true";
|
||||
String escapedLeaderBoardName = URLEncoder.encode(leaderboardName,"UTF-8");
|
||||
String escapedRegattaName = URLEncoder.encode(regattaName, "UTF-8");
|
||||
String escapedRaceName = URLEncoder.encode(raceName, "UTF-8");
|
||||
String url = context + "gwt/RaceBoard.html?leaderboardName=" + escapedLeaderBoardName + "®attaName="
|
||||
+ escapedRegattaName + "&raceName=" + escapedRaceName;
|
||||
return goToRaceboardUrl(webDriver, url);
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.selenium.test.raceboard;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
@@ -36,7 +37,6 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
private static final Date BMW_STOP_EVENT_TIME = DatatypeConverter.parseDateTime("2012-04-08T10:50:00-05:00")
|
||||
.getTime();
|
||||
|
||||
private static final String EVENT_LINK = "/gwt/RaceBoard.html?leaderboardName=BMW+Cup+(J80)®attaName=BMW+Cup+(J80)&raceName=BMW+Cup+Race+1&canReplayDuringLiveRaces=true";
|
||||
private static final String BMW_CUP_RACE_NAME = "R1";
|
||||
|
||||
private TrackableRaceDescriptor trackableRace;
|
||||
@@ -53,7 +53,7 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createRaceAsAdminSetWindSettingToTrue() throws InterruptedException {
|
||||
public void createRaceAsAdminSetWindSettingToTrue() throws InterruptedException, UnsupportedEncodingException {
|
||||
RegattaDescriptor bmwCupDescriptor = new RegattaDescriptor(BMW_CUP_EVENT, BMW_CUP_BOAT_CLASS);
|
||||
|
||||
AdminConsolePage adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
|
||||
@@ -72,18 +72,18 @@ public class SettingsTest extends AbstractSeleniumTest {
|
||||
// status FINISHED when done loading
|
||||
|
||||
LeaderboardConfigurationPanelPO leaderboard = adminConsole.goToLeaderboardConfiguration();
|
||||
Thread.sleep(1000);
|
||||
LeaderboardDetailsPanelPO details = leaderboard.getLeaderboardDetails(BMW_CUP_REGATTA);
|
||||
Thread.sleep(1000);
|
||||
Assert.assertTrue(details != null);
|
||||
details.linkRace(new RaceDescriptor(BMW_CUP_RACE_NAME, "Default", false, false, 0), trackedRace);
|
||||
|
||||
RaceBoardPage raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot() + EVENT_LINK);
|
||||
RaceBoardPage raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA,
|
||||
BMW_CUP_REGATTA, String.format(RACE, 1));
|
||||
MapSettingsPO mapSettings = raceboard.openMapSettings();
|
||||
mapSettings.setWindChart(true);
|
||||
mapSettings.makeDefault();
|
||||
// reload
|
||||
RaceBoardPage raceboard2 = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot() + EVENT_LINK);
|
||||
RaceBoardPage raceboard2 = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot(), BMW_CUP_REGATTA,
|
||||
BMW_CUP_REGATTA, String.format(RACE, 1));
|
||||
MapSettingsPO mapSettings2 = raceboard2.openMapSettings();
|
||||
boolean stillSelected = mapSettings2.isWindChartSelected();
|
||||
Assert.assertTrue(stillSelected);
|
||||
|
||||
Reference in new issue
Block a user