Support element lookup with javascript
There are a few use cases where it would be useful to be able to get an element returned by javascript (via execute() method). For complex lookups (e.g. find an element that contains a certain element), it may be useful to have this as an alternative to xpath.
This appears to be impossible because you must have access to the driver to construct a web element, but the driver is not available to the test case class.
In my case, I have a number of comment forms on a page without a unique identifier at the form element level, and I'd like to fill the form that contains a hidden input with a certain value.
Other use cases are finding the parent of an element (http://www.seleniumwebdriver.com/google-selenium-webdriver/parent-of-a-webelement/), using libraries such as jQuery or Sizzle, etc.
This can be done as a method in the Session object, where execute() resides. But what would you pass back from JavaScript to PHP to identify the found element? The id attribute?