title: How can I extend the Selenium By.class to create more flexibility?
body: <p>How can I extend the Selenium <strong>By.class</strong> to create more flexibility?   I looked at the <a href="http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/By.java" rel="noreferrer">By.class</a> and I don't quite know how to approach this.   It looks like I need to create an interface class and a static By class, such as <strong>ByJavascriptGetWebElement</strong>, in order to create this kind of wrapper?</p>
  
  <p>I would like to be able to call it like:</p>
  
  <pre><code>By.javascript("return document.querySelector(\"div#item div\");", el );
  </code></pre>
  
  <p>And I have also heard of an easier way to do it but I would prefer to do it the more traditional way:</p>
  
  <pre><code>public By byJavascriptGetElement( WebElement we ) {
      return By.  ???
  }
  </code></pre>
  
  <p>Any ideas?</p>