title: How to test value in input using XPath
body: <p>In my selenium tests I need to find input element with specific value.</p>
  
  <p>UI is rendered by following code:</p>
  
  <pre><code>&lt;div id="product-list"&gt;
    &lt;!-- ko foreach: $data.productItems --&gt;
      &lt;div class="product-list-item"&gt;
        &lt;input data-bind="value: $data.name"&gt;
      &lt;/div&gt; 
    &lt;!-- /ko --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My selenium tests uses following code to find input element with specific name:</p>
  
  <pre><code>By xpath = By.xpath(".//div[@id='product-list']//div[contains(@class, 'product-list-item')]/input[@value='Product Name']");
  WebElement element = browser.getWebDriver().findElement(xpath);
  </code></pre>
  
  <p>The problem is that element is always null since the <code>input[value='Product Name]"</code> will always fail, because there is no "value" attribute in input. There is just property "value" which you can see via it e.g. "Developer Tools" in Chrome.</p>
  
  <p>I have some example for investigating why "value" is not correctly processed.</p>
  
  <p><a href="https://jsfiddle.net/5fye0bbx/5/" rel="nofollow noreferrer">jsfiddle example</a></p>
  
  <p>Is there some advice how to find proper input element? Or at least explain how to handle value attribute vs value property?</p>
  
  <p>EDIT1: fixed missing @ in <code>input[@value='Product Name']</code></p>
  
  <p>EDIT2: updated example</p>
  
  <p>EDIT3: Isn't the issue caused by inability XPATH to access DOM properties and is only capable to process HTML (or any other XGML) tag structure and its attributes? Since the knockout pushes the real value into DOM properties only, it is then not reachable from XPATH.</p>