original_string: protected function ensure_element_exists($element, $selectortype) {
  
          // Getting the behat selector & locator.
          list($selector, $locator) = $this->transform_selector($selectortype, $element);
  
          // Exception if it timesout and the element is still there.
          $msg = 'The "' . $element . '" element does not exist and should exist';
          $exception = new ExpectationException($msg, $this->getSession());
  
          // It will stop spinning once the find() method returns true.
          $this->spin(
              function($context, $args) {
                  // We don't use behat_base::find as it is already spinning.
                  if ($context->getSession()->getPage()->find($args['selector'], $args['locator'])) {
                      return true;
                  }
                  return false;
              },
              array('selector' => $selector, 'locator' => $locator),
              self::get_extended_timeout(),
              $exception,
              true
          );
  
      }
code: protected function ensure_element_exists($element, $selectortype) {
  
          // Getting the behat selector & locator.
          list($selector, $locator) = $this->transform_selector($selectortype, $element);
  
          // Exception if it timesout and the element is still there.
          $msg = 'The "' . $element . '" element does not exist and should exist';
          $exception = new ExpectationException($msg, $this->getSession());
  
          // It will stop spinning once the find() method returns true.
          $this->spin(
              function($context, $args) {
                  // We don't use behat_base::find as it is already spinning.
                  if ($context->getSession()->getPage()->find($args['selector'], $args['locator'])) {
                      return true;
                  }
                  return false;
              },
              array('selector' => $selector, 'locator' => $locator),
              self::get_extended_timeout(),
              $exception,
              true
          );
  
      }
code_tokens: protected function ensure_element_exists ( $ element , $ selectortype ) { // Getting the behat selector & locator. list ( $ selector , $ locator ) = $ this -> transform_selector ( $ selectortype , $ element ) ; // Exception if it timesout and the element is still there. $ msg = 'The "' . $ element . '" element does not exist and should exist' ; $ exception = new ExpectationException ( $ msg , $ this -> getSession ( ) ) ; // It will stop spinning once the find() method returns true. $ this -> spin ( function ( $ context , $ args ) { // We don't use behat_base::find as it is already spinning. if ( $ context -> getSession ( ) -> getPage ( ) -> find ( $ args [ 'selector' ] , $ args [ 'locator' ] ) ) { return true ; } return false ; } , array ( 'selector' => $ selector , 'locator' => $ locator ) , self :: get_extended_timeout ( ) , $ exception , true ) ; }
docstring: Spins around an element until it exists
  
  @throws ExpectationException
  @param string $element
  @param string $selectortype
  @return void
docstring_tokens: Spins around an element until it exists