title: Googling in Selenium WebDriver, trying to verify result; result comes back as false when true
body: <p>I am attempting to write a Selenium WebDriver test that navigates to Google, searches for something, and then verifies that Google has searched for what was typed in. However, the below code gives a "false" output, when I can see that it is true.</p>
  
  <p>All of the code that I can find for this scenario seem to be pre-Google Instant, and I cannot make Instant stay turned off in FirefoxDriver. It should also be waiting for the bar with Web, Images, Video etc. to be clickable before checking anything; increasing the implicitlyWait value does not seem to have any effect on how the test plays out, or its final result. Switching between verifyTrue and assertTrue does not change the result.</p>
  
  <p>I apologise if the answer is obvious, but I'm relatively new to Selenium WebDriver (and Java).</p>
  
  <pre><code>package mypackage;
  
  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;
  import java.util.concurrent.TimeUnit;
  
  public class NavigateSearchVerify {
  
      public static void main(String[] args) {
  
          WebDriver driver = new FirefoxDriver();
          String baseUrl = "http://www.google.com";
          driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
  
          driver.get(baseUrl);
  
          WebElement query = driver.findElement(By.name("q"));
          query.sendKeys("Hello");
          query.sendKeys(Keys.ENTER);
  
          WebDriverWait wait = new WebDriverWait(driver, 15);
          wait.until(ExpectedConditions.elementToBeClickable(By.id("top_nav")));
  
          Boolean assertTrue = driver.findElements(By.className("gbqfif")).contains("Hello");
          if (assertTrue == true) {
              System.out.print("Yes");
          } else {
              System.out.print("No");
          }    
      }    
  }
  </code></pre>