selenium web driver wait until page to refresh
<p>Below is the code snippet of my selenium test case, where i use select method to choose a value from the drop down . And the next step would be clicking on the submit . But by the time i try to click on the submit button the page is not refreshed(which will refresh the same page), throwing </p>

<blockquote>
  <p>element not clickable,StaleElementReference exception</p>
</blockquote>

<p>. The only solution which works for me is <code>thread.sleep()</code>. </p>

<p>I tried all the below options but had no luck :(</p>

<p><code>explicit wait()</code>,<code>wait.until(Exceptedcontions.visibility)</code>,<code>element to be clickable()</code> etc , tried all the solutions on th web . </p>

<p>I had to use <code>thread.sleep()</code> 3-4 times in a test case and i have around 100 test cases which is costing a lot of time . </p>

<p>Any working solutions where the web driver waits until the page gets completely refreshed and DOM loads completely before clicking on the submit button. </p>

<pre><code>@Test
@Timeout(group = Group.SLOW)
public void testProvider() throws InterruptedException {

    proceedToProvider();
    new Select(driver.findElement(By.id("searchId"))).selectByVisibleText("Search");
    Thread.sleep(2000);
    driver.findElement(By.id("btnSubmit")).click();
    timeSplit("Search submitted");
</code></pre>

<p>Below is the error i see when i use other solutions.</p>

<blockquote>
  <p>org.openqa.selenium.WebDriverException: unknown error: Element is not
  clickable at point (1289, 141). Other element would receive the click:
  
  (Session info: chrome=53.0.2785.116)   (Driver info:
  chromedriver=2.21.371459
  (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1
  x86_64) (WARNING: The server did not provide any stacktrace
  information) Command duration or timeout: 168 milliseconds Build info:
  version: '2.49.1', revision:
  '808c23b0963853d375cbe54b90bbd052e2528a54', time: '2016-01-21
  09:37:52' System info: host: 'ALAKASIMA01-W7L', ip: '10.145.45.233',
  os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1',
  java.version: '1.8.0_73' Driver info:
  org.openqa.selenium.remote.RemoteWebDriver Capabilities
  [{applicationCacheEnabled=false, rotatable=false,
  mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459
  (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),
  userDataDir=C:\Users\kasima01\AppData\Local\Temp\scoped_dir6628_12218},
  takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
  hasTouchScreen=false, version=53.0.2785.116, platform=XP,
  browserConnectionEnabled=false, nativeEvents=true,
  acceptSslCerts=true, locationContextEnabled=true,
  webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
  javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID:
  8bf0b4cc7efc715015509f4be345d14d</p>
</blockquote>