title: Opening a href link in Selenium Java
body: <p>I am trying to click on the following a href link in selenium. I have tried using xpath and <code>By.linkText()</code> and <code>By.cssSelectort()</code> but I have not be able to locate the element. Any help is much appreciated</p>
  
  <pre><code>driver.findElement(By.linkText("CCC_PH3_Sandbox_Keybridge: CCC PH3 Sandbox Keybridge")).click();
  </code></pre>
  
  <p>and <code>By.xpath()</code> but its unable to locate the element</p>
  
  <pre><code>WebElement course = driver.findElementByXPath("html/body/table/tbody/tr/td/div/div[2]/table/tbody/tr/td[3]/a/span[1]");
  course.click();
  </code></pre>
  
  <p><strong>css locator :</strong></p>
  
  <pre><code>driver.findElement(By.cssSelector("a[href*='/webapps/portal']")).click();
  </code></pre>
  
  <p>Here is the <strong>html snippet:</strong></p>
  
  <pre><code>&lt;img width="12" height="12" src="/images/ci/icons/bookopen_li.gif" alt=""&gt;
  &lt;a target="_top" href=" /webapps/portal/frameset.jsp?tab_tab_group_id=_2_1&amp;url=%2Fwebapps%2Fblackboard%2Fexecute%2Flauncher%3Ftype%3DCourse%26id%3D_2135_1%26url%3D"&gt;CCC_PH3_Sandbox_Keybridge: CCC PH3 Sandbox Keybridge&lt;/a&gt;
  </code></pre>