/** * 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; } }
public function stop() { if (!isset($this->sessionId)) { return; } //endlos-recursion verhinden wenn stop() nicht erfolgreich aufgerufen werden kann if (!$this->_stopping) { $this->_stopping = true; parent::stop(); } }
/** * @param array $browser * @return PHPUnit_Extensions_SeleniumTestCase_Driver * @since Method available since Release 3.3.0 */ protected function getDriver(array $browser) { if (isset($browser['name'])) { if (!is_string($browser['name'])) { throw new InvalidArgumentException('Array element "name" is no string.'); } } else { $browser['name'] = ''; } if (isset($browser['browser'])) { if (!is_string($browser['browser'])) { throw new InvalidArgumentException('Array element "browser" is no string.'); } } else { $browser['browser'] = ''; } if (isset($browser['host'])) { if (!is_string($browser['host'])) { throw new InvalidArgumentException('Array element "host" is no string.'); } } else { $browser['host'] = 'localhost'; } if (isset($browser['port'])) { if (!is_int($browser['port'])) { throw new InvalidArgumentException('Array element "port" is no integer.'); } } else { $browser['port'] = 4444; } if (isset($browser['timeout'])) { if (!is_int($browser['timeout'])) { throw new InvalidArgumentException('Array element "timeout" is no integer.'); } } else { $browser['timeout'] = 30; } if (isset($browser['httpTimeout'])) { if (!is_int($browser['httpTimeout'])) { throw new InvalidArgumentException('Array element "httpTimeout" is no integer.'); } } else { $browser['httpTimeout'] = 45; } $driver = new PHPUnit_Extensions_SeleniumTestCase_Driver(); $driver->setName($browser['name']); $driver->setBrowser($browser['browser']); $driver->setHost($browser['host']); $driver->setPort($browser['port']); $driver->setTimeout($browser['timeout']); $driver->setHttpTimeout($browser['httpTimeout']); $driver->setTestCase($this); $driver->setTestId($this->testId); $this->drivers[] = $driver; return $driver; }
/** * Stops browser connection if the session is not marked as contiguous * @return mixed */ public function stop() { if (!$this->_contiguousSession) { return; } self::$_currentSessionId = null; self::$_currentBrowser = null; self::$_currentContiguousSession = null; self::$_currentTestClassName = null; parent::stop(); }
/** * @param array $browser * @return PHPUnit_Extensions_SeleniumTestCase_Driver * @since Method available since Release 3.3.0 */ protected function getDriver(array $browser) { if (isset($browser['name'])) { if (!is_string($browser['name'])) { throw new InvalidArgumentException(); } } else { $browser['name'] = ''; } if (isset($browser['browser'])) { if (!is_string($browser['browser'])) { throw new InvalidArgumentException(); } } else { $browser['browser'] = ''; } if (isset($browser['host'])) { if (!is_string($browser['host'])) { throw new InvalidArgumentException(); } } else { $browser['host'] = 'localhost'; } if (isset($browser['port'])) { if (!is_int($browser['port'])) { throw new InvalidArgumentException(); } } else { $browser['port'] = 4444; } if (isset($browser['timeout'])) { if (!is_int($browser['timeout'])) { throw new InvalidArgumentException(); } } else { $browser['timeout'] = 30000; } $driver = new PHPUnit_Extensions_SeleniumTestCase_Driver(); $driver->setName($browser['name']); $driver->setBrowser($browser['browser']); $driver->setHost($browser['host']); $driver->setPort($browser['port']); $driver->setTimeout($browser['timeout']); $driver->setTestCase($this); $this->drivers[] = $driver; return $driver; }
/** * 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; }
/** * @param array $browser * @return PHPUnit_Extensions_SeleniumTestCase_Driver */ protected function getDriver(array $browser) { if (isset($browser['name'])) { if (!is_string($browser['name'])) { throw new InvalidArgumentException( 'Array element "name" is no string.' ); } } else { $browser['name'] = ''; } if (isset($browser['browser'])) { if (!is_string($browser['browser'])) { throw new InvalidArgumentException( 'Array element "browser" is no string.' ); } } else { $browser['browser'] = ''; } if (isset($browser['host'])) { if (!is_string($browser['host'])) { throw new InvalidArgumentException( 'Array element "host" is no string.' ); } } else { $browser['host'] = 'localhost'; } if (isset($browser['port'])) { if (!is_int($browser['port'])) { throw new InvalidArgumentException( 'Array element "port" is no integer.' ); } } else { $browser['port'] = 4444; } if (isset($browser['timeout'])) { if (!is_int($browser['timeout'])) { throw new InvalidArgumentException( 'Array element "timeout" is no integer.' ); } } else { $browser['timeout'] = 30; } if (isset($browser['httpTimeout'])) { if (!is_int($browser['httpTimeout'])) { throw new InvalidArgumentException( 'Array element "httpTimeout" is no integer.' ); } } else { $browser['httpTimeout'] = 45; } if (isset($browser['captureScreenshotOnFailure'])) { if (!is_bool($browser['captureScreenshotOnFailure'])) { throw new InvalidArgumentException( 'Array element "captureScreenshotOnFailure" is no boolean.' ); } } else { $browser['captureScreenshotOnFailure'] = false; } if (isset($browser['screenshotPath'])) { if (!is_string($browser['screenshotPath'])) { throw new InvalidArgumentException( 'Array element "screenshotPath" is no string.' ); } } else { $browser['screenshotPath'] = ''; } if (isset($browser['screenshotUrl'])) { if (!is_string($browser['screenshotUrl'])) { throw new InvalidArgumentException( 'Array element "screenshotUrl" is no string.' ); } } else { $browser['screenshotUrl'] = ''; } if (isset($browser['captureMethod'])) { if (!is_string($browser['captureMethod'])) { throw new InvalidArgumentException( 'Array element "captureMethod" is no string.' ); } } else { $browser['captureMethod'] = 'captureScreenshot'; } if (@fsockopen($browser['host'], $browser['port'], $errno, $errstr)) { $this->serverRunning = TRUE; } else { $this->serverRunning = FALSE; } $driver = new PHPUnit_Extensions_SeleniumTestCase_Driver; $driver->setName($browser['name']); $driver->setBrowser($browser['browser']); $driver->setHost($browser['host']); $driver->setPort($browser['port']); $driver->setTimeout($browser['timeout']); $driver->setHttpTimeout($browser['httpTimeout']); $driver->setCaptureScreenshotOnFailure($browser['captureScreenshotOnFailure']); $driver->setScreenshotPath($browser['screenshotPath']); $driver->setScreenshotUrl($browser['screenshotUrl']); $driver->setCaptureMethod($browser['captureMethod']); $driver->setTestCase($this); $driver->setTestId($this->testId); $this->drivers[] = $driver; return $driver; }