|
6 | 6 | import org.labkey.test.Locator; |
7 | 7 | import org.labkey.test.TestFileUtils; |
8 | 8 | import org.labkey.test.WebDriverWrapper; |
| 9 | +import org.labkey.test.categories.Base; |
9 | 10 | import org.labkey.test.components.ext4.Window; |
10 | 11 | import org.labkey.test.util.DataRegionTable; |
11 | 12 | import org.labkey.test.util.Ext4Helper; |
@@ -166,19 +167,29 @@ public static void waitForJBrowseToLoad(BaseWebDriverTest test) |
166 | 167 |
|
167 | 168 | public static long getTotalVariantFeatures(BaseWebDriverTest test) |
168 | 169 | { |
169 | | - Locator l = Locator.tagWithAttribute("svg", "data-testid", "svgfeatures").append(Locator.tag("polygon")); |
| 170 | + final Long winWidth = test.executeScript("return window.outerWidth", Long.class); |
| 171 | + final Long winHeight = test.executeScript("return window.outerHeight", Long.class); |
| 172 | + final Locator l = Locator.tagWithAttribute("svg", "data-testid", "svgfeatures").append(Locator.tag("polygon")); |
170 | 173 | try |
171 | 174 | { |
172 | 175 | // NOTE: JBrowse renders features using multiple blocks per track, and these tracks can redundantly render identical features on top of one another. |
173 | 176 | // Counting unique locations is indirect, but should result in unique features |
174 | | - return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getLocation).distinct().count(); |
| 177 | + return doVariantCount(test, l, winWidth, winHeight); |
175 | 178 | } |
176 | 179 | catch (StaleElementReferenceException e) |
177 | 180 | { |
178 | 181 | test.log("Stale elements, retrying"); |
179 | 182 | WebDriverWrapper.sleep(5000); |
180 | 183 |
|
181 | | - return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getLocation).distinct().count(); |
| 184 | + return doVariantCount(test, l, winWidth, winHeight); |
182 | 185 | } |
183 | 186 | } |
| 187 | + |
| 188 | + private static long doVariantCount(BaseWebDriverTest test, Locator l, long winWidth, long winHeight) |
| 189 | + { |
| 190 | + return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getRect).distinct().filter( |
| 191 | + // This is designed to limit to just elements within the viewport: |
| 192 | + rec -> rec.x > 0 & rec.x <= winWidth & rec.y > 0 & rec.y <= winHeight |
| 193 | + ).count(); |
| 194 | + } |
184 | 195 | } |
0 commit comments