I have a table where each row will have a download link with a (partly) auto-generated id element. The reason for this is that the actual href-element will allways be \"#\",
Until you find the element first, you can't retrieve the attribute values of it.
Use findElements
method to fetch all links using the following locator
table tr td[class='journalTable-journalPost'] a
Then iterate through each element using for-each to fetch id for each element.
Sample code:
List listOfLinks = driver.findElements(By.cssSelector("table tr td[class='journalTable-journalPost'] a"));
for(WebElement link: listOfLinks) {
System.out.println("id:" + link.getAttribute("id"));
}