Esempio n. 1
0
 /**
  * Sends a command to the Selenium RC server.
  * Extension: transaction logging to opened file stream in view: TIME,REQUEST,RESPONSE or TIME,EXCEPTION
  *
  * @param string $command Command for send to Selenium RC server
  * @param array $arguments Array of arguments to command
  * @param array $namedArguments
  *
  * @throws Exception
  * @return string
  */
 protected function doCommand($command, array $arguments = array(), array $namedArguments = array())
 {
     try {
         $response = parent::doCommand($command, $arguments, $namedArguments);
         // Add command logging
         if (!empty($this->_logHandle)) {
             fputs($this->_logHandle, self::udate('H:i:s.u') . "\n");
             fputs($this->_logHandle, "\tRequest: " . $command . "\n");
             if ($command == 'captureEntirePageScreenshotToString' || $command == 'getHtmlSource') {
                 fputs($this->_logHandle, "\tResponse: OK\n\n");
             } else {
                 fputs($this->_logHandle, "\tResponse: " . $response . "\n\n");
             }
             fflush($this->_logHandle);
         }
         return $response;
     } catch (Exception $e) {
         if (!empty($this->_logHandle)) {
             fputs($this->_logHandle, self::udate('H:i:s.u') . "\n");
             fputs($this->_logHandle, "\tRequest: " . $command . "\n");
             fputs($this->_logHandle, "\tException: " . $e->getMessage() . "\n\n");
             fflush($this->_logHandle);
         }
         throw $e;
     }
 }
Esempio n. 2
0
 /**
  * Sends a command to the Selenium RC server.
  * Extension: transaction logging to opened file stream in view: TIME,REQUEST,RESPONSE or TIME,EXCEPTION
  *
  * @param string $command Command for send to Selenium RC server
  * @param array $arguments Array of arguments to command
  *
  * @return string
  * @throws RuntimeException
  */
 protected function doCommand($command, array $arguments = array())
 {
     try {
         $response = parent::doCommand($command, $arguments);
         //Fixed bug for PHPUnit_Selenium 1.2.0(1)
         if (!preg_match('/^OK/', $response)) {
             throw new RuntimeException($response);
         }
         // Add command logging
         if (!empty(self::$_logHandle)) {
             fputs(self::$_logHandle, self::udate('H:i:s.u') . "\n");
             fputs(self::$_logHandle, "\tRequest: " . $command . "\n");
             fputs(self::$_logHandle, "\tResponse: " . $response . "\n\n");
             fflush(self::$_logHandle);
         }
         return $response;
     } catch (RuntimeException $e) {
         if (!empty(self::$_logHandle)) {
             fputs(self::$_logHandle, self::udate('H:i:s.u') . "\n");
             fputs(self::$_logHandle, "\tRequest: " . $command . "\n");
             fputs(self::$_logHandle, "\tException: " . $e->getMessage() . "\n\n");
             fflush(self::$_logHandle);
         }
         throw $e;
     }
 }
 /**
  * Sends a command to the Selenium RC server.
  * Extension: transaction logging to opened file stream in view: TIME,REQUEST,RESPONSE or TIME,EXCEPTION
  *
  * @param  string $command Command for send to Selenium RC server
  * @param  array $arguments Array of arguments to command
  * @return string
  */
 protected function doCommand($command, array $arguments = array())
 {
     // Add command logging
     try {
         $response = parent::doCommand($command, $arguments);
         if (!empty($this->_logHandle)) {
             fputs($this->_logHandle, self::udate('H:i:s.u') . "\n");
             fputs($this->_logHandle, "\tRequest: " . end($this->commands) . "\n");
             fputs($this->_logHandle, "\tResponse: " . $response . "\n\n");
             fflush($this->_logHandle);
         }
     } catch (PHPUnit_Framework_Exception $e) {
         if (!empty($this->_logHandle)) {
             fputs($this->_logHandle, self::udate('H:i:s.u') . "\n");
             fputs($this->_logHandle, "\tException: " . $e->getMessage() . "\n");
             fflush($this->_logHandle);
         }
         throw $e;
     }
     return $response;
 }