Merge branch 'bug4675' into bug4339

Conflicts:
	java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayLeaderboardView.java
This commit is contained in:
Steffen Schaefer committed 2018-07-20 16:41:41 +02:00
commit aa4614cc1b
3 files changed
+42 -33

No files matched your search

@@ -1,10 +1,7 @@
package com.sap.sailing.selenium.pages.autoplay;
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.pages.PageArea;
import com.sap.sailing.selenium.pages.leaderboard.LeaderboardTablePO;
@@ -15,32 +12,8 @@ public class AutoPlayLeaderboardView extends PageArea {
}
public LeaderboardTablePO getLeaderBoardWithData() {
WebElement leaderboardCellTable = new WebDriverWait(driver, 30).until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
WebElement leaderboardCellTable = findElementOrNullBySeleniumId("LeaderboardCellTable");
if (leaderboardCellTable != null) {
if (isElementEntirelyVisible(leaderboardCellTable)) {
return leaderboardCellTable;
} else {
return null;
}
} else {
return null;
}
}
});
LeaderboardTablePO leaderboardTablePO = new LeaderboardTablePO(this.driver, leaderboardCellTable);
LeaderboardTablePO leaderboardTablePO = new LeaderboardTablePO(this.driver, findElementBySeleniumId("LeaderboardCellTable"));
leaderboardTablePO.waitForTableToShowData();
// After the data is loaded it could be possible that the table isn't completely visible anymore
new WebDriverWait(driver, 30).until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver arg0) {
return isElementEntirelyVisible(leaderboardCellTable);
}
});
return leaderboardTablePO;
}
}
@@ -4,7 +4,9 @@ import java.io.UnsupportedEncodingException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
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.HostPage;
@@ -21,9 +23,6 @@ public class AutoPlayPage extends HostPage {
@FindBy(how = BySeleniumId.class, using = "AutoPlayStartView")
private WebElement autoPlayStartView;
@FindBy(how = BySeleniumId.class, using = "LeaderboardView")
private WebElement autoPlayLeaderboardView;
@FindBy(how = BySeleniumId.class, using = "IdleNextUpView")
private WebElement idleNextUpView;
@@ -76,7 +75,22 @@ public class AutoPlayPage extends HostPage {
public AutoPlayLeaderboardView goToAutoPlayClassicUrl(WebDriver driver, String url) {
driver.get(url); //$NON-NLS-1$
return new AutoPlayLeaderboardView(driver, autoPlayLeaderboardView);
final WebElement leaderboardViewElement = new WebDriverWait(driver, 30).until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
final WebElement leaderboardViewElement = findElementOrNullBySeleniumId("LeaderboardView");
if (leaderboardViewElement != null) {
if (isElementEntirelyVisible(leaderboardViewElement)) {
return leaderboardViewElement;
} else {
return null;
}
} else {
return null;
}
}
});
return new AutoPlayLeaderboardView(driver, leaderboardViewElement);
}
public AutoPlayUpcomingView goToAutoPlaySixtyInchUrl(WebDriver webDriver, String url) {
@@ -12,7 +12,10 @@ import javax.xml.bind.DatatypeConverter;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.google.common.base.Function;
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
@@ -118,7 +121,26 @@ public class TestAutoPlay extends AbstractSeleniumTest {
assertTrue("Url does not contain proper name " + url, url.contains("name=BMW+Cup+(J80)"));
AutoPlayLeaderboardView autoplayPage = page.goToAutoPlayClassicUrl(getWebDriver(), url);
LeaderboardTablePO leaderBoard = autoplayPage.getLeaderBoardWithData();
List<String> races = leaderBoard.getRaceNames();
final List<String> races = new WebDriverWait(getWebDriver(), 20).until(new Function<WebDriver, List<String>>() {
@Override
public List<String> apply(WebDriver arg0) {
try {
final List<String> races = leaderBoard.getRaceNames();
final List<String> result;
if (races != null && !races.isEmpty()) {
result = races;
} else {
// The table may seem to be empty while the leaderboard updates itself
result = null;
}
return result;
} catch (Exception e) {
// While the leaderboard updates its contents, errors may occur while reading data via selenium
// In this case we need to try this in the next loop again
return null;
}
}
});
Assert.assertTrue(races.contains("R1"));
Assert.assertTrue(races.contains("R2"));
Assert.assertTrue(races.contains("R3"));