Added initial selenium support for WindPanel

This commit is contained in:
Steffen Schaefer committed 2017-04-04 08:11:10 +02:00
1 parent 94f4d38fb5
commit c5f468ccc2
3 files changed
+74

No files matched your search

@@ -109,6 +109,8 @@ public class WindPanel extends FormPanel implements RegattasDisplayer, WindShowe
public WindPanel(final SailingServiceAsync sailingService, AsyncActionsExecutor asyncActionsExecutor, public WindPanel(final SailingServiceAsync sailingService, AsyncActionsExecutor asyncActionsExecutor,
ErrorReporter errorReporter, RegattaRefresher regattaRefresher, final StringMessages stringMessages) { ErrorReporter errorReporter, RegattaRefresher regattaRefresher, final StringMessages stringMessages) {
ensureDebugId("WindPanel");
this.sailingService = sailingService; this.sailingService = sailingService;
this.errorReporter = errorReporter; this.errorReporter = errorReporter;
this.stringMessages = stringMessages; this.stringMessages = stringMessages;
@@ -121,6 +123,7 @@ public class WindPanel extends FormPanel implements RegattasDisplayer, WindShowe
trackedRacesListComposite = new TrackedRacesListComposite(null, null, sailingService, errorReporter, trackedRacesListComposite = new TrackedRacesListComposite(null, null, sailingService, errorReporter,
regattaRefresher, regattaRefresher,
stringMessages, /*multiselection*/true, /* actionButtonsEnabled */ false); stringMessages, /*multiselection*/true, /* actionButtonsEnabled */ false);
trackedRacesListComposite.ensureDebugId("TrackedRacesListComposite");
mainPanel.add(trackedRacesListComposite); mainPanel.add(trackedRacesListComposite);
refreshableRaceSelectionModel = (RefreshableMultiSelectionModel<RaceDTO>) trackedRacesListComposite.getSelectionModel(); refreshableRaceSelectionModel = (RefreshableMultiSelectionModel<RaceDTO>) trackedRacesListComposite.getSelectionModel();
refreshableRaceSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { refreshableRaceSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@@ -268,7 +271,9 @@ public class WindPanel extends FormPanel implements RegattasDisplayer, WindShowe
final CheckBox correctByDeclination = new CheckBox(stringMessages.declinationCheckbox()); final CheckBox correctByDeclination = new CheckBox(stringMessages.declinationCheckbox());
correctByDeclination.setValue(true); // by default this is desirable because the Igtimi connector reads uncorrected magnetic values correctByDeclination.setValue(true); // by default this is desirable because the Igtimi connector reads uncorrected magnetic values
final Button importButton = new Button(stringMessages.importWindFromIgtimi()); final Button importButton = new Button(stringMessages.importWindFromIgtimi());
importButton.ensureDebugId("ImportWindFromIgtimi");
final HTML resultReport = new HTML(); final HTML resultReport = new HTML();
resultReport.ensureDebugId("IgtimiImportResultReport");
importButton.addClickHandler(new ClickHandler() { importButton.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
@@ -20,6 +20,7 @@ import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManag
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesCompetitorsPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesCompetitorsPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesManagementPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanelPO; import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.wind.WindPanelPO;
/** /**
* <p>The page object representing the administration console. The console consists of multiple tabs with its content * <p>The page object representing the administration console. The console consists of multiple tabs with its content
@@ -53,6 +54,9 @@ public class AdminConsolePage extends HostPageWithAuthentication {
private static final String TRACKED_RACES_TAB_LABEL = "Tracked races"; //$NON-NLS-1$ private static final String TRACKED_RACES_TAB_LABEL = "Tracked races"; //$NON-NLS-1$
private static final String TRACKED_RACES_TAB_IDENTIFIER = "TrackedRacesManagement"; //$NON-NLS-1$ private static final String TRACKED_RACES_TAB_IDENTIFIER = "TrackedRacesManagement"; //$NON-NLS-1$
private static final String WIND_TAB_LABEL = "Wind"; //$NON-NLS-1$
private static final String WIND_TAB_IDENTIFIER = "WindPanel"; //$NON-NLS-1$
private static final String LEADERBOARD_CONFIGURATION_TAB_PARENT_LABEL = "Leaderboards"; //$NON-NLS-1$ private static final String LEADERBOARD_CONFIGURATION_TAB_PARENT_LABEL = "Leaderboards"; //$NON-NLS-1$
private static final String LEADERBOARD_CONFIGURATION_TAB_PARENT_IDENTIFIER = "LeaderboardPanel"; //$NON-NLS-1$ private static final String LEADERBOARD_CONFIGURATION_TAB_PARENT_IDENTIFIER = "LeaderboardPanel"; //$NON-NLS-1$
@@ -127,6 +131,12 @@ public class AdminConsolePage extends HostPageWithAuthentication {
TRACKED_RACES_TAB_IDENTIFIER, false)); TRACKED_RACES_TAB_IDENTIFIER, false));
} }
public WindPanelPO goToWind() {
goToTab(TRACKED_RACES_TAB_PARENT_LABEL, TRACKED_RACES_TAB_PARENT_IDENTIFIER, true);
return new WindPanelPO(this.driver, goToTab(WIND_TAB_LABEL,
WIND_TAB_IDENTIFIER, false));
}
public LeaderboardConfigurationPanelPO goToLeaderboardConfiguration() { public LeaderboardConfigurationPanelPO goToLeaderboardConfiguration() {
goToTab(LEADERBOARD_CONFIGURATION_TAB_PARENT_LABEL, LEADERBOARD_CONFIGURATION_TAB_PARENT_IDENTIFIER, true); goToTab(LEADERBOARD_CONFIGURATION_TAB_PARENT_LABEL, LEADERBOARD_CONFIGURATION_TAB_PARENT_IDENTIFIER, true);
return new LeaderboardConfigurationPanelPO(this.driver, goToTab(LEADERBOARD_CONFIGURATION_TAB_LABEL, return new LeaderboardConfigurationPanelPO(this.driver, goToTab(LEADERBOARD_CONFIGURATION_TAB_LABEL,
@@ -0,0 +1,59 @@
package com.sap.sailing.selenium.pages.adminconsole.wind;
import org.openqa.selenium.Alert;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.FluentWait;
import com.google.common.base.Function;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.PageArea;
public class WindPanelPO extends PageArea {
@FindBy(how = BySeleniumId.class, using = "ImportWindFromIgtimi")
private WebElement importWindFromIgtimi;
@FindBy(how = BySeleniumId.class, using = "IgtimiImportResultReport")
private WebElement igtimiImportResultReport;
public WindPanelPO(WebDriver driver, WebElement element) {
super(driver, element);
}
public void importWindFromIgtimi() throws InterruptedException {
importWindFromIgtimi.click();
int i = 0;
while (i < DEFAULT_WAIT_TIMEOUT_SECONDS) {
i++;
try {
Alert alert = driver.switchTo().alert();
alert.accept();
break;
} catch (NoAlertPresentException e) {
Thread.sleep(1000);
continue;
}
}
if (i >= DEFAULT_WAIT_TIMEOUT_SECONDS) {
throw new NoAlertPresentException();
}
FluentWait<String> wait = createFluentWait("The following number of fixes were imported for the listed races:", /* waiting 10 minutes at most */ 10 * 60, DEFAULT_POLLING_INTERVAL);
wait.until(new Function<String, Object>() {
@Override
public Object apply(String message) {
try {
String statusText = igtimiImportResultReport.getText();
return statusText.contains(message);
} catch (TimeoutException exception) {
return Boolean.FALSE;
}
}
});
}
}