title: Unable to click a href link using Selenium
body: <p>I have an HTML href link</p>
  
  <pre><code>&lt;a class="btn btn-icon-text btn-secondary" data-toggle="modal" data-target="#recordSharingDownloadModal" href="/person/mL7CD8tR59g2Cy2/health-record/sharing/media/clinical-summary/%7B7c-06-74-be-dc-67-47-5d-be-92-4c-58-5a-fd-1b-8f%7D/download-options/" title="Download Document"&gt;Download&lt;/a&gt;
  </code></pre>
  
  <p>using Selenium I need to click the link. Currently, I am using below code -</p>
  
  <pre><code>driver.findElement(By.xpath("//a[contains(@href='/person/mL7CD8tR59g2Cy2/health-record/sharing/media/clinical-summary/%7B7c-06-74-be-dc-67-47-5d-be-92-4c-58-5a-fd-1b-8f%7D/download-options/')]")).click();
  </code></pre>
  
  <p>But it is throwing an error </p>
  
  <blockquote>
    <p>"java.lang.NullPointerException"</p>
  </blockquote>
  
  <p>I have also tried to click the button using CssSelector but still the same error. I need to click a Download button under clinical summary section but there are multiple sections with the same button name. Only the HREF is unique.</p>
  
  <p>Can anyone please help me?</p>
  
  <p>The piece of code:</p>
  
  <pre><code>package LaunchIQHealth;
  
  import java.io.File;
  import java.io.IOException;
  import org.apache.commons.io.FileUtils;
  import org.openqa.selenium.By;
  import org.openqa.selenium.JavascriptExecutor;
  import org.openqa.selenium.OutputType;
  import org.openqa.selenium.TakesScreenshot;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.support.ui.*;
  
  public class AutomateIQHealth 
  {
      public static void main(String[] args) throws IOException, InterruptedException
      {
          System.setProperty("webdriver.chrome.driver", "C:\\Users\\abc\\Desktop\\chromedriver.exe");
          WebDriver driver = new ChromeDriver();
          WebDriverWait wait = new WebDriverWait(driver, 20);
              driver.get("url");
              ((JavascriptExecutor)driver).executeScript("scroll(0,400)").equals("Clinical Summaries");  
              wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), 'Download")));      
              driver.findElements(By.xpath("//a[@href='/person/mL7CD8tR59g2Cy2/health-record/sharing/media/clinical-summary/%7B7c-06-74-be-dc-67-47-5d-be-92-4c-58-5a-fd-1b-8f%7D/download-options/']")).get(0).click();
      }
  }
  </code></pre>