Could not evaluate XPath (Behat/Mink) -
i'm using following function:
/** * click on element provided xpath query * * @when /^i click on element xpath "([^"]*)"$/ */ public function iclickontheelementwithxpath($xpath) { $session = $this->getsession(); // mink session $element = $session->getpage()->find('xpath',$session->getselectorshandler()->selectortoxpath('xpath', $xpath)); // runs actual query , returns element // errors must not pass silently if (null === $element) { throw new \invalidargumentexception(sprintf('could not evaluate xpath: "%s"', $xpath)); } // ok, let's click on $element->click(); } in featurecontext.php trying click on button following xpath (the behat step is): when click on element 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] firebug happy xpath, behat giving me error:
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]"
what doing wrong?
here example of behat on w3schools, trying click on "try yourself" button":
feature: xpath try on w3schools.com/tags/att_input_src.asp scenario: click button on xpath @javascript when go "/tags/att_input_src.asp" , click on element xpath "/html/body/div/div[3]/div[6]/div/a[1]" , wait 5 seconds should on "tags/tryit.asp?filename=tryhtml_input_src" gives same error, not evaluate xpath, xpath on firebug shows correct button...
i had same problem. appears need ommit /html/body. me
//div[2]/div/div[2]/div/table/tbody/tr/td[3] works fine.
Comments
Post a Comment