Capture the 18 images, click on one, use the captureScreen command to do the screen capture, go back to the main page and repeat.
But you’re going to have visually review the resulting screenshots and validate that they’re correct. The right way to test this would be to have a known data set and when you click one of the links, you would also have already captured images that would indicate whether the right page had loaded. Your script would look for the image of the correct page and log an error if it isn’t found. That’s the right way to validate the behavior of the application.
If you’re trying to test the data, then you’d do more what you asked about originally, but then I wouldn’t expect you to know what would be showing up on the main page either.
So what is the goal of your testing?