title: Implicit waiting in E2E tests for Angular application
body: <p>I have E2E tests (using Selenium WebDriver) for an Angular 4/ASP.NET Core Web API application.</p>
  
  <p>I am suffering from occasional timeout/wait issues within some of the tests.</p>
  
  <p>The E2E framework has a method WaitForAngular() which uses some Javascript (taken from Protractor) that waits for Angular to indicate it has loaded all 'testabilities' before continuing (see <a href="https://stackoverflow.com/a/39349865/95423">https://stackoverflow.com/a/39349865/95423</a>)</p>
  
  <p>However this doesn't seem totally reliable and occasionally on a run we end up with indefinite waits occurring.</p>
  
  <p>The other approach we use is implicit waits for the element in question to be rendered:</p>
  
  <pre><code>var url = "targetURL"
  Driver.Instance.Navigate().GoToUrl(url);
  
  var waitSeconds = 15;
  var navWait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(waitSeconds))
  {
      Message = $"The targetURL failed to load in {waitSeconds} seconds"
  };
  
  navWait.Until(x =&gt; x.FindElementById(targetUrlId) != null || x.FindElementById(forbiddenId) != null);
  </code></pre>
  
  <p>I'm seeing more robust results from the second approach, however it means more code and potentially more brittle tests if the condition of the implicit wait is not carefully considered.</p>
  
  <p>Which is the better approach here, or is there an alternative?</p>