title: Selecting and Identifying element with JQuery to use it in Selenium 2 Java API
body: <p>This is the situation:</p>
  
  <ul>
  <li>I use the Java API of Selenium 2 to open and control a firefox browser instance</li>
  <li>I load the jQuery script to a page via JavaScript execution</li>
  <li>I then use jQuery expressions to select elements and traverse through the DOM tree</li>
  </ul>
  
  <p>Now is my question, can i somehow find a unique identifier for each of the found elements? My goal is to get the same element with Selenium by using an Xpath or CSS selector. So it would be most straighforward if i could generate an unambiguous selector for the elements in jQuery. Other ideas are welcome too.</p>
  
  <p>I need an automatic approach for identifying elements in jQuery, which can be "converted" to Selenium elements / locators.</p>
  
  <p>/edit</p>
  
  <p>To make it clearer:</p>
  
  <p>If i have selected an element in jQuery:</p>
  
  <pre><code>webDriver.executeScript("var element = $('#myDiv input.test')");
  </code></pre>
  
  <p>Now, I want something like this:</p>
  
  <pre><code>WebElement webElement = webDriver.executeScript("return element");
  </code></pre>
  
  <p>Is that possible?</p>