Skip to content

Commit ea28d70

Browse files
committed
comments
1 parent 8f917f6 commit ea28d70

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ehr/test/src/org/labkey/test/tests/ehr/AbstractGenericEHRTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,21 @@ private String validLink(WebElement anchor)
415415
private void validatePageLinks(Set<String> crawledLinks)
416416
{
417417
log("Validating links on " + getURL());
418+
419+
// Find all anchors in the body content area, excluding buttons and those in data regions
418420
List<WebElement> anchors = getDriver().findElements(By.xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' lk-body-ct ')]//a[not(ancestor::form[@data-region-form]) and not(@role='button') and not(contains(@class, 'labkey-button'))]"));
419421

420422
log(anchors.size() + " possible links found.");
421423
int validatedCount = 0;
422424
Set<String> validLinksOnPage = new HashSet<>();
423425
for (WebElement anchor : anchors)
424426
{
427+
// Only validate links once
425428
String href = anchor.getDomAttribute("href");
426429
if (href != null && validLinksOnPage.contains(href))
427430
continue;
428431

432+
// Validate and record valid links
429433
String validUrl = validLink(anchor);
430434
if (validUrl != null)
431435
{
@@ -436,6 +440,7 @@ private void validatePageLinks(Set<String> crawledLinks)
436440
}
437441
log(validatedCount + " links validated.");
438442

443+
// Recursively crawl valid links that have not yet been crawled and aren't listed as a skip.
439444
for (String s : validLinksOnPage)
440445
{
441446
if (!crawledLinks.contains(s) && skipLinksForCrawling().stream().noneMatch(link -> s.toLowerCase().contains(link.toLowerCase())))

0 commit comments

Comments
 (0)