title: Is there relative CSS locator for Selenium?
body: <p>Suppose I'm looking for some <b>div</b> elements under <b>#myPage</b> element.
  My goal is to use CSS selectors and limit the search only to <b>#myPage</b> descendants.</p>
  
  <p>Using Selenium XPath locators I can write something like this:</p>
  
  <pre><code>WebElement page = driver.findElement(new By.ById("myPage"));
  ....
  List&lt;WebElement&gt; item = page.findElements(new By.ByXPath(".//div"));
  </code></pre>
  
  <p>However, trying to use CSS yields all <b>divs</b> in documents, not only descendants of <b>#myPage</b>:</p>
  
  <pre><code>WebElement page = driver.findElement(new By.ById("myPage"));
  ....
  List&lt;WebElement&gt; item = page.findElements(new By.ByCssSelector("div"));
  </code></pre>
  
  <p>The big difference is the <code>.//</code> prefix that makes the XPath expression relative. I couldn't find similar property in CSS syntax, and I wonder if it's even possible.</p>
  
  <p>P.S.<BR>
  I know I can use <code>#myPage > div</code> expression, but then I couple the page lookup operation with the lookup of its descendants, which is not always desirable.</p>