mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-09 12:31:00 +00:00
Merge branch 'bug4675' into bug4339
Conflicts: java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardTablePO.java
This commit is contained in:
commit
0b02783cb3
3 files changed
+70
-2
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);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -198,7 +198,7 @@ public class LeaderboardTablePO extends CellTablePO<LeaderboardEntry> {
|
||||
new WebDriverWait(driver, 30).until(new Function<WebDriver, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(WebDriver driver) {
|
||||
return !getEntries().isEmpty();
|
||||
return !getRows().isEmpty();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user