title: Could not evaluate XPath (Behat/Mink)
body: <p>I'm using the following function:</p>
  
  <pre><code>    /**
      * Click on the element with the provided xpath query
      *
      * @When /^I click on the element with xpath "([^"]*)"$/
      */
     public function iClickOnTheElementWithXPath($xpath)
     {
         $session = $this-&gt;getSession(); // get the mink session
         $element = $session-&gt;getPage()-&gt;find('xpath',$session-&gt;getSelectorsHandler()-&gt;selectorToXpath('xpath', $xpath)); // runs the actual query and returns the element
  
         // errors must not pass silently
         if (null === $element) {
             throw new \InvalidArgumentException(sprintf('Could not evaluate XPath: "%s"', $xpath));
         }
  
         // ok, let's click on it
         $element-&gt;click();
  
     }
  </code></pre>
  
  <p>in my FeatureContext.php trying to click on a button with the following XPath (the Behat Step is): When I click on the element with XPath</p>
  
  <pre class="lang-none prettyprint-override"><code>//html/body/div[4]/div/div/div/div[2]/div[2]/div[4]/div/div/div/div[2]/ol/li/span[4]/a[1]
  </code></pre>
  
  <p>Firebug is happy with this XPath, but behat is giving me the error:</p>
  
  <blockquote>
    <p>Could not evaluate XPath: "//html/body/div[4]/div/div/div/div[2]/div[2]/div[4]/div/div/div/div[2]/ol/li/span[4]/a[1]"</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <p>here is an example of the Behat on w3schools, trying to click on the "Try it yourself" button": </p>
  
  <pre><code>             Feature: xpath try on w3schools.com/tags/att_input_src.asp 
               Scenario: click button on xpath 
                @javascript
               When I go to "/tags/att_input_src.asp" 
                And I click on the element with xpath "/html/body/div/div[3]/div[6]/div/a[1]" 
                And I wait 5 seconds
               Then I should be on "tags/tryit.asp?filename=tryhtml_input_src"
  </code></pre>
  
  <p>gives the same error, could not evaluate xpath, the xpath on Firebug shows the correct button...</p>