Merge branch 'bug4675' into bug4339

Conflicts:
	java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/PageObject.java
	java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/autoplay/AutoPlayLeaderboardView.java
	java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardTablePO.java
This commit is contained in:
Steffen Schaefer committed 2018-07-20 13:35:06 +02:00
commit 760eb92908
5 files changed
+43 -27

No files matched your search

@@ -634,4 +634,23 @@ public class PageObject {
scrollToView(webElement);
webElement.click();
}
public boolean isElementEntirelyVisible(WebElement element) {
try {
if (element.isDisplayed()) {
final int windowWidth = driver.manage().window().getSize().getWidth();
if (windowWidth >= element.getLocation().x
+ element.getSize().width) {
return true;
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
// The element may currently only partially visible which makes some of the calls fail
return false;
}
}
}
@@ -14,17 +14,13 @@ public class AutoPlayLeaderboardView extends PageArea {
super(driver, element);
}
public LeaderboardTablePO getLeaderBoard() {
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) {
try {
if (leaderboardCellTable.isDisplayed()) {
final int windowWidth = driver.manage().window().getSize().getWidth();
if (windowWidth >= leaderboardCellTable.getLocation().x
+ leaderboardCellTable.getSize().width) {
if (isElementEntirelyVisible(leaderboardCellTable)) {
return leaderboardCellTable;
} else {
return null;
@@ -32,17 +28,19 @@ public class AutoPlayLeaderboardView extends PageArea {
} else {
return null;
}
} catch (Exception e) {
// The element may currently only partially visible which makes some of the calls fail
// In this case it is necessary to wait for the next loop
return null;
}
} else {
return null;
}
});
LeaderboardTablePO leaderboardTablePO = new LeaderboardTablePO(this.driver, 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 new LeaderboardTablePO(this.driver, leaderboardCellTable);
return leaderboardTablePO;
}
}
@@ -11,7 +11,9 @@ import java.util.stream.Stream;
import org.openqa.selenium.By;
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.pages.PageArea;
import com.sap.sailing.selenium.pages.common.CSSConstants;
@@ -343,4 +345,13 @@ public abstract class CellTablePO<T extends DataEntryPO> extends PageArea {
return LOADING_ANIMATION_IMAGE.equals(image);
}
public void waitForTableToShowData() {
new WebDriverWait(driver, 30).until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return !getRows().isEmpty();
}
});
}
}
@@ -2,13 +2,11 @@ package com.sap.sailing.selenium.pages.leaderboard;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.sap.sailing.selenium.pages.common.CSSHelper;
import com.sap.sailing.selenium.pages.gwt.CellTablePO;
@@ -193,13 +191,4 @@ public class LeaderboardTablePO extends CellTablePO<LeaderboardEntry> {
private WebElement getExpansionButton(WebElement header) {
return header.findElement(By.xpath(EXPANSION_BUTTON_XPATH));
}
public void waitForLeaderboardToHaveData() {
new WebDriverWait(driver, 30).until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return !getRows().isEmpty();
}
});
}
}
@@ -117,8 +117,7 @@ public class TestAutoPlay extends AbstractSeleniumTest {
assertTrue("Url does not contain proper title " + url, url.contains("lbwh.saph.title=Leaderboard%3A+BMW+Cup+(J80)"));
assertTrue("Url does not contain proper name " + url, url.contains("name=BMW+Cup+(J80)"));
AutoPlayLeaderboardView autoplayPage = page.goToAutoPlayClassicUrl(getWebDriver(), url);
LeaderboardTablePO leaderBoard = autoplayPage.getLeaderBoard();
leaderBoard.waitForLeaderboardToHaveData();
LeaderboardTablePO leaderBoard = autoplayPage.getLeaderBoardWithData();
List<String> races = leaderBoard.getRaceNames();
Assert.assertTrue(races.contains("R1"));
Assert.assertTrue(races.contains("R2"));