title: Find next sibling of any given element with Selenium WebDriver
body: <p>I'm trying to create a method that given a WebElement finds and returns the very next element. I have found a lot of examples for what should work using XPath with "following" or "following-sibling" but I can't get it to work. For the purpose of the question here I will show the html, but the element types are irrelevant for what I need as I want a generic method that given any element of any type (a/ul/div/whatever) it will return the next sibling regardless of type.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;a id="blah" href="#" class="stuff"&gt;"My Label"&lt;/a&gt;
  &lt;ul class="some-class"&gt;
      &lt;li&gt;...&lt;/li&gt;
      &lt;li&gt;...&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  
  
  <p>My buggy debugging code:</p>
  
  <pre><code>IWebElement element = driver.FindElement(By.Id("blah"));
  IWebElement nextElement = element.FindElement(By.XPath("//following-sibling::ul[@class='some-class']"));
  </code></pre>
  
  <p>I suspect my xpath syntax is wrong... and I am frankly clueless. Does the "//" mean relative to element or to the DOM itself? Is there a way of doing this without knowing what the tag of the next element is? I would like to just get the next element no matter what type it is. I'd just like to figure out the simplest and most generic way to do this. What I would like to have:</p>
  
  <pre><code>public IWebElement NextSibling(IWebElement element) 
  {
      IWebElement nextSibling = element.FindElement(By.?("magical string to find next sibling"));
      return nextSibling;
  }
  </code></pre>
  
  <p>...which is exactly what you can already do in javascript with <code>element.nextSibling()</code></p>