// Available variables:
// WebDriver driver, selenium driver instance, can manipulate the page at will
// List<String> discoveredUrls, insert all the URLs to process here
// ALogger logger, aspire logger, for debug purposes
// Get a list of all the <a /> elements
driver.findElements(By.tagName("a")).each { item ->
String link = item.getAttribute("href");
if (link == null || link == "")
link = url.getAttribute("src");
logger.info("Current url %s, discovered %s", driver.getCurrentUrl(), link);
discoveredUrls.add(link);
}
logger.info("Current url %s, discovery complete", driver.getCurrentUrl()); |