The Selenium website has an example of how to do something similar to this from Java (using Firefox as the browser) at http://www.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example
Here's a quick TL;DR version. It doesn't click through to Stack Overflow but instead should take a screenshot of the Google results for that term. Going via Google when you already know the URL of the site may be a redundant step anyway, I am sure you can modify this example to make it do what you need it to.
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Stack Overflow");
element.submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("Stack Overflow");
}
});
// Screenshot of search results (screen not whole page)
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\screenshot.png"));
Screenshot code is from Sergii Pozharov's answer at Take a screenshot with Selenium WebDriver - see that for other considerations such as choice of driver.