title: Selenium webdriver click google search
body: <p>I'm searching text "Cheese!" on google homepage and unsure how can I can click on the searched links after pressing the search button. For example I wanted to click the third link from top on search page then how can I find identify the link and click on it. My code so far:</p>
  
  <pre><code>package mypackage;
  
  import org.openqa.selenium.By; 
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement; 
  import org.openqa.selenium.support.ui.ExpectedCondition;
  import org.openqa.selenium.chrome.ChromeDriver; 
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  public class myclass {
  
      public static void main(String[] args) {
  
          System.setProperty("webdriver.chrome.driver", "C:\\selenium-java-2.35.0\\chromedriver_win32_2.2\\chromedriver.exe");
  
           WebDriver driver = new ChromeDriver(); 
           driver.get("http://www.google.com"); 
           WebElement element = driver.findElement(By.name("q"));
           element.sendKeys("Cheese!");
           element.submit();
  
           //driver.close();
      }
  
  
  
  }
  </code></pre>