title: Java selenium how to open a link from google search results?
body: <p>I am new to automation testing in Selenium and i am doing some basic automation testing such as searching for something in Google and then clicking on a link which is required from the search results. </p>
  
  <p>The code below, which i have produced works up until i get to the testing method. I am unable to select a link from the Google search page but i am not being shown any errors on my console. So i setup a thread on this particular line and it mentioned it could find the link name however the link name is used in the html code as i have checked on Google inspect. </p>
  
  <p>Am i missing something obvious? I am relatively new to Selenium so any help is appreciated. Also i have tried mirroring some code from this users response <em>"<a href="https://stackoverflow.com/questions/33559296/how-to-click-a-link-by-text-in-selenium-web-driver-java">How to click a link by text in Selenium web driver java</a>"</em> but no luck!</p>
  
  <p>Thanks</p>
  
  <pre class="lang-java prettyprint-override"><code>    package com.demo.testcases;
  
  
  
  
  
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.Keys;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  
  
  
  
  public class MyFirstTestScript {
  
  private static WebDriver driver;
  
  
  public static void main (String[] args)  {
  
      SetUp();
      testing();
  
  
  
  }
  
  // TODO Auto-generated method stub
  
  
  @setup
  
      public static void SetUp () {
  
      driver = new FirefoxDriver();
      driver.get("http://www.google.co.uk");
      System.setProperty("webdriver.gecko.driver", "usr/local/bin/geckodriver");
      driver.findElement(By.name("q")).sendKeys("BBC" + Keys.ENTER);
  }   
  @Test
          public static void testing()  {
  
      driver.findElement(By.partialLinkText("BBC - Home")).click();
  
  
  }
  }
  </code></pre>