title: org.openqa.selenium.TimeoutException when loading angular SPA
body: <p>I'm using <a href="https://github.com/xolvio/chimp">chimp.js</a> which enhances webdriver.io with some fibers magic so that the code can be defined in a synchronous way. This is the code:</p>
  
  <pre><code>var c = require('./config');
  
  module.exports = function () {
      this.When(/^I try to login with wrong credentials$/, function () {
          browser.setValue(userNameField, wrongUser);
          browser.setValue(passwordField, wrongPassword);
          browser.click('button[value="Login"]');
      });
      this.When(/^I try to login with the correct credentials$/, function () {
          browser.setValue(userNameField, c.userName);
          browser.setValue(passwordField, c.password);
          console.log('before pressig the button');
          browser.click('button[value="Login"]');
          console.log('logged in');
      });
  };
  </code></pre>
  
  <p>The first <code>When</code> executes just fine. The second <code>When</code> also works, I just don't get to see</p>
  
  <blockquote>
    <p>logged in</p>
  </blockquote>
  
  <p>on the console. Both run on the same website, and both click on the same button. In the second case, after the login succeeds, the browser is redirected to an angular SPA. Here everything loads up correctly, but that's it. The callback never happens.</p>
  
  <p>Running the tests with <code>--debug --log=command</code> I saw this to be the last line (before the timeout)</p>
  
  <pre><code>[1;30m[01:30:18]: [0m [0;35mCOMMAND [0mPOST      "/wd/hub/session/7c334efe-2417-4184-b43c-082ba4441291/element/11/click"
  </code></pre>
  
  <p>switching log-level to verbose, and waiting for ~5min I got the following error:</p>
  
  <pre><code>[chimp][selenium.stderr] 01:36:59.561 DEBUG - Executed: [0560aaa14e4cf874afd72336c19e299b, clickElement {id=0.6384125368203968-3}]
  
  [chimp][selenium.stderr] 01:37:02.449 WARN - Exception thrown
  org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: 10.000
    (Session info: chrome=47.0.2526.73)
    (Driver info: chromedriver=2.19.346063 (38b35413bd4a486d436a9749e090454bc9ff6708),platform=Mac OS X 10.11.0 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 310.12 seconds
  Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
  System info: host: '&lt;HOST_NAME&gt;', ip: '&lt;IP_ADDRESS&gt;', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_20'
  Driver info: org.openqa.selenium.chrome.ChromeDriver
  Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/nc/3cdxbvwj44j_gk1qj24mbr5w0000gn/T/.org.chromium.Chromium.1n3kHd}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=47.0.2526.73, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
  Session ID: 0560aaa14e4cf874afd72336c19e299b
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:332)
    at com.sun.proxy.$Proxy3.click(Unknown Source)
    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:345)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.openqa.selenium.remote.server.KnownElements$1.invoke(KnownElements.java:64)
    at com.sun.proxy.$Proxy2.click(Unknown Source)
    at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:30)
    at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
  
  [chimp][selenium.stderr] 01:37:02.458 WARN - Exception: timeout: Timed out receiving message from renderer: 10.000
    (Session info: chrome=47.0.2526.73)
    (Driver info: chromedriver=2.19.346063 (38b35413bd4a486d436a9749e090454bc9ff6708),platform=Mac OS X 10.11.0 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 310.12 seconds
  Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
  System info: host: '&lt;HOST_NAME&gt;', ip: '&lt;IP_ADDRESS&gt;', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11', java.version: '1.8.0_20'
  Driver info: org.openqa.selenium.chrome.ChromeDriver
  Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={userDataDir=/var/folders/nc/3cdxbvwj44j_gk1qj24mbr5w0000gn/T/.org.chromium.Chromium.1n3kHd}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=47.0.2526.73, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
  Session ID: 0560aaa14e4cf874afd72336c19e299b
  
  [chimp][selenium.stderr] 01:37:02.471 DEBUG - Finished: POST /session/e103e58b-7ac9-4c8d-8f65-1f60295231d9/element/11/click
  </code></pre>
  
  <p>It takes on average between 3-7s for the first page of the SPA to be loaded, data to be initialised, ... (chrome stops showing that the page is loading). The timeout is set to 10s so I thought to increase it, via</p>
  
  <pre><code>module.exports = function () {
      this.BeforeScenario(function () {
          browser.timeout('script', 60 * 1000);
          browser.timeout('page load', 60 * 1000);
      });
  };
  </code></pre>
  
  <p>but that didn't help either. Any idea what I could do / try?</p>
  
  <p>Just to clarify again - the login page is a simple static server-side rendered HTML. After the user is logged in, they are redirected to a SPA, which is based on Angular 1.4. Pressing the login button with wrong credentials works probably, because I don't get redirected to the SPA, but back to the login page. </p>
  
  <p>And all tests are run in chrome, on Mac OS X El Capitan</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Now it worked once. Afterwards I've noticed, that the script continues running, when I reload the website, in case it got stuck.</p>
  
  <p>The page here in question works this way:</p>
  
  <ul>
  <li><code>/</code> page is accessed and angular initialised</li>
  <li>ui-router routes to <code>#/defaultroute</code></li>
  <li>Controller gets initialised and downloads some initial data</li>
  <li>new controllers get initialised inside an <code>ng-repeat</code> and download even more data</li>
  </ul>
  
  <p>So yeah, its quite a bit of data downloading and waiting for the whole page to show up. Maybe that's causing troubles for chimp.js or webdriver.io?</p>
  
  <p>And of course, switching from <code>browser.click(...);</code> to <code>browser.key(['Enter']);</code> doesn't work either. The same problems with getting stuck and reloading the browser fixes it. It seems like silenium maybe doesn't get the the page actually finished loading. Which is why reloading the page fixes it. Any idea how to fix that?</p>
  
  <p>Btw, I've also opened an issue about this: <a href="https://github.com/xolvio/chimp/issues/165">https://github.com/xolvio/chimp/issues/165</a></p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>In Firefox and PhantomJS it works, Safari doesn't run at all.</p>
  
  <p>Maybe at this point I'd just like to know where the error is, if it's a known bug, ...</p>