mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
Bug 4339: In AutoPlay test wait for the leaderboard to be completely
visible (animation) to make further checks to not fail due to parts being invisible
This commit is contained in:
1 parent
3ed22654e7
commit
cfd87fcf33
2 files changed
+69
-1
No files matched your search
@@ -317,6 +317,45 @@ public class PageObject {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Finds and returns the first element with the specified selenium id in the given search context. If multiple
|
||||
* elements exists, the first found element is returned. If no matching element can be found, {@code null} is
|
||||
* returned.
|
||||
* </p>
|
||||
*
|
||||
* @param context
|
||||
* The search context to use for the search.
|
||||
* @param id
|
||||
* The selenium id of the element.
|
||||
* @return The first matching element in the given context.
|
||||
*/
|
||||
protected WebElement findElementOrNullBySeleniumId(SearchContext context, String id) {
|
||||
final List<WebElement> elements = context.findElements(new BySeleniumId(id));
|
||||
WebElement result;
|
||||
if (elements.isEmpty()) {
|
||||
result = null;
|
||||
} else {
|
||||
result = elements.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Finds and returns the first element with the specified selenium id in the given search context. If multiple
|
||||
* elements exists, the first found element is returned. If no matching element can be found, {@code null} is
|
||||
* returned.
|
||||
* </p>
|
||||
*
|
||||
* @param id
|
||||
* The selenium id of the element.
|
||||
* @return The first matching element in the given context.
|
||||
*/
|
||||
protected WebElement findElementOrNullBySeleniumId(String id) {
|
||||
return findElementOrNullBySeleniumId(this.context, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Finds and returns the first element with the specified selenium id in the given search context. If multiple
|
||||
* elements exists, the element closest to the context is returned.</p>
|
||||
|
||||
+30
-1
@@ -2,7 +2,9 @@ package com.sap.sailing.selenium.pages.autoplay;
|
||||
|
||||
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.leaderboard.LeaderboardTablePO;
|
||||
|
||||
@@ -12,7 +14,34 @@ public class AutoPlayLeaderboardView extends PageArea {
|
||||
}
|
||||
|
||||
public LeaderboardTablePO getLeaderBoard() {
|
||||
return new LeaderboardTablePO(this.driver, waitForElementBySeleniumId(driver, "LeaderboardCellTable", 20));
|
||||
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) {
|
||||
return leaderboardCellTable;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new LeaderboardTablePO(this.driver, leaderboardCellTable);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user