mardi 25 août 2015

Could not find element with xpath in behat mink

I am now on BEHAT & MINK. I am having following error.

  1. I found xpath of particular element by below code.
public function iFindXpathOfElement($offername)
    {
        $session = $this->getMainContext()->getSession();
        $element = $this->getSession()->getPage()->findAll('css','li.ontBgcolor');
        if(!empty($element)){
            foreach ($element as $key => $arrObj) {
                if(strpos($arrObj->getText(), $offername)!== false){
                    $test = $arrObj->getXpath();
                    echo $test;
                    $xpathReturn = null;                        
                }
            }
        }        
    }

This function give me xpath in following format

(//html/descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' client_meeting_section ')])[2]

but now i am trying to above element with following function.

public function iShouldSeeXpath($xpath)
    {
        $session = $this->getMainContext()->getSession();

        $element = $session->getPage()->find(
            'xpath',
            $session->getSelectorsHandler()->selectorToXpath('xpath', $xpath)
        );

        if (null === $element) {
            throw new \InvalidArgumentException(sprintf('Cannot find element with the following xpath: "%s"', $xpath));
        }
    }

I am facing this error.

(::) failed steps (::)

01. Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "boolean".
    In step `And I should see "(//html/descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' client_meeting_section ')])[2]" xpath'.

Aucun commentaire:

Enregistrer un commentaire