title: How to navigate and click a button on a web page using Selenium WebDriver?
body: <p>I have an issue navigating a "SEARCH" button using Selenium. I need to click a "Search" button then come back to the initial page and click it again. My code navigates this button and clicks it perfectly fine <strong><em>the first time</em></strong>, then the web page comes back to the initial URL. Then it supposed to navigate the same button again, however, it does not work...I used many different ways (xpath etc.) What is the problem here? Here is my FULL code. One may copy-paste it to eclipse and see what I am talking about:</p>
  
  <pre><code>     import java.util.concurrent.TimeUnit;
       import org.openqa.selenium.By;
       import org.openqa.selenium.WebDriver;
       import org.openqa.selenium.WebElement;
       import org.openqa.selenium.chrome.ChromeDriver;
  
       public class Search {
  
  public static void main(String[] args) throws InterruptedException {
  
      System.setProperty("webdriver.chrome.driver",
              "chromedriver\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
  
      // Getting the initial page
      driver.get("http://pqasb.pqarchiver.com/chicagotribune/advancedsearch.html");
      driver.findElement(By.xpath("//input[@value='historic']")).click();
      WebElement element = driver.findElement(By.name("QryTxt"));
      element.sendKeys("issue");
      driver.findElement(
              By.xpath("//input[@value='Search'][@onclick='return checkinput(this.form, 0);'][@type='button']"))
              .click();
  
      // Getting back to the initial page
      driver.get("http://pqasb.pqarchiver.com/chicagotribune/advancedsearch.html");
      driver.findElement(
              By.xpath("//input[@value='Search'][@onclick='return checkinput(this.form, 0);'][@type='button']"))
              .click();
      /**
       * This command does not execute. It is supposed to click on the button
       * "SEARCH" It worked well in the above identical code line, however now
       * it just does not recognize the existence of this button How can I
       * overcome this issue? I tried navigating this button by all different
       * means (xpath etc...)
       */
  }
  
       }
  </code></pre>