mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 20:25:31 +00:00
Bug 4339: Fixed session handling for multi window setup
This commit is contained in:
+4
-4
@@ -105,12 +105,12 @@ public abstract class AbstractSeleniumTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUpAuthenticatedSession() {
|
||||
protected void setUpAuthenticatedSession(WebDriver webDriver) {
|
||||
logger.info("Authenticating session...");
|
||||
Cookie sessionCookie = authenticate(getContextRoot());
|
||||
getWebDriver().get(getContextRoot() + "index.html"); // initialize web driver so setting a cookie for the local domain is possible
|
||||
webDriver.get(getContextRoot() + "index.html"); // initialize web driver so setting a cookie for the local domain is possible
|
||||
final Cookie cookieWithoutDomain = new Cookie(sessionCookie.getName(), sessionCookie.getValue(), null, sessionCookie.getPath(), sessionCookie.getExpiry(), sessionCookie.isSecure(), sessionCookie.isHttpOnly());
|
||||
getWebDriver().manage().addCookie(cookieWithoutDomain);
|
||||
webDriver.manage().addCookie(cookieWithoutDomain);
|
||||
logger.info("...obtained session cookie "+sessionCookie);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public abstract class AbstractSeleniumTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() {
|
||||
setUpAuthenticatedSession();
|
||||
setUpAuthenticatedSession(getWebDriver());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-2
@@ -72,8 +72,10 @@ public class TestRefreshableSelectionModel extends AbstractSeleniumTest {
|
||||
@Test
|
||||
public void testMaintenanceOfSelectionAfterDataChanges() {
|
||||
this.environment.getWindowManager().withExtraWindow((windowForSelection, windowForEdit) -> {
|
||||
final WebDriver windowForEditDriver = windowForEdit.switchToWindow();
|
||||
setUpAuthenticatedSession(windowForEditDriver);
|
||||
final TrackedRacesCompetitorsPanelPO competitorsPanel = goToCompetitorsPanel(
|
||||
windowForEdit.switchToWindow());
|
||||
windowForEditDriver);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
TrackedRacesCompetitorEditDialogPO dialog = competitorsPanel.pushAddCompetitorButton();
|
||||
@@ -216,7 +218,9 @@ public class TestRefreshableSelectionModel extends AbstractSeleniumTest {
|
||||
assertEquals(5, anzRaceColumns);
|
||||
|
||||
// Open a second window & setup second window
|
||||
AdminConsolePage adminConsoleForEdit = AdminConsolePage.goToPage(windowForEdit.switchToWindow(), getContextRoot());
|
||||
final WebDriver windowForEditDriver = windowForEdit.switchToWindow();
|
||||
setUpAuthenticatedSession(windowForEditDriver);
|
||||
AdminConsolePage adminConsoleForEdit = AdminConsolePage.goToPage(windowForEditDriver, getContextRoot());
|
||||
RegattaStructureManagementPanelPO regattaStructure = adminConsoleForEdit.goToRegattaStructure();
|
||||
|
||||
RegattaDetailsCompositePO regattaDetails = regattaStructure.getRegattaDetails(this.regatta);
|
||||
|
||||
+10
-3
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
|
||||
@@ -80,7 +81,9 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
assertThat(races.size(), equalTo(5));
|
||||
assertThat(table.getEntries().size(), equalTo(28)); // the regatta already has the races linked; regatta leaderboard obtains competitors from regatta
|
||||
|
||||
AdminConsolePage adminConsole = AdminConsolePage.goToPage(adminConsoleWindow.switchToWindow(), getContextRoot());
|
||||
final WebDriver adminConsoleWindowDriver = leaderboardWindow.switchToWindow();
|
||||
setUpAuthenticatedSession(adminConsoleWindowDriver);
|
||||
AdminConsolePage adminConsole = AdminConsolePage.goToPage(adminConsoleWindowDriver, getContextRoot());
|
||||
LeaderboardConfigurationPanelPO leaderboardConfiguration = adminConsole.goToLeaderboardConfiguration();
|
||||
LeaderboardDetailsPanelPO leaderboardDetails = leaderboardConfiguration.getLeaderboardDetails(this.regatta.toString());
|
||||
|
||||
@@ -121,7 +124,9 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
leaderboardDetails.linkRace(this.leaderboardRaces.get(3), this.trackedRaces.get(3));
|
||||
leaderboardDetails.linkRace(this.leaderboardRaces.get(4), this.trackedRaces.get(4));
|
||||
// Open the leaderboard in our second window
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindow.switchToWindow(), getContextRoot(), LEADERBOARD, false);
|
||||
final WebDriver leaderboardWindowDriver = leaderboardWindow.switchToWindow();
|
||||
setUpAuthenticatedSession(leaderboardWindowDriver);
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindowDriver, getContextRoot(), LEADERBOARD, false);
|
||||
LeaderboardTablePO table = leaderboard.getLeaderboardTable();
|
||||
// Go back to the administration console and delete third race
|
||||
adminConsoleWindow.switchToWindow();
|
||||
@@ -156,7 +161,9 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest {
|
||||
leaderboardDetails.linkRace(this.leaderboardRaces.get(4), this.trackedRaces.get(4));
|
||||
|
||||
// Open the leaderboard in our second window
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindow.switchToWindow(), getContextRoot(), LEADERBOARD, false);
|
||||
final WebDriver leaderboardWindowDriver = leaderboardWindow.switchToWindow();
|
||||
setUpAuthenticatedSession(leaderboardWindowDriver);
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindowDriver, getContextRoot(), LEADERBOARD, false);
|
||||
LeaderboardTablePO table = leaderboard.getLeaderboardTable();
|
||||
|
||||
// Go back to the administration console and rename the first race
|
||||
|
||||
+4
-1
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
|
||||
@@ -61,7 +62,9 @@ public class TestSwitchingOffStartOfRaceInference extends AbstractSeleniumTest {
|
||||
@Test
|
||||
public void testCorrectDisplayOfRaceColumnWithAndWithoutStartTimeInference() {
|
||||
this.environment.getWindowManager().withExtraWindow((adminConsoleWindow, leaderboardWindow) -> {
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindow.switchToWindow(), getContextRoot(), LEADERBOARD, /* race details */ false);
|
||||
final WebDriver leaderboardWindowDriver = leaderboardWindow.switchToWindow();
|
||||
setUpAuthenticatedSession(leaderboardWindowDriver);
|
||||
LeaderboardPage leaderboard = LeaderboardPage.goToPage(leaderboardWindowDriver, getContextRoot(), LEADERBOARD, /* race details */ false);
|
||||
LeaderboardTablePO leaderboardTable = leaderboard.getLeaderboardTable();
|
||||
List<String> races = leaderboardTable.getRaceNames();
|
||||
assertThat("Expected only D3", races, equalTo(Arrays.asList("D3")));
|
||||
|
||||
Reference in New Issue
Block a user