title: Selenium: finding elements in searchContext
body: <p>everyone!
  I'm stuck with following problem:
  There is some</p>
  
  <pre><code>SearchContext searchContext;
  By by;
  </code></pre>
  
  <p>which could be WebDriver or WebElement.
  Assume that both of them are already initialized (and we don't know how);
  Now we want to find elements with such xpath, seems to do following</p>
  
  <pre><code>List&lt;WebElement&gt; elements = searchContext.findElements(by);
  </code></pre>
  
  <p>But, if searchContext is WebElement and</p>
  
  <pre><code>by = By.xpath("//div");
  </code></pre>
  
  <p>it wouldn't work! (no elements would be found), because we need to do</p>
  
  <pre><code>by = By.xpath("./div");
  </code></pre>
  
  <p>(see <a href="https://stackoverflow.com/questions/10520294/locating-child-nodes-of-webelements-in-selenium">Locating child nodes of WebElements in selenium</a>)
  But, how i've mentioned, we know nothing about how by was initialized;</p>
  
  <p>So, my question is: is there any way to find elements properly despite the problems above?
  I've got two variables: by and searchContext, and I should to find specified element in searchContext.</p>