Find element by property value
<p>I'm testing a web application using <a href="http://nightwatchjs.org/" rel="nofollow">Nightwatch.js</a>, which uses <a href="http://www.seleniumhq.org/projects/webdriver/" rel="nofollow">Selenium WebDriver</a> to interact with the browser. In my app I have a dynamically created list of items differentiated only by their names and the names are displayed as <code>&lt;input&gt;</code> values. I need to find an item by its name.</p>

<p>Example HTML representation of document structure:</p>

<pre><code>&lt;div class="item"&gt;
  &lt;input&gt;  &lt;!-- current value: "first" --&gt;
&lt;/div&gt;
&lt;div class="item"&gt;
  &lt;input&gt;  &lt;!-- current value: "second" --&gt;
&lt;/div&gt;
&lt;div class="item"&gt;
  &lt;input&gt;  &lt;!-- current value: "first" --&gt;
&lt;/div&gt;
</code></pre>

<p>I need to find <code>div.item</code> containing an input with the value <code>second</code>.</p>

<p>Note that the value of an <code>&lt;input&gt;</code> is determined by the value of its <code>value</code> <em>property</em>, which might be different from the value of its <code>value</code> <em>attribute</em>. In my case, the DOM is manipulated by <a href="https://facebook.github.io/react/" rel="nofollow">React</a>, so the inputs might not have the <code>value</code> attribute at all.</p>

<p><strong>Is there a way to find element by <em>property</em> value with Nightwatch (or Selenium WebDriver API)?</strong></p>

<p>I looked over the WebDriver <a href="http://www.seleniumhq.org/docs/03_webdriver.jsp#locating-ui-elements-webelements" rel="nofollow">documentation</a> and the only way I see is <a href="http://nightwatchjs.org/api/execute.html" rel="nofollow">executing</a> custom JavaScript code, which has some serious drawbacks (e.g. requires own implementation of waiting for element to appear and doesn't interact with Nightwatch page objects). As far as I can see, all of the other methods are concerned with looking at the HTML only (so <em>attributes</em> at best, not <em>properties</em>).</p>

<hr>

<p><em>Just to be completely clear, using selectors like <code>input[value=...]</code> (CSS) or <code>//input[@value=...]</code> (XPath) is <strong>not</strong> a solution, as it performs lookup by attribute value, not property value.</em></p>