title: Can I wait for a subelement appear in selenium-webdriver
body: <p>I want to locate a deep nested element with selenium-webdiver.js</p>
  
  <p>How can I make sure, a specific element (in this special case lazy loaded in a shadow dom) is already present?
  I found this:</p>
  
  <pre><code>driver.wait(until.elementLocated(By.id('foo')), 10000);
  </code></pre>
  
  <p>But this searches in the whole DOM.</p>
  
  <p>I'm in shadow DOM, and have the expanded the shadow tree as a new WebElement, using this function:</p>
  
  <pre><code>const expandShadowElement = function(driver, element) {
    return driver.executeScript('return arguments[0].shadowRoot', 
    element);
  };
  const elShadowContent = expandShadowElement(driver, elShadowRoot);
  </code></pre>
  
  <p>So I think, I would need something, starting it's search (and wait) as subelement of elShadowContent.</p>