library/MinkWrapper.php
public function select($sSelector, $sOptionSelector)
    {
        $oSelectorsHandler = $this->getMinkSession()->getSelectorsHandler();
        $oSelect = null;

        if (strpos($sSelector, '/') === false) {
            $page = $this->getMinkSession()->getPage();
            $sParsedSelector = $oSelectorsHandler->xpathLiteral($sSelector);
            $oSelect = $page->find('named', array('select', $sParsedSelector));
        }

        if (is_null($oSelect)) {
            $oSelect = $this->getElementLazy($sSelector);
        }

        if (strpos($sOptionSelector, 'index=') === 0) {
            $iIndex = str_replace('index=', '', $sOptionSelector);
            $sOptionSelector = $this->_getSelectOptionByIndex($oSelect, $iIndex);
        } else {
            $sOptionSelector = str_replace(array('label=', 'value='), '', $sOptionSelector);
        }

        if (is_null($oSelect)) {
            $this->fail("Select '$sSelector' was not found!");
        }

        $oOptions = $oSelect->findAll('named', array('option', $oSelectorsHandler->xpathLiteral($sOptionSelector)));

        $oOption = $this->_getExactMatch($oOptions, $sOptionSelector);

        if (is_null($oOption)) {
            $this->fail("Option '$sOptionSelector' was not found in '$sSelector' select ");
        }

        $this->getMinkSession()->getDriver()->selectOption(
            $oSelect->getXpath(), $oOption->getValue(), false
        );

        $this->fireEvent($sSelector, 'change');
    }
public function select($sSelector, $sOptionSelector)
    {
        $oSelectorsHandler = $this->getMinkSession()->getSelectorsHandler();
        $oSelect = null;

        if (strpos($sSelector, '/') === false) {
            $page = $this->getMinkSession()->getPage();
            $sParsedSelector = $oSelectorsHandler->xpathLiteral($sSelector);
            $oSelect = $page->find('named', array('select', $sParsedSelector));
        }

        if (is_null($oSelect)) {
            $oSelect = $this->getElementLazy($sSelector);
        }

        if (strpos($sOptionSelector, 'index=') === 0) {
            $iIndex = str_replace('index=', '', $sOptionSelector);
            $sOptionSelector = $this->_getSelectOptionByIndex($oSelect, $iIndex);
        } else {
            $sOptionSelector = str_replace(array('label=', 'value='), '', $sOptionSelector);
        }

        if (is_null($oSelect)) {
            $this->fail("Select '$sSelector' was not found!");
        }

        $oOptions = $oSelect->findAll('named', array('option', $oSelectorsHandler->xpathLiteral($sOptionSelector)));

        $oOption = $this->_getExactMatch($oOptions, $sOptionSelector);

        if (is_null($oOption)) {
            $this->fail("Option '$sOptionSelector' was not found in '$sSelector' select ");
        }

        $this->getMinkSession()->getDriver()->selectOption(
            $oSelect->getXpath(), $oOption->getValue(), false
        );

        $this->fireEvent($sSelector, 'change');
    }
public function select ( $ sSelector , $ sOptionSelector ) { $ oSelectorsHandler = $ this -> getMinkSession ( ) -> getSelectorsHandler ( ) ; $ oSelect = null ; if ( strpos ( $ sSelector , '/' ) === false ) { $ page = $ this -> getMinkSession ( ) -> getPage ( ) ; $ sParsedSelector = $ oSelectorsHandler -> xpathLiteral ( $ sSelector ) ; $ oSelect = $ page -> find ( 'named' , array ( 'select' , $ sParsedSelector ) ) ; } if ( is_null ( $ oSelect ) ) { $ oSelect = $ this -> getElementLazy ( $ sSelector ) ; } if ( strpos ( $ sOptionSelector , 'index=' ) === 0 ) { $ iIndex = str_replace ( 'index=' , '' , $ sOptionSelector ) ; $ sOptionSelector = $ this -> _getSelectOptionByIndex ( $ oSelect , $ iIndex ) ; } else { $ sOptionSelector = str_replace ( array ( 'label=' , 'value=' ) , '' , $ sOptionSelector ) ; } if ( is_null ( $ oSelect ) ) { $ this -> fail ( "Select '$sSelector' was not found!" ) ; } $ oOptions = $ oSelect -> findAll ( 'named' , array ( 'option' , $ oSelectorsHandler -> xpathLiteral ( $ sOptionSelector ) ) ) ; $ oOption = $ this -> _getExactMatch ( $ oOptions , $ sOptionSelector ) ; if ( is_null ( $ oOption ) ) { $ this -> fail ( "Option '$sOptionSelector' was not found in '$sSelector' select " ) ; } $ this -> getMinkSession ( ) -> getDriver ( ) -> selectOption ( $ oSelect -> getXpath ( ) , $ oOption -> getValue ( ) , false ) ; $ this -> fireEvent ( $ sSelector , 'change' ) ; }
Selects select element option

@param $sSelector
@param $sOptionSelector
Selects select element option