title: How to disable promise manager in selenium-webdriver
body: <p>As detailed in <a href="https://code.google.com/p/selenium/wiki/WebDriverJs#Promises" rel="nofollow">https://code.google.com/p/selenium/wiki/WebDriverJs#Promises</a>, <code>selenium-webdriver</code> uses an automatic promise manager to keep people from having to do repetitive promise chaining.</p>
  
  <p>However, in some cases the assumption made by the promise manager, that successive calls should be chained is wrong, and it should be deactivated.</p>
  
  <p>An example would be:</p>
  
  <pre><code>var isLoaded = function (browser) {
      var waitForJS = waitForElement(browser, By.css('body.js'));
      var waitForMobile = waitForElement(browser, By.css('#mobile_landing_page'));
  
      return Promise.any([waitForJS, waitForMobile]);
  };
  </code></pre>
  
  <p>Here I want to create a generic function, that no matter whether it is on a mobile landing page or the desktop site waits until any of those two conditions is fulfilled.</p>
  
  <p>The way the promise manager interprets it though is </p>
  
  <pre><code>var isLoaded = function (browser) {
      var waitForMobile = waitForElement(browser, By.css('#mobile_landing_page'));
      var waitForJS = waitForElement(browser, By.css('body.js')).then(function () {
          return waitForMobile;
      });
  
      return Promise.any([waitForJS, waitForMobile]);
  };
  </code></pre>
  
  <p>This can obviously never resolve for the non-mobile case, since only one of those can be true at a time.</p>
  
  <p>Is there a way to completely disable the promise manager and manually schedule all calls?</p>
  
  <p>Here's the definition of <code>waitForElement</code></p>
  
  <pre><code>var waitForElement = function (browser, element, timeout) {
      return browser.wait(until.elementLocated(element), timeout);
  };
  </code></pre>