Selenium: How can i say to Selenium to wait for a button element?
<p>I have one verification button which have some delay after I click on it (after I click it shows me a grid with elements) and then appears a <code>NEXT</code> button which redirects to the next page. I have this code:</p>

<pre><code>((JavascriptExecutor)driver).executeScript("arguments[0].click()",driver.findElement(By.cssSelector("div#button-verify-wrapper &gt; a")));
Thread.sleep(18000);
driver.findElement(By.xpath(".//*[@id='select-a-data-source-footer']/div/div/a")).click();
Thread.sleep(5000);
</code></pre>

<p>But I want to procced to click on the <code>NEXT</code> button, after all the grid charge (it takes a while depends on the server at that moment), because the next button just appear after the grid appears.</p>

<p>Are there selenium sentences to do it?</p>