title: org.openqa.selenium.NoSuchElementException: Unable to locate a node using HtmlunitDriver/Phantomjs
body: <p>I am using HTMLUnitDriver. It is unable to locate the xpaths and css selectors</p>
  
  <pre><code>WebDriver d=new HtmlUnitDriver();
  WebDriverWait wait = new WebDriverWait(d, 10);
  // d.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
  d.get("http://www.google.com");
  //d.manage().window().maximize();
  d.findElement(By.name("q")).sendKeys("flipkart");
  d.findElement(By.name("btnG")).click();
  Thread.sleep(5000);
  String s1 = wait.until(
          ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='rhs_block']/ol/li/div[1]/div/div[1]/ol/li[2]/div/div[1]"))).getText();
  //String s1=d.findElement(By.cssSelector("div.kno-ecr-pt.kno-fb-ctx")).
  Assert.assertEquals(s1,"Flipkart");
  System.out.println(s1);
  d.close();
  d.quit();
  </code></pre>
  
  <p>It works Fine with all browser but not HTMLUNITDRIVER </p>
  
  <p>I read some posts saying that we need to give wait I tried with all the possible waits in selenium.</p>
  
  <p>I have tried with PhantomJS, but with the same issue of Unable to locate xpath.</p>
  
  <pre><code>File file = new File("C:/jars/phantomjs-2.0.0-windows/bin/phantomjs.exe");             
  System.setProperty("phantomjs.binary.path", file.getAbsolutePath());        
  WebDriver d = new PhantomJSDriver(); 
  
  //WebDriver d=new HtmlUnitDriver();
  WebDriverWait wait = new WebDriverWait(d, 10);
  d.get("http://www.google.com");
  //  d.manage().window().maximize();
  d.findElement(By.name("q")).sendKeys("flipkart");
  d.findElement(By.name("btnG")).click();
  Thread.sleep(5000);
  String s1 = wait.until(
          ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='rhs_block']/ol/li/div[1]/div/div[1]/ol/li[2]/div/div[1]"))).getText();
  //String s1=d.findElement(By.cssSelector("div.kno-ecr-pt.kno-fb-ctx")).
  Assert.assertEquals(s1,"Flipkart");
  System.out.println(s1);
  d.close();
  d.quit(); 
  </code></pre>